/** * Copyright 2022 Gravwell, Inc. All rights reserved. * * Contact: [legal@gravwell.io](mailto:legal@gravwell.io) * * This software may be modified and distributed under the terms of the MIT * license. See the LICENSE file for details. */ interface ProgrammaticPromise { promise: Promise; resolve: (value: T) => void; reject: (error: Error) => void; } export const createProgrammaticPromise = (): ProgrammaticPromise => { const obj = {} as ProgrammaticPromise; obj.promise = new Promise((_resolve, _reject) => { obj.resolve = (value: T) => _resolve(value); obj.reject = (error: Error) => _reject(error); }); return obj; };