@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.
@@ -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
+ ✓ Creating entry file 3.4 secs
9
+ ⠙ Building modules
10
+ ⠹ Building modules
11
+ ⠸ 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
+ ✓ 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
+ ```
@@ -0,0 +1,2 @@
1
+ declare const _default: (obj: any) => boolean;
2
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./is-promise.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./is-promise.cjs.development.js')
8
+ }
@@ -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
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../../tsconfig.build.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "esModuleInterop": true
6
+ },
7
+
8
+ "include": [
9
+ "src/**/*"
10
+ ]
11
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "jsx": "react",
5
+ "esModuleInterop": true
6
+ }
7
+ }