Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -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.

View file

@ -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;

View file

@ -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

View file

@ -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"}

View file

@ -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"
}
}