diff options
author | Minteck <contact@minteck.org> | 2022-02-12 10:33:06 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-02-12 10:33:06 +0100 |
commit | 01160246e4a0c0052181c72a53737e356ea7d02d (patch) | |
tree | c6f8ea675f9147d4c06ef503697fb35d58493991 /node_modules/@kwsites | |
parent | af898a152a14e31bdbcbbedb952ad333697553ef (diff) | |
download | twilight-01160246e4a0c0052181c72a53737e356ea7d02d.tar.gz twilight-01160246e4a0c0052181c72a53737e356ea7d02d.tar.bz2 twilight-01160246e4a0c0052181c72a53737e356ea7d02d.zip |
First commit
Diffstat (limited to 'node_modules/@kwsites')
21 files changed, 485 insertions, 0 deletions
diff --git a/node_modules/@kwsites/file-exists/CHANGELOG.md b/node_modules/@kwsites/file-exists/CHANGELOG.md new file mode 100644 index 0000000..9361ecb --- /dev/null +++ b/node_modules/@kwsites/file-exists/CHANGELOG.md @@ -0,0 +1,12 @@ + +# Release History + +## 1.1.1 + +- Add dependency on `debug` to log results of the file system checks +- Add `jest` tests + +# 1.0.0 + +- First public release, a simple typescript library for checking whether a path exists + on the file system and optionally whether it points to a file or folder. diff --git a/node_modules/@kwsites/file-exists/LICENSE b/node_modules/@kwsites/file-exists/LICENSE new file mode 100644 index 0000000..b123c04 --- /dev/null +++ b/node_modules/@kwsites/file-exists/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2015 Steve King + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/@kwsites/file-exists/dist/index.d.ts b/node_modules/@kwsites/file-exists/dist/index.d.ts new file mode 100644 index 0000000..8420b10 --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/index.d.ts @@ -0,0 +1 @@ +export * from './src'; diff --git a/node_modules/@kwsites/file-exists/dist/index.js b/node_modules/@kwsites/file-exists/dist/index.js new file mode 100644 index 0000000..87332ba --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/index.js @@ -0,0 +1,7 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./src")); +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/@kwsites/file-exists/dist/index.js.map b/node_modules/@kwsites/file-exists/dist/index.js.map new file mode 100644 index 0000000..3b75ca4 --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;AACA,2BAAsB"}
\ No newline at end of file diff --git a/node_modules/@kwsites/file-exists/dist/src/index.d.ts b/node_modules/@kwsites/file-exists/dist/src/index.d.ts new file mode 100644 index 0000000..3d234cd --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/src/index.d.ts @@ -0,0 +1,19 @@ +/** + * Synchronous validation of a path existing either as a file or as a directory. + * + * @param {string} path The path to check + * @param {number} type One or both of the exported numeric constants + */ +export declare function exists(path: string, type?: number): boolean; +/** + * Constant representing a file + */ +export declare const FILE = 1; +/** + * Constant representing a folder + */ +export declare const FOLDER = 2; +/** + * Constant representing either a file or a folder + */ +export declare const READABLE: number; diff --git a/node_modules/@kwsites/file-exists/dist/src/index.js b/node_modules/@kwsites/file-exists/dist/src/index.js new file mode 100644 index 0000000..8a41c70 --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/src/index.js @@ -0,0 +1,55 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs_1 = require("fs"); +const debug_1 = __importDefault(require("debug")); +const log = debug_1.default('@kwsites/file-exists'); +function check(path, isFile, isDirectory) { + log(`checking %s`, path); + try { + const stat = fs_1.statSync(path); + if (stat.isFile() && isFile) { + log(`[OK] path represents a file`); + return true; + } + if (stat.isDirectory() && isDirectory) { + log(`[OK] path represents a directory`); + return true; + } + log(`[FAIL] path represents something other than a file or directory`); + return false; + } + catch (e) { + if (e.code === 'ENOENT') { + log(`[FAIL] path is not accessible: %o`, e); + return false; + } + log(`[FATAL] %o`, e); + throw e; + } +} +/** + * Synchronous validation of a path existing either as a file or as a directory. + * + * @param {string} path The path to check + * @param {number} type One or both of the exported numeric constants + */ +function exists(path, type = exports.READABLE) { + return check(path, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0); +} +exports.exists = exists; +/** + * Constant representing a file + */ +exports.FILE = 1; +/** + * Constant representing a folder + */ +exports.FOLDER = 2; +/** + * Constant representing either a file or a folder + */ +exports.READABLE = exports.FILE + exports.FOLDER; +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/@kwsites/file-exists/dist/src/index.js.map b/node_modules/@kwsites/file-exists/dist/src/index.js.map new file mode 100644 index 0000000..68f2b8a --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,2BAA8B;AAC9B,kDAA0B;AAE1B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ules/@kwsites/file-exists/dist/test/__mocks__/fs.d.ts new file mode 100644 index 0000000..ab80d33 --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.d.ts @@ -0,0 +1,7 @@ +export declare function statSync(...args: any[]): any; +export declare function addStatSyncMock(fn: any): void; +export declare function assertMocksUsed(): void; +declare const mockFs: { + statSync: typeof statSync; +}; +export default mockFs; diff --git a/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.js b/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.js new file mode 100644 index 0000000..cd46c71 --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let statSyncMocks = []; +function statSync(...args) { + const mock = statSyncMocks.shift(); + if (typeof mock !== 'function') { + throw new Error(`fs.statSync called without configuring a mock`); + } + return mock(...args); +} +exports.statSync = statSync; +function addStatSyncMock(fn) { + statSyncMocks.push(fn); +} +exports.addStatSyncMock = addStatSyncMock; +function assertMocksUsed() { + if (statSyncMocks.length) { + throw new Error(`fs.afterEach: statSync has ${statSyncMocks.length} unused mocks`); + } +} +exports.assertMocksUsed = assertMocksUsed; +const mockFs = { + statSync, +}; +exports.default = mockFs; +//# sourceMappingURL=fs.js.map
\ No newline at end of file diff --git a/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.js.map b/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.js.map new file mode 100644 index 0000000..e2a3d16 --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/test/__mocks__/fs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../test/__mocks__/fs.ts"],"names":[],"mappings":";;AACA,IAAI,aAAa,GAAU,EAAE,CAAC;AAE9B,SAAgB,QAAQ,CAAC,GAAG,IAAW;IACpC,MAAO,IAAI,GAAG,aAAa,CAAC,KAAK,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KACnE;IAED,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACxB,CAAC;AAPD,4BAOC;AAED,SAAgB,eAAe,CAAC,EAAO;IACpC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe;IAC5B,IAAI,aAAa,CAAC,MAAM,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,8BAA8B,aAAa,CAAC,MAAM,eAAe,CAAC,CAAC;KACrF;AACJ,CAAC;AAJD,0CAIC;AAED,MAAM,MAAM,GAAG;IACZ,QAAQ;CACV,CAAA;AAED,kBAAe,MAAM,CAAC"}
\ No newline at end of file diff --git a/node_modules/@kwsites/file-exists/dist/test/exists.spec.d.ts b/node_modules/@kwsites/file-exists/dist/test/exists.spec.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/test/exists.spec.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@kwsites/file-exists/dist/test/exists.spec.js b/node_modules/@kwsites/file-exists/dist/test/exists.spec.js new file mode 100644 index 0000000..a36b549 --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/test/exists.spec.js @@ -0,0 +1,77 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +jest.mock('fs'); +//@ts-ignore +const fs_1 = require("fs"); +const src_1 = require("../src"); +describe(`exists`, () => { + let statSync; + let statSyncMock; + let path; + beforeEach(() => { + path = `./path/${Math.random()}`; + fs_1.addStatSyncMock(statSyncMock = jest.fn(() => statSync())); + }); + afterEach(() => { + fs_1.assertMocksUsed(); + statSync = statSyncMock = undefined; + }); + describe('known errors', () => { + beforeEach(() => givenStatSyncThrows({ code: 'ENOENT' })); + it('with type', () => { + expect(src_1.exists(path, src_1.READABLE)).toBe(false); + }); + it('with type omitted', () => { + expect(src_1.exists(path)).toBe(false); + }); + }); + describe('unknown errors', () => { + let err; + beforeEach(() => err = givenStatSyncThrows(new Error('something'))); + it('with type', () => { + expect(() => src_1.exists(path, src_1.READABLE)).toThrow(err); + }); + it('with type omitted', () => { + expect(() => src_1.exists(path)).toThrow(err); + }); + }); + describe('path is a file', () => { + beforeEach(() => givenStatSyncIsA('file')); + existsReturns(true, false, true); + }); + describe('path is a folder', () => { + beforeEach(() => givenStatSyncIsA('folder')); + existsReturns(false, true, true); + }); + describe('path is unknown', () => { + beforeEach(() => givenStatSyncIsA('unknown')); + existsReturns(false, false, false); + }); + function existsReturns(file, folder, readable) { + it('when searching for a file', () => { + expect(src_1.exists(path, src_1.FILE)).toBe(file); + }); + it('when searching for a folder', () => { + expect(src_1.exists(path, src_1.FOLDER)).toBe(folder); + }); + it('when searching for either', () => { + expect(src_1.exists(path, src_1.READABLE)).toBe(readable); + }); + it('when searching without a type', () => { + expect(src_1.exists(path)).toBe(readable); + }); + } + function givenStatSyncThrows(err) { + statSync = () => { throw err; }; + return err; + } + function givenStatSyncIsA(type) { + const mockStat = { + isFile() { return type === 'file'; }, + isDirectory() { return type === 'folder'; }, + }; + statSync = () => mockStat; + return mockStat; + } +}); +//# sourceMappingURL=exists.spec.js.map
\ No newline at end of file diff --git a/node_modules/@kwsites/file-exists/dist/test/exists.spec.js.map b/node_modules/@kwsites/file-exists/dist/test/exists.spec.js.map new file mode 100644 index 0000000..669176a --- /dev/null +++ b/node_modules/@kwsites/file-exists/dist/test/exists.spec.js.map @@ -0,0 +1 @@ +{"version":3,"file":"exists.spec.js","sourceRoot":"","sources":["../../test/exists.spec.ts"],"names":[],"mappings":";;AACA,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEhB,YAAY;AACZ,2BAAsD;AACtD,gCAAwD;AAExD,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IAErB,IAAI,QAAa,CAAC;IAClB,IAAI,YAAiB,CAAC;IACtB,IAAI,IAAY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YAAM,CAAC,IAAI,EAAE,cAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACtC,MAAM,CAAC,YAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACN,CAAC;IAED,SAAS,mBAAmB,CAAE,GAAQ;QACnC,QAAQ,GAAG,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAChC,OAAO,GAAG,CAAC;IACd,CAAC;IAED,SAAS,gBAAgB,CAAE,IAAmC;QAC3D,MAAM,QAAQ,GAAG;YACd,MAAM,KAAM,OAAO,IAAI,KAAK,MAAM,CAAA,CAAC,CAAC;YACpC,WAAW,KAAM,OAAO,IAAI,KAAK,QAAQ,CAAA,CAAC,CAAC;SAC7C,CAAC;QACF,QAAQ,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC;QAC1B,OAAO,QAAQ,CAAC;IACnB,CAAC;AAEJ,CAAC,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/@kwsites/file-exists/package.json b/node_modules/@kwsites/file-exists/package.json new file mode 100644 index 0000000..1cf6a80 --- /dev/null +++ b/node_modules/@kwsites/file-exists/package.json @@ -0,0 +1,42 @@ +{ + "name": "@kwsites/file-exists", + "version": "1.1.1", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "license": "MIT", + "repository": "git@github.com:kwsites/file-exists.git", + "author": "Steve King <steve@mydev.co>", + "contributors": [ + { + "name": "Steve King", + "email": "steve@mydev.co" + } + ], + "files": [ + "dist/**/*.*" + ], + "scripts": { + "clean": "rimraf ./dist", + "build": "yarn run clean && tsc", + "preversion": "yarn run clean && yarn run build && yarn test", + "postversion": "npm publish --access=public && git push && git push --tags", + "test": "jest --coverage", + "tsc": "tsc" + }, + "devDependencies": { + "@babel/core": "^7.10.1", + "@babel/preset-env": "^7.10.1", + "@babel/preset-typescript": "^7.10.1", + "@types/debug": "^4.1.5", + "@types/jest": "^26.0.0", + "@types/node": "^10.12.0", + "babel-jest": "^26.0.1", + "jest": "^25.3.0", + "rimraf": "^2.6.2", + "ts-node": "^8.10.2", + "typescript": "^3.1.3" + }, + "dependencies": { + "debug": "^4.1.1" + } +} diff --git a/node_modules/@kwsites/file-exists/readme.md b/node_modules/@kwsites/file-exists/readme.md new file mode 100644 index 0000000..0db6d0f --- /dev/null +++ b/node_modules/@kwsites/file-exists/readme.md @@ -0,0 +1,41 @@ +# @kwsites/file-exists + +Synchronous validation of a path existing either as a file or as a directory. + +``` +const { exists, FILE, FOLDER, READABLE } = require('@kwsites/file-exists'); + +// check for a folder existing +assert(exists(__dirname, FOLDER)); +assert(!exists(__filename, FOLDER)); + +// check for a file existing +assert(!exists(__filename, FILE)); +assert(exists(__filename, FILE)); + +// when no type is specified, both folders and files are allowed +assert(exists(__dirname)); +assert(exists(__filename)); + +// alternatively specify both files and folders +assert(exists(__dirname, FILE + FOLDER)); + +// or just that the path is readable (can be either a file or folder) +assert(exists(__filename, READABLE)); +``` + +## Troubleshooting + +This library uses [debug](https://www.npmjs.com/package/debug) to handle logging, +to enable logging, use either the environment variable: + +``` +"DEBUG=@kwsites/file-exists" node ./your-app.js +``` + +Or explicitly enable logging using the `debug` library itself: + +```javascript +require('debug').enable('@kwsites/file-exists'); +``` + diff --git a/node_modules/@kwsites/promise-deferred/LICENSE b/node_modules/@kwsites/promise-deferred/LICENSE new file mode 100644 index 0000000..d082eb9 --- /dev/null +++ b/node_modules/@kwsites/promise-deferred/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 kwsites + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@kwsites/promise-deferred/dist/index.d.ts b/node_modules/@kwsites/promise-deferred/dist/index.d.ts new file mode 100644 index 0000000..68fb38a --- /dev/null +++ b/node_modules/@kwsites/promise-deferred/dist/index.d.ts @@ -0,0 +1,49 @@ +/** + * The `DeferredPromise` has a `promise` property in an initially pending state, + * that will be resolved when the `done` method is called or rejected when the + * `fail` method is called. + */ +export interface DeferredPromise<RESOLVES, REJECTS extends Error = Error> { + done(result: RESOLVES): void; + fail(error: REJECTS): void; + readonly status: DeferredPromiseStatus; + readonly fulfilled: boolean; + promise: Promise<RESOLVES>; +} +/** + * The three states the DeferredPromise can be in - initially pending then either + * resolved or rejected when it is fulfilled. + * + * ```typescript + import {createDeferred, DeferredPromiseStatus} from '@kwsites/promise-deferred`; + + const pending: DeferredPromiseStatus = 'pending'; + expect(createDeferred()).toHaveProperty('status', pending); + ``` + */ +export declare type DeferredPromiseStatus = 'pending' | 'resolved' | 'rejected'; +/** + * Creates a new `DeferredPromise` + * + * ```typescript + import {deferred} from '@kwsites/promise-deferred`; + ``` + */ +export declare function deferred<T extends any = void, E extends Error = Error>(): DeferredPromise<T, E>; +/** + * Alias of the exported `deferred` function, to help consumers wanting to use `deferred` as the + * local variable name rather than the factory import name, without needing to rename on import. + * + * ```typescript + import {createDeferred} from '@kwsites/promise-deferred`; + ``` + */ +export declare const createDeferred: typeof deferred; +/** + * Default export allows use as: + * + * ```typescript + import deferred from '@kwsites/promise-deferred`; + ``` + */ +export default deferred; diff --git a/node_modules/@kwsites/promise-deferred/dist/index.js b/node_modules/@kwsites/promise-deferred/dist/index.js new file mode 100644 index 0000000..1ffefe6 --- /dev/null +++ b/node_modules/@kwsites/promise-deferred/dist/index.js @@ -0,0 +1,59 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createDeferred = exports.deferred = void 0; +/** + * Creates a new `DeferredPromise` + * + * ```typescript + import {deferred} from '@kwsites/promise-deferred`; + ``` + */ +function deferred() { + let done; + let fail; + let status = 'pending'; + const promise = new Promise((_done, _fail) => { + done = _done; + fail = _fail; + }); + return { + promise, + done(result) { + if (status === 'pending') { + status = 'resolved'; + done(result); + } + }, + fail(error) { + if (status === 'pending') { + status = 'rejected'; + fail(error); + } + }, + get fulfilled() { + return status !== 'pending'; + }, + get status() { + return status; + }, + }; +} +exports.deferred = deferred; +/** + * Alias of the exported `deferred` function, to help consumers wanting to use `deferred` as the + * local variable name rather than the factory import name, without needing to rename on import. + * + * ```typescript + import {createDeferred} from '@kwsites/promise-deferred`; + ``` + */ +exports.createDeferred = deferred; +/** + * Default export allows use as: + * + * ```typescript + import deferred from '@kwsites/promise-deferred`; + ``` + */ +exports.default = deferred; +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/@kwsites/promise-deferred/dist/index.js.map b/node_modules/@kwsites/promise-deferred/dist/index.js.map new file mode 100644 index 0000000..74583ed --- /dev/null +++ b/node_modules/@kwsites/promise-deferred/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA0BA;;;;;;GAMG;AACH,SAAgB,QAAQ;IACrB,IAAI,IAAyB,CAAC;IAC9B,IAAI,IAAwB,CAAC;IAC7B,IAAI,MAAM,GAA0B,SAAS,CAAC;IAE9C,MAAM,OAAO,GAAe,IAAI,OAAO,CAAI,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACzD,IAAI,GAAG,KAAK,CAAC;QACb,IAAI,GAAG,KAAK,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO;QACJ,OAAO;QACP,IAAI,CAAE,MAAM;YACT,IAAI,MAAM,KAAK,SAAS,EAAE;gBACvB,MAAM,GAAG,UAAU,CAAC;gBACpB,IAAI,CAAC,MAAM,CAAC,CAAC;aACf;QACJ,CAAC;QACD,IAAI,CAAE,KAAK;YACR,IAAI,MAAM,KAAK,SAAS,EAAE;gBACvB,MAAM,GAAG,UAAU,CAAC;gBACpB,IAAI,CAAC,KAAK,CAAC,CAAC;aACd;QACJ,CAAC;QACD,IAAI,SAAS;YACV,OAAO,MAAM,KAAK,SAAS,CAAC;QAC/B,CAAC;QACD,IAAI,MAAM;YACP,OAAO,MAAM,CAAC;QACjB,CAAC;KACH,CAAC;AACL,CAAC;AA/BD,4BA+BC;AAED;;;;;;;GAOG;AACU,QAAA,cAAc,GAAG,QAAQ,CAAC;AAEvC;;;;;;GAMG;AACH,kBAAe,QAAQ,CAAC"}
\ No newline at end of file diff --git a/node_modules/@kwsites/promise-deferred/package.json b/node_modules/@kwsites/promise-deferred/package.json new file mode 100644 index 0000000..72dbbf0 --- /dev/null +++ b/node_modules/@kwsites/promise-deferred/package.json @@ -0,0 +1,43 @@ +{ + "name": "@kwsites/promise-deferred", + "description": "Minimalist creation of promise wrappers, exposing the ability to resolve or reject the inner promise", + "version": "1.1.1", + "private": false, + "author": "Steve King <steve@mydev.co>", + "contributors": [ + { + "name": "Steve King", + "email": "steve@mydev.co" + } + ], + "main": "./dist/index", + "types": "./dist/index", + "license": "MIT", + "repository": "git://github.com/kwsites/promise-deferred.git", + "devDependencies": { + "@babel/core": "^7.10.3", + "@babel/preset-env": "^7.10.3", + "@babel/preset-typescript": "^7.10.1", + "@types/jest": "^26.0.0", + "@types/node": "^14.0.13", + "babel-jest": "^26.1.0", + "babel-preset-env": "^1.7.0", + "jest": "^26.1.0", + "ts-node": "^8.10.2", + "typescript": "^3.9.5" + }, + "files": [ + "LICENSE", + "dist/**/*.*" + ], + "scripts": { + "clean": "git clean -fxd -e .idea -e node_modules", + "clean:modules": "git clean -fxd node_modules", + "build": "tsc --build", + "build:clean": "yarn run clean && tsc", + "preversion": "yarn run build:clean && yarn test", + "postversion": "npm publish --access=public && git push && git push --tags", + "test": "jest --coverage", + "tsc": "tsc" + } +} |