@alterior/common 3.7.5 → 3.9.1
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/dist/base64.test.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/is-constructor.d.ts +13 -0
- package/dist/is-constructor.d.ts.map +1 -0
- package/dist/is-constructor.js +30 -0
- package/dist/is-constructor.js.map +1 -0
- package/dist/is-constructor.test.d.ts +2 -0
- package/dist/is-constructor.test.d.ts.map +1 -0
- package/dist/is-constructor.test.js.map +1 -0
- package/dist/padding.d.ts +23 -0
- package/dist/padding.d.ts.map +1 -0
- package/dist/padding.js +44 -0
- package/dist/padding.js.map +1 -0
- package/dist.esm/base64.test.js.map +1 -1
- package/dist.esm/index.d.ts +2 -0
- package/dist.esm/index.d.ts.map +1 -1
- package/dist.esm/index.js +2 -0
- package/dist.esm/index.js.map +1 -1
- package/dist.esm/is-constructor.d.ts +13 -0
- package/dist.esm/is-constructor.d.ts.map +1 -0
- package/dist.esm/is-constructor.js +25 -0
- package/dist.esm/is-constructor.js.map +1 -0
- package/dist.esm/is-constructor.test.d.ts +2 -0
- package/dist.esm/is-constructor.test.d.ts.map +1 -0
- package/dist.esm/is-constructor.test.js.map +1 -0
- package/dist.esm/padding.d.ts +23 -0
- package/dist.esm/padding.d.ts.map +1 -0
- package/dist.esm/padding.js +38 -0
- package/dist.esm/padding.js.map +1 -0
- package/package.json +2 -2
- package/src/base64.test.ts +3 -0
- package/src/index.ts +3 -1
- package/src/is-constructor.test.ts +24 -0
- package/src/is-constructor.ts +25 -0
- package/src/padding.ts +44 -0
package/dist/base64.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.test.js","sourceRoot":"","sources":["../src/base64.test.ts"],"names":[],"mappings":";;AAAA,qCAAkC;AAClC,+BAA8B;AAC9B,mCAAkC;AA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;YACpC,IAAA,aAAM,EAAC,eAAM,CAAC,MAAM,CAAC,eAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,4 +19,6 @@ tslib_1.__exportStar(require("./time"), exports);
|
|
|
19
19
|
tslib_1.__exportStar(require("./get-param-names"), exports);
|
|
20
20
|
tslib_1.__exportStar(require("./lazy-subject"), exports);
|
|
21
21
|
tslib_1.__exportStar(require("./check-native-async"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./is-constructor"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./padding"), exports);
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,kDAAwB;AACxB,qDAA2B;AAC3B,mDAAyB;AACzB,oDAA0B;AAC1B,wDAA8B;AAC9B,mDAAyB;AACzB,oDAA0B;AAC1B,mDAAyB;AACzB,kDAAwB;AACxB,uDAA6B;AAC7B,yDAA+B;AAC/B,kDAAwB;AACxB,yDAA+B;AAC/B,iDAAuB;AACvB,4DAAkC;AAClC,yDAA+B;AAC/B,+DAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,kDAAwB;AACxB,qDAA2B;AAC3B,mDAAyB;AACzB,oDAA0B;AAC1B,wDAA8B;AAC9B,mDAAyB;AACzB,oDAA0B;AAC1B,mDAAyB;AACzB,kDAAwB;AACxB,uDAA6B;AAC7B,yDAA+B;AAC/B,kDAAwB;AACxB,yDAA+B;AAC/B,iDAAuB;AACvB,4DAAkC;AAClC,yDAA+B;AAC/B,+DAAqC;AACrC,2DAAiC;AACjC,oDAA0B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the given function is constructable. Note that this is not the same as a *class*. In Ecmascript, normal
|
|
3
|
+
* functions are also constructable. Use isClass() if you want to check if a function is a class.
|
|
4
|
+
*
|
|
5
|
+
* @see https://stackoverflow.com/a/46759625
|
|
6
|
+
*/
|
|
7
|
+
export declare function isConstructor(f: Function): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Check if the given function is a class. Note that this only works for Ecmascript standard classes, the older
|
|
10
|
+
* prototype style constructor functions will return false here.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isClass(f: Function): boolean;
|
|
13
|
+
//# sourceMappingURL=is-constructor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-constructor.d.ts","sourceRoot":"","sources":["../src/is-constructor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,QAAQ,WAUxC;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,WAElC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isClass = exports.isConstructor = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Check if the given function is constructable. Note that this is not the same as a *class*. In Ecmascript, normal
|
|
6
|
+
* functions are also constructable. Use isClass() if you want to check if a function is a class.
|
|
7
|
+
*
|
|
8
|
+
* @see https://stackoverflow.com/a/46759625
|
|
9
|
+
*/
|
|
10
|
+
function isConstructor(f) {
|
|
11
|
+
if (f === Symbol)
|
|
12
|
+
return false;
|
|
13
|
+
try {
|
|
14
|
+
Reflect.construct(String, [], f);
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
exports.isConstructor = isConstructor;
|
|
22
|
+
/**
|
|
23
|
+
* Check if the given function is a class. Note that this only works for Ecmascript standard classes, the older
|
|
24
|
+
* prototype style constructor functions will return false here.
|
|
25
|
+
*/
|
|
26
|
+
function isClass(f) {
|
|
27
|
+
return f.toString().startsWith('class ');
|
|
28
|
+
}
|
|
29
|
+
exports.isClass = isClass;
|
|
30
|
+
//# sourceMappingURL=is-constructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-constructor.js","sourceRoot":"","sources":["../src/is-constructor.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,CAAW;IACrC,IAAI,CAAC,KAAK,MAAM;QACZ,OAAO,KAAK,CAAC;IAEjB,IAAI;QACA,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;KACpC;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAVD,sCAUC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,CAAW;IAC/B,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAFD,0BAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-constructor.test.d.ts","sourceRoot":"","sources":["../src/is-constructor.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-constructor.test.js","sourceRoot":"","sources":["../src/is-constructor.test.ts"],"names":[],"mappings":";;AAAA,mCAA+B;AAC/B,qDAA0D;AAC1D,+BAA8B;AAE9B,IAAA,cAAK,EAAC,QAAQ,CAAC,EAAE;IACb,QAAQ,CAAC,iBAAiB,EAAE,EAAE,CAAC,EAAE;QAC7B,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;YACzB,IAAA,aAAM,EAAC,IAAA,8BAA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C,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the end.
|
|
3
|
+
*
|
|
4
|
+
* @param str
|
|
5
|
+
* @param length
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function rightPad(str: string, length: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the beginning.
|
|
11
|
+
* @param str
|
|
12
|
+
* @param length
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function leftPad(str: string, length: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
|
|
18
|
+
* @param number
|
|
19
|
+
* @param digits
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function zeroPad(number: any, digits?: number): string;
|
|
23
|
+
//# sourceMappingURL=padding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padding.d.ts","sourceRoot":"","sources":["../src/padding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAOnD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAOlD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,SAAI,UAM9C"}
|
package/dist/padding.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zeroPad = exports.leftPad = exports.rightPad = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the end.
|
|
6
|
+
*
|
|
7
|
+
* @param str
|
|
8
|
+
* @param length
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function rightPad(str, length) {
|
|
12
|
+
str = String(str);
|
|
13
|
+
while (str.length < length)
|
|
14
|
+
str += ' ';
|
|
15
|
+
return str;
|
|
16
|
+
}
|
|
17
|
+
exports.rightPad = rightPad;
|
|
18
|
+
/**
|
|
19
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the beginning.
|
|
20
|
+
* @param str
|
|
21
|
+
* @param length
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
function leftPad(str, length) {
|
|
25
|
+
str = String(str);
|
|
26
|
+
while (str.length < length)
|
|
27
|
+
str = ' ' + str;
|
|
28
|
+
return str;
|
|
29
|
+
}
|
|
30
|
+
exports.leftPad = leftPad;
|
|
31
|
+
/**
|
|
32
|
+
* Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
|
|
33
|
+
* @param number
|
|
34
|
+
* @param digits
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
function zeroPad(number, digits = 2) {
|
|
38
|
+
let str = `${number}`;
|
|
39
|
+
while (str.length < digits)
|
|
40
|
+
str = '0' + str;
|
|
41
|
+
return str;
|
|
42
|
+
}
|
|
43
|
+
exports.zeroPad = zeroPad;
|
|
44
|
+
//# sourceMappingURL=padding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padding.js","sourceRoot":"","sources":["../src/padding.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,MAAc;IAChD,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAElB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM;QACtB,GAAG,IAAI,GAAG,CAAC;IAEf,OAAO,GAAG,CAAC;AACf,CAAC;AAPD,4BAOC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CA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CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC"}
|
package/dist.esm/index.js
CHANGED
package/dist.esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the given function is constructable. Note that this is not the same as a *class*. In Ecmascript, normal
|
|
3
|
+
* functions are also constructable. Use isClass() if you want to check if a function is a class.
|
|
4
|
+
*
|
|
5
|
+
* @see https://stackoverflow.com/a/46759625
|
|
6
|
+
*/
|
|
7
|
+
export declare function isConstructor(f: Function): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Check if the given function is a class. Note that this only works for Ecmascript standard classes, the older
|
|
10
|
+
* prototype style constructor functions will return false here.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isClass(f: Function): boolean;
|
|
13
|
+
//# sourceMappingURL=is-constructor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-constructor.d.ts","sourceRoot":"","sources":["../src/is-constructor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,QAAQ,WAUxC;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,WAElC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the given function is constructable. Note that this is not the same as a *class*. In Ecmascript, normal
|
|
3
|
+
* functions are also constructable. Use isClass() if you want to check if a function is a class.
|
|
4
|
+
*
|
|
5
|
+
* @see https://stackoverflow.com/a/46759625
|
|
6
|
+
*/
|
|
7
|
+
export function isConstructor(f) {
|
|
8
|
+
if (f === Symbol)
|
|
9
|
+
return false;
|
|
10
|
+
try {
|
|
11
|
+
Reflect.construct(String, [], f);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Check if the given function is a class. Note that this only works for Ecmascript standard classes, the older
|
|
20
|
+
* prototype style constructor functions will return false here.
|
|
21
|
+
*/
|
|
22
|
+
export function isClass(f) {
|
|
23
|
+
return f.toString().startsWith('class ');
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=is-constructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-constructor.js","sourceRoot":"","sources":["../src/is-constructor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,CAAW;IACrC,IAAI,CAAC,KAAK,MAAM;QACZ,OAAO,KAAK,CAAC;IAEjB,IAAI;QACA,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;KACpC;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,CAAW;IAC/B,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-constructor.test.d.ts","sourceRoot":"","sources":["../src/is-constructor.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-constructor.test.js","sourceRoot":"","sources":["../src/is-constructor.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,KAAK,CAAC,QAAQ,CAAC,EAAE;IACb,QAAQ,CAAC,iBAAiB,EAAE,EAAE,CAAC,EAAE;QAC7B,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;YACzB,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;YAClD,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YAC5C,MAAM,CAAC,aAAa,CAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YAC5C,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YAC1C,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;aAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAClD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE;QACvB,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;YACzB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;aAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;YACxC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YAC7C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YACtC,MAAM,CAAC,OAAO,CAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YACtC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QACxC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the end.
|
|
3
|
+
*
|
|
4
|
+
* @param str
|
|
5
|
+
* @param length
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function rightPad(str: string, length: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the beginning.
|
|
11
|
+
* @param str
|
|
12
|
+
* @param length
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function leftPad(str: string, length: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
|
|
18
|
+
* @param number
|
|
19
|
+
* @param digits
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function zeroPad(number: any, digits?: number): string;
|
|
23
|
+
//# sourceMappingURL=padding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padding.d.ts","sourceRoot":"","sources":["../src/padding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAOnD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAOlD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,SAAI,UAM9C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the end.
|
|
3
|
+
*
|
|
4
|
+
* @param str
|
|
5
|
+
* @param length
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export function rightPad(str, length) {
|
|
9
|
+
str = String(str);
|
|
10
|
+
while (str.length < length)
|
|
11
|
+
str += ' ';
|
|
12
|
+
return str;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the beginning.
|
|
16
|
+
* @param str
|
|
17
|
+
* @param length
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export function leftPad(str, length) {
|
|
21
|
+
str = String(str);
|
|
22
|
+
while (str.length < length)
|
|
23
|
+
str = ' ' + str;
|
|
24
|
+
return str;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
|
|
28
|
+
* @param number
|
|
29
|
+
* @param digits
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export function zeroPad(number, digits = 2) {
|
|
33
|
+
let str = `${number}`;
|
|
34
|
+
while (str.length < digits)
|
|
35
|
+
str = '0' + str;
|
|
36
|
+
return str;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=padding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padding.js","sourceRoot":"","sources":["../src/padding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,MAAc;IAChD,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAElB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM;QACtB,GAAG,IAAI,GAAG,CAAC;IAEf,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,MAAc;IAC/C,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAElB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM;QACtB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAEpB,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,MAAW,EAAE,MAAM,GAAG,CAAC;IAC3C,IAAI,GAAG,GAAG,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM;QACtB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAEpB,OAAO,GAAG,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alterior/common",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"description": "Useful utilities for Typescript apps",
|
|
5
5
|
"author": "The Alterior Project (https://github.com/alterior-mvc)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"reflect-metadata": "^0.1.13"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "9d3a7885fb01f3a6f875d12bcdf1a8a7fca4ffc1"
|
|
47
47
|
}
|
package/src/base64.test.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -15,4 +15,6 @@ export * from './presentation';
|
|
|
15
15
|
export * from './time';
|
|
16
16
|
export * from './get-param-names';
|
|
17
17
|
export * from './lazy-subject';
|
|
18
|
-
export * from './check-native-async';
|
|
18
|
+
export * from './check-native-async';
|
|
19
|
+
export * from './is-constructor';
|
|
20
|
+
export * from './padding';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { suite } from "razmin";
|
|
2
|
+
import { isClass, isConstructor } from "./is-constructor";
|
|
3
|
+
import { expect } from "chai";
|
|
4
|
+
|
|
5
|
+
suite(describe => {
|
|
6
|
+
describe('isConstructor()', it => {
|
|
7
|
+
it('works as expected', () => {
|
|
8
|
+
expect(isConstructor(function () { })).to.be.true;
|
|
9
|
+
expect(isConstructor(() => {})).to.be.false;
|
|
10
|
+
expect(isConstructor(<any>123)).to.be.false;
|
|
11
|
+
expect(isConstructor(Symbol)).to.be.false;
|
|
12
|
+
expect(isConstructor(class A { })).to.be.true;
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('isClass()', it => {
|
|
16
|
+
it('works as expected', () => {
|
|
17
|
+
expect(isClass(class A { })).to.be.true;
|
|
18
|
+
expect(isClass(function () { })).to.be.false;
|
|
19
|
+
expect(isClass(() => {})).to.be.false;
|
|
20
|
+
expect(isClass(<any>123)).to.be.false;
|
|
21
|
+
expect(isClass(Symbol)).to.be.false;
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the given function is constructable. Note that this is not the same as a *class*. In Ecmascript, normal
|
|
3
|
+
* functions are also constructable. Use isClass() if you want to check if a function is a class.
|
|
4
|
+
*
|
|
5
|
+
* @see https://stackoverflow.com/a/46759625
|
|
6
|
+
*/
|
|
7
|
+
export function isConstructor(f: Function) {
|
|
8
|
+
if (f === Symbol)
|
|
9
|
+
return false;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
Reflect.construct(String, [], f);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check if the given function is a class. Note that this only works for Ecmascript standard classes, the older
|
|
21
|
+
* prototype style constructor functions will return false here.
|
|
22
|
+
*/
|
|
23
|
+
export function isClass(f: Function) {
|
|
24
|
+
return f.toString().startsWith('class ');
|
|
25
|
+
}
|
package/src/padding.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the end.
|
|
3
|
+
*
|
|
4
|
+
* @param str
|
|
5
|
+
* @param length
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export function rightPad(str: string, length: number) {
|
|
9
|
+
str = String(str);
|
|
10
|
+
|
|
11
|
+
while (str.length < length)
|
|
12
|
+
str += ' ';
|
|
13
|
+
|
|
14
|
+
return str;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Pad the given string until its at least `length` characters long by adding spaces to the beginning.
|
|
19
|
+
* @param str
|
|
20
|
+
* @param length
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export function leftPad(str: string, length: number) {
|
|
24
|
+
str = String(str);
|
|
25
|
+
|
|
26
|
+
while (str.length < length)
|
|
27
|
+
str = ' ' + str;
|
|
28
|
+
|
|
29
|
+
return str;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
|
|
34
|
+
* @param number
|
|
35
|
+
* @param digits
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
export function zeroPad(number: any, digits = 2) {
|
|
39
|
+
let str = `${number}`;
|
|
40
|
+
while (str.length < digits)
|
|
41
|
+
str = '0' + str;
|
|
42
|
+
|
|
43
|
+
return str;
|
|
44
|
+
}
|