@alwatr/flatomise 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/dist/main.cjs +3 -0
- package/dist/main.cjs.map +7 -0
- package/dist/main.d.ts +24 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.mjs +3 -0
- package/dist/main.mjs.map +7 -0
- package/package.json +75 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 1.0.0 (2024-01-03)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **flatomise:** A utility for creating promises that can be externally resolved or rejected. ([1bc4478](https://github.com/Alwatr/nanolib/commit/1bc4478327f156b5e45650590aea013590443723)) by @AliMD
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 S. Ali Mihandoost
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Flatomise
|
|
2
|
+
|
|
3
|
+
A utility for creating promises that can be externally resolved or rejected.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @alwatr/flatomise
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import {newFlatomise} from '@alwatr/flatomise';
|
|
15
|
+
|
|
16
|
+
const flatomise = newFlatomise();
|
|
17
|
+
flatomise.promise.then(() => {
|
|
18
|
+
console.log('flatomise resolved');
|
|
19
|
+
});
|
|
20
|
+
flatomise.resolve();
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
For real usage, see [async-queue](https://github.com/Alwatr/nanolib/blob/next/packages/async-quque/src/main.ts).
|
package/dist/main.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* @alwatr/flatomise v1.0.0 */
|
|
2
|
+
"use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var n=(e,o)=>{for(var i in o)r(e,i,{get:o[i],enumerable:!0})},v=(e,o,i,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of m(o))!l.call(e,t)&&t!==i&&r(e,t,{get:()=>o[t],enumerable:!(s=a(o,t))||s.enumerable});return e};var c=e=>v(r({},"__esModule",{value:!0}),e);var d={};n(d,{newFlatomise:()=>F});module.exports=c(d);function F(){let e={};return e.promise=new Promise((o,i)=>{e.resolve=o,e.reject=i}),e}0&&(module.exports={newFlatomise});
|
|
3
|
+
//# sourceMappingURL=main.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/main.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Flat promise that can be resolved or rejected from outside.\n */\nexport interface Flatomise {\n promise: Promise<void>;\n resolve: () => void;\n reject: () => void;\n}\n\n/**\n * Create a new Flatomise is a promise that can be resolved or rejected from outside.\n *\n * @returns A new Flatomise.\n *\n * @example\n * ```typescript\n * const flatomise = newFlatomise();\n * flatomise.promise.then(() => {\n * console.log('flatomise resolved');\n * });\n * flatomise.resolve();\n * ```\n */\nexport function newFlatomise(): Flatomise {\n const flatomise: Partial<Flatomise> = {};\n flatomise.promise = new Promise<void>((resolve, reject) => {\n flatomise.resolve = resolve;\n flatomise.reject = reject;\n });\n return flatomise as Flatomise;\n}\n"],
|
|
5
|
+
"mappings": ";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAuBO,SAASE,GAA0B,CACxC,IAAME,EAAgC,CAAC,EACvC,OAAAA,EAAU,QAAU,IAAI,QAAc,CAACC,EAASC,IAAW,CACzDF,EAAU,QAAUC,EACpBD,EAAU,OAASE,CACrB,CAAC,EACMF,CACT",
|
|
6
|
+
"names": ["main_exports", "__export", "newFlatomise", "__toCommonJS", "flatomise", "resolve", "reject"]
|
|
7
|
+
}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flat promise that can be resolved or rejected from outside.
|
|
3
|
+
*/
|
|
4
|
+
export interface Flatomise {
|
|
5
|
+
promise: Promise<void>;
|
|
6
|
+
resolve: () => void;
|
|
7
|
+
reject: () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a new Flatomise is a promise that can be resolved or rejected from outside.
|
|
11
|
+
*
|
|
12
|
+
* @returns A new Flatomise.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const flatomise = newFlatomise();
|
|
17
|
+
* flatomise.promise.then(() => {
|
|
18
|
+
* console.log('flatomise resolved');
|
|
19
|
+
* });
|
|
20
|
+
* flatomise.resolve();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function newFlatomise(): Flatomise;
|
|
24
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAOxC"}
|
package/dist/main.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/main.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Flat promise that can be resolved or rejected from outside.\n */\nexport interface Flatomise {\n promise: Promise<void>;\n resolve: () => void;\n reject: () => void;\n}\n\n/**\n * Create a new Flatomise is a promise that can be resolved or rejected from outside.\n *\n * @returns A new Flatomise.\n *\n * @example\n * ```typescript\n * const flatomise = newFlatomise();\n * flatomise.promise.then(() => {\n * console.log('flatomise resolved');\n * });\n * flatomise.resolve();\n * ```\n */\nexport function newFlatomise(): Flatomise {\n const flatomise: Partial<Flatomise> = {};\n flatomise.promise = new Promise<void>((resolve, reject) => {\n flatomise.resolve = resolve;\n flatomise.reject = reject;\n });\n return flatomise as Flatomise;\n}\n"],
|
|
5
|
+
"mappings": ";AAuBO,SAASA,GAA0B,CACxC,IAAMC,EAAgC,CAAC,EACvC,OAAAA,EAAU,QAAU,IAAI,QAAc,CAACC,EAASC,IAAW,CACzDF,EAAU,QAAUC,EACpBD,EAAU,OAASE,CACrB,CAAC,EACMF,CACT",
|
|
6
|
+
"names": ["newFlatomise", "flatomise", "resolve", "reject"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alwatr/flatomise",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A utility for creating promises that can be externally resolved or rejected.",
|
|
5
|
+
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"flatomise",
|
|
8
|
+
"flat-promise",
|
|
9
|
+
"promise",
|
|
10
|
+
"cross-platform",
|
|
11
|
+
"ECMAScript",
|
|
12
|
+
"typescript",
|
|
13
|
+
"javascript",
|
|
14
|
+
"node",
|
|
15
|
+
"nodejs",
|
|
16
|
+
"esm",
|
|
17
|
+
"module",
|
|
18
|
+
"utility",
|
|
19
|
+
"util",
|
|
20
|
+
"utils",
|
|
21
|
+
"nanolib",
|
|
22
|
+
"alwatr"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/main.cjs",
|
|
26
|
+
"module": "./dist/main.mjs",
|
|
27
|
+
"types": "./dist/main.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": "./dist/main.mjs",
|
|
31
|
+
"require": "./dist/main.cjs",
|
|
32
|
+
"types": "./dist/main.d.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"files": [
|
|
37
|
+
"**/*.{js,mjs,cjs,map,d.ts,html,md}",
|
|
38
|
+
"!demo/**/*"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/Alwatr/nanolib",
|
|
46
|
+
"directory": "packages/flatomise"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/flatomise#readme",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/Alwatr/nanolib/issues"
|
|
51
|
+
},
|
|
52
|
+
"prettier": "@alwatr/prettier-config",
|
|
53
|
+
"scripts": {
|
|
54
|
+
"b": "yarn run build",
|
|
55
|
+
"w": "yarn run watch",
|
|
56
|
+
"c": "yarn run clean",
|
|
57
|
+
"cb": "yarn run clean && yarn run build",
|
|
58
|
+
"d": "yarn run build:es && ALWATR_DEBUG=1 yarn node",
|
|
59
|
+
"build": "yarn run build:ts & yarn run build:es",
|
|
60
|
+
"build:es": "nano-build --preset=module",
|
|
61
|
+
"build:ts": "tsc --build",
|
|
62
|
+
"watch": "yarn run watch:ts & yarn run watch:es",
|
|
63
|
+
"watch:es": "yarn run build:es --watch",
|
|
64
|
+
"watch:ts": "yarn run build:ts --watch --preserveWatchOutput",
|
|
65
|
+
"clean": "rm -rfv dist *.tsbuildinfo"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@alwatr/nano-build": "^1.2.3",
|
|
69
|
+
"@alwatr/prettier-config": "^1.0.4",
|
|
70
|
+
"@alwatr/tsconfig-base": "^1.1.0",
|
|
71
|
+
"@types/node": "^20.10.6",
|
|
72
|
+
"typescript": "^5.3.3"
|
|
73
|
+
},
|
|
74
|
+
"gitHead": "154de55566d7f39bba46d269585bae838499f0bf"
|
|
75
|
+
}
|