-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
111 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ package-lock.json | |
.DS_Store | ||
.idea | ||
.vscode | ||
|
||
# vscode localhistory | ||
.history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"git": { | ||
"requireCleanWorkingDir": false | ||
}, | ||
"hooks": { | ||
"after:init": [ | ||
"npm run test", | ||
"t2k" | ||
], | ||
"after:bump": [ | ||
"npm run build" | ||
] | ||
}, | ||
"github": { | ||
"release": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,42 @@ | ||
# next-is-promise | ||
> Test whether an object looks like a promises-a+ promise. | ||
[![version][version-image]][version-url] | ||
[![license][license-image]][license-url] | ||
[![size][size-image]][size-url] | ||
[![download][download-image]][download-url] | ||
|
||
## installation | ||
```bash | ||
npm install -S @feizheng/next-is-promise | ||
npm install -S @jswork/next-is-promise | ||
``` | ||
|
||
## usage | ||
```js | ||
import '@feizheng/next-is-promise'; | ||
import '@jswork/next-is-promise'; | ||
|
||
const fn1 = () => { | ||
return new Promise(() => { | ||
setTimeout(() => { | ||
resolve('done'); | ||
}, 1000); | ||
}); | ||
}; | ||
|
||
//DOCS here! | ||
nx.isPromise(fn1()); // true | ||
``` | ||
|
||
## resources | ||
- https://github.com/then/is-promise | ||
## license | ||
Code released under [the MIT license](https://github.com/afeiship/next-is-promise/blob/master/LICENSE.txt). | ||
|
||
[version-image]: https://img.shields.io/npm/v/@jswork/next-is-promise | ||
[version-url]: https://npmjs.org/package/@jswork/next-is-promise | ||
|
||
[license-image]: https://img.shields.io/npm/l/@jswork/next-is-promise | ||
[license-url]: https://github.com/afeiship/next-is-promise/blob/master/LICENSE.txt | ||
|
||
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-is-promise | ||
[size-url]: https://github.com/afeiship/next-is-promise/blob/master/dist/next-is-promise.min.js | ||
|
||
[download-image]: https://img.shields.io/npm/dm/@jswork/next-is-promise | ||
[download-url]: https://www.npmjs.com/package/@jswork/next-is-promise |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { resolve } = require('path'); | ||
|
||
(function () { | ||
require('../src'); | ||
const fs = require('fs'); | ||
|
||
describe('api.basic test', () => { | ||
test('nx.isPromise', function () { | ||
const fn1 = () => { | ||
return new Promise(() => { | ||
setTimeout(() => { | ||
resolve('done'); | ||
}, 1000); | ||
}); | ||
}; | ||
expect(nx.isPromise(fn1())).toBe(true); | ||
}); | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
/*! | ||
* name: @feizheng/next-is-promise | ||
* name: @jswork/next-is-promise | ||
* description: Test whether an object looks like a promises-a+ promise. | ||
* homepage: https://github.com/afeiship/next-is-promise | ||
* version: 1.0.1 | ||
* date: 2020-05-06T00:33:45.607Z | ||
* version: 1.0.0 | ||
* date: 2020-11-21 10:52:29 | ||
* license: MIT | ||
*/ | ||
|
||
(function () { | ||
var global = global || this || window || Function('return this')(); | ||
var nx = global.nx || require('@feizheng/next-js-core2'); | ||
var nx = global.nx || require('@jswork/next'); | ||
var OBJ = 'object'; | ||
var FUNC = 'function'; | ||
|
||
nx.isPromise = function (inObj) { | ||
return ( | ||
!!inObj && | ||
(typeof inObj === OBJ || typeof inObj === FUNC) && | ||
typeof inObj.then === FUNC | ||
); | ||
return !!inObj && (typeof inObj === OBJ || typeof inObj === FUNC) && typeof inObj.then === FUNC; | ||
}; | ||
|
||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = nx.isPromise; | ||
} | ||
})(); | ||
|
||
//# sourceMappingURL=next-is-promise.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/*! | ||
* name: @jswork/next-is-promise | ||
* description: Test whether an object looks like a promises-a+ promise. | ||
* homepage: https://github.com/afeiship/next-is-promise | ||
* version: 1.0.0 | ||
* date: 2020-11-21 10:52:29 | ||
* license: MIT | ||
*/ | ||
!function(){var e=(this||window||Function("return this")()).nx||require("@jswork/next"),o="function";e.isPromise=function(e){return!!e&&("object"==typeof e||typeof e==o)&&typeof e.then==o},"undefined"!=typeof module&&module.exports&&(module.exports=e.isPromise)}(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters