@x-oasis/is-promise 0.1.38
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/.turbo/turbo-build.log +15 -0
- package/CHANGELOG.md +25 -0
- package/README.md +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/is-promise.cjs.development.js +18 -0
- package/dist/is-promise.cjs.development.js.map +1 -0
- package/dist/is-promise.cjs.production.min.js +2 -0
- package/dist/is-promise.cjs.production.min.js.map +1 -0
- package/dist/is-promise.esm.js +12 -0
- package/dist/is-promise.esm.js.map +1 -0
- package/package.json +25 -0
- package/src/index.ts +12 -0
- package/test/test.spec.ts +12 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
> @x-oasis/is-promise@0.1.38 build /home/runner/work/x-oasis/x-oasis/packages/assertion/is-promise
|
|
3
|
+
> tsdx build --tsconfig tsconfig.build.json
|
|
4
|
+
|
|
5
|
+
@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
|
|
6
|
+
@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
|
|
7
|
+
⠙ Creating entry file
|
|
8
|
+
[2K[1A[2K[G✓ Creating entry file 3.4 secs
|
|
9
|
+
⠙ Building modules
|
|
10
|
+
[2K[1A[2K[G⠹ Building modules
|
|
11
|
+
[2K[1A[2K[G⠸ Building modules
|
|
12
|
+
[tsdx]: Your rootDir is currently set to "./". Please change your rootDir to "./src".
|
|
13
|
+
TSDX has deprecated setting tsconfig.compilerOptions.rootDir to "./" as it caused buggy output for declarationMaps and more.
|
|
14
|
+
You may also need to change your include to remove "test", which also caused declarations to be unnecessarily created for test files.
|
|
15
|
+
[2K[1A[2K[G✓ Building modules 3.5 secs
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @x-oasis/is-promise
|
|
2
|
+
|
|
3
|
+
## 0.1.38
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f1aae14: bump version
|
|
8
|
+
- Updated dependencies [f1aae14]
|
|
9
|
+
- @x-oasis/to-string@0.1.38
|
|
10
|
+
|
|
11
|
+
## 0.1.37
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 8cb524c: trigger next
|
|
16
|
+
- Updated dependencies [8cb524c]
|
|
17
|
+
- @x-oasis/to-string@0.1.37
|
|
18
|
+
|
|
19
|
+
## 0.1.36
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 7c2a0ba: git add .
|
|
24
|
+
- Updated dependencies [7c2a0ba]
|
|
25
|
+
- @x-oasis/to-string@0.1.36
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @x-oasis/is-promise
|
|
2
|
+
|
|
3
|
+
_test value is `NaN`, `undefined`, `null`, `''`, `[]` and `{}` _
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
$ npm i @x-oasis/is-promise
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## How to use
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import isPromise from '@x-oasis/is-promise'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## How to run test
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
$ pnpm test
|
|
21
|
+
```
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var toString = _interopDefault(require('@x-oasis/to-string'));
|
|
8
|
+
|
|
9
|
+
var index = (function (obj) {
|
|
10
|
+
if (toString(obj) === '[object Promise]') return true;
|
|
11
|
+
if (toString(obj) === '[object Object]') {
|
|
12
|
+
return typeof obj.then === 'function';
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
exports.default = index;
|
|
18
|
+
//# sourceMappingURL=is-promise.cjs.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-promise.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import toString from '@x-oasis/to-string';\n\n// https://github.com/lodash/lodash/blob/main/src/isEmpty.ts\n// https://stackoverflow.com/a/53751866\n\nexport default (obj: any) => {\n if (toString(obj) === '[object Promise]') return true;\n if (toString(obj) === '[object Object]') {\n return typeof obj.then === 'function';\n }\n return false;\n};\n"],"names":["obj","toString","then"],"mappings":";;;;;;;;AAKA,aAAe,UAACA,GAAQ;EACtB,IAAIC,QAAQ,CAACD,GAAG,CAAC,KAAK,kBAAkB,EAAE,OAAO,IAAI;EACrD,IAAIC,QAAQ,CAACD,GAAG,CAAC,KAAK,iBAAiB,EAAE;IACvC,OAAO,OAAOA,GAAG,CAACE,IAAI,KAAK,UAAU;;EAEvC,OAAO,KAAK;AACd,CAAC;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("@x-oasis/to-string"))&&"object"==typeof e&&"default"in e?e.default:e;exports.default=function(e){return"[object Promise]"===t(e)||"[object Object]"===t(e)&&"function"==typeof e.then};
|
|
2
|
+
//# sourceMappingURL=is-promise.cjs.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-promise.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["import toString from '@x-oasis/to-string';\n\n// https://github.com/lodash/lodash/blob/main/src/isEmpty.ts\n// https://stackoverflow.com/a/53751866\n\nexport default (obj: any) => {\n if (toString(obj) === '[object Promise]') return true;\n if (toString(obj) === '[object Object]') {\n return typeof obj.then === 'function';\n }\n return false;\n};\n"],"names":["obj","toString","then"],"mappings":"sLAKgBA,GACd,MAAsB,qBAAlBC,EAASD,IACS,oBAAlBC,EAASD,IACgB,mBAAbA,EAAIE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import toString from '@x-oasis/to-string';
|
|
2
|
+
|
|
3
|
+
var index = (function (obj) {
|
|
4
|
+
if (toString(obj) === '[object Promise]') return true;
|
|
5
|
+
if (toString(obj) === '[object Object]') {
|
|
6
|
+
return typeof obj.then === 'function';
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export default index;
|
|
12
|
+
//# sourceMappingURL=is-promise.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-promise.esm.js","sources":["../src/index.ts"],"sourcesContent":["import toString from '@x-oasis/to-string';\n\n// https://github.com/lodash/lodash/blob/main/src/isEmpty.ts\n// https://stackoverflow.com/a/53751866\n\nexport default (obj: any) => {\n if (toString(obj) === '[object Promise]') return true;\n if (toString(obj) === '[object Object]') {\n return typeof obj.then === 'function';\n }\n return false;\n};\n"],"names":["obj","toString","then"],"mappings":";;AAKA,aAAe,UAACA,GAAQ;EACtB,IAAIC,QAAQ,CAACD,GAAG,CAAC,KAAK,kBAAkB,EAAE,OAAO,IAAI;EACrD,IAAIC,QAAQ,CAACD,GAAG,CAAC,KAAK,iBAAiB,EAAE;IACvC,OAAO,OAAOA,GAAG,CAACE,IAAI,KAAK,UAAU;;EAEvC,OAAO,KAAK;AACd,CAAC;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x-oasis/is-promise",
|
|
3
|
+
"version": "0.1.38",
|
|
4
|
+
"description": "is-promise function",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/is-promise.esm.js",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"tsdx": "^0.14.1"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@x-oasis/to-string": "^0.1.38"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsdx build --tsconfig tsconfig.build.json",
|
|
21
|
+
"clean": "rimraf ./dist",
|
|
22
|
+
"test": "vitest",
|
|
23
|
+
"compile": "tsc -p tsconfig.build.json"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import toString from '@x-oasis/to-string';
|
|
2
|
+
|
|
3
|
+
// https://github.com/lodash/lodash/blob/main/src/isEmpty.ts
|
|
4
|
+
// https://stackoverflow.com/a/53751866
|
|
5
|
+
|
|
6
|
+
export default (obj: any) => {
|
|
7
|
+
if (toString(obj) === '[object Promise]') return true;
|
|
8
|
+
if (toString(obj) === '[object Object]') {
|
|
9
|
+
return typeof obj.then === 'function';
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
|
+
import isEmpty from '../src';
|
|
3
|
+
|
|
4
|
+
test('vitest', async () => {
|
|
5
|
+
expect(isEmpty({})).toBe(true);
|
|
6
|
+
expect(isEmpty([])).toBe(true);
|
|
7
|
+
expect(isEmpty(new Map())).toBe(true);
|
|
8
|
+
expect(isEmpty(new Set())).toBe(true);
|
|
9
|
+
expect(isEmpty(false)).toBe(false);
|
|
10
|
+
expect(isEmpty(0)).toBe(false);
|
|
11
|
+
expect(isEmpty(1)).toBe(false);
|
|
12
|
+
});
|