1 | let is = {
|
2 | object: function (instance) {
|
3 | return (typeof (instance) === 'object' && !Array.isArray(instance) && instance !== undefined && instance !== null)
|
4 | },
|
5 |
|
6 | array: function (instance) {
|
7 | return (typeof (instance) === 'object' && Array.isArray(instance))
|
8 | },
|
9 |
|
10 | string: function (instance) {
|
11 | return (typeof (instance) === 'string')
|
12 | },
|
13 |
|
14 | boolean: function (instance) {
|
15 | return (instance === true || instance === false);
|
16 | },
|
17 |
|
18 | number: function (instance) {
|
19 | return (typeof (instance) === 'number');
|
20 | },
|
21 |
|
22 | integer: function (instance) {
|
23 | return (is.number(instance) && (instance % 1 === 0));
|
24 | },
|
25 |
|
26 | undefinedOrNull: function (instance) {
|
27 | return (instance === undefined || instance === null)
|
28 | }
|
29 | }
|
30 |
|
31 | let promiseCreate = function (cb) {
|
32 |
|
33 | return function () {
|
34 | var args = Array.prototype.slice.call(arguments);
|
35 | var self = this;
|
36 | return new Promise(function (resolve, reject) {
|
37 | cb.apply(self, args.concat([resolve, reject]))
|
38 | })
|
39 | }
|
40 | }
|
41 |
|
42 | module.exports = {
|
43 | is,
|
44 | promiseCreate:promiseCreate
|
45 | } |
\ | No newline at end of file |