@onivoro/isomorphic-common 0.3.3 → 0.3.4
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/esm/index.js +45 -29
- package/dist/esm/lib/constants/millis-per-day.constant.js +5 -2
- package/dist/esm/lib/constants/millis-per-hour.constant.js +5 -2
- package/dist/esm/lib/constants/millis-per-minute.constant.js +4 -1
- package/dist/esm/lib/functions/add-offset.function.js +9 -5
- package/dist/esm/lib/functions/camel-case.function.js +9 -5
- package/dist/esm/lib/functions/convert-object-to-literal.function.js +5 -1
- package/dist/esm/lib/functions/from-boolean-string.function.js +5 -1
- package/dist/esm/lib/functions/from-calendar-date.function.js +7 -3
- package/dist/esm/lib/functions/from-csv-string.function.js +5 -1
- package/dist/esm/lib/functions/get-tag.function.js +5 -1
- package/dist/esm/lib/functions/is-symbol.function.js +7 -3
- package/dist/esm/lib/functions/kebab-case.function.js +7 -3
- package/dist/esm/lib/functions/parse-bool.function.js +5 -1
- package/dist/esm/lib/functions/properties-to-array.function.js +5 -1
- package/dist/esm/lib/functions/sanitize-filename.function.js +5 -1
- package/dist/esm/lib/functions/snake-case.function.js +7 -3
- package/dist/esm/lib/functions/subtract-offset.function.js +9 -5
- package/dist/esm/lib/functions/to-boolean-string.function.js +5 -1
- package/dist/esm/lib/functions/to-calendar-date.function.js +7 -3
- package/dist/esm/lib/functions/to-csv-string.function.js +5 -1
- package/dist/esm/lib/functions/to-decimal-base.function.js +5 -1
- package/dist/esm/lib/functions/to-dollars-and-cents.function.js +8 -4
- package/dist/esm/lib/functions/to-string.function.js +7 -3
- package/dist/esm/lib/functions/to-unique-array.function.js +5 -1
- package/dist/esm/lib/functions/to-words.function.js +5 -1
- package/dist/esm/lib/functions/try-parse-date.function.js +5 -1
- package/dist/esm/lib/functions/unicode-words.const.js +5 -1
- package/dist/esm/lib/functions/upper-first.function.js +5 -1
- package/dist/esm/lib/functions/words.function.js +7 -3
- package/dist/esm/lib/interfaces/axios-wrapped-nest-exception.interface.js +2 -1
- package/dist/esm/lib/interfaces/entity-provider.interface.js +2 -1
- package/dist/esm/lib/interfaces/keys-of.type.js +2 -1
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -1,29 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lib/constants/millis-per-day.constant"), exports);
|
|
18
|
+
__exportStar(require("./lib/constants/millis-per-hour.constant"), exports);
|
|
19
|
+
__exportStar(require("./lib/constants/millis-per-minute.constant"), exports);
|
|
20
|
+
__exportStar(require("./lib/functions/add-offset.function"), exports);
|
|
21
|
+
__exportStar(require("./lib/functions/camel-case.function"), exports);
|
|
22
|
+
__exportStar(require("./lib/functions/convert-object-to-literal.function"), exports);
|
|
23
|
+
__exportStar(require("./lib/functions/from-boolean-string.function"), exports);
|
|
24
|
+
__exportStar(require("./lib/functions/from-calendar-date.function"), exports);
|
|
25
|
+
__exportStar(require("./lib/functions/from-csv-string.function"), exports);
|
|
26
|
+
__exportStar(require("./lib/functions/kebab-case.function"), exports);
|
|
27
|
+
__exportStar(require("./lib/functions/parse-bool.function"), exports);
|
|
28
|
+
__exportStar(require("./lib/functions/properties-to-array.function"), exports);
|
|
29
|
+
__exportStar(require("./lib/functions/sanitize-filename.function"), exports);
|
|
30
|
+
__exportStar(require("./lib/functions/snake-case.function"), exports);
|
|
31
|
+
__exportStar(require("./lib/functions/subtract-offset.function"), exports);
|
|
32
|
+
__exportStar(require("./lib/functions/to-boolean-string.function"), exports);
|
|
33
|
+
__exportStar(require("./lib/functions/to-calendar-date.function"), exports);
|
|
34
|
+
__exportStar(require("./lib/functions/to-csv-string.function"), exports);
|
|
35
|
+
__exportStar(require("./lib/functions/to-decimal-base.function"), exports);
|
|
36
|
+
__exportStar(require("./lib/functions/to-dollars-and-cents.function"), exports);
|
|
37
|
+
__exportStar(require("./lib/functions/to-unique-array.function"), exports);
|
|
38
|
+
__exportStar(require("./lib/functions/to-words.function"), exports);
|
|
39
|
+
__exportStar(require("./lib/functions/try-parse-date.function"), exports);
|
|
40
|
+
__exportStar(require("./lib/functions/unicode-words.const"), exports);
|
|
41
|
+
__exportStar(require("./lib/functions/upper-first.function"), exports);
|
|
42
|
+
__exportStar(require("./lib/functions/words.function"), exports);
|
|
43
|
+
__exportStar(require("./lib/interfaces/axios-wrapped-nest-exception.interface"), exports);
|
|
44
|
+
__exportStar(require("./lib/interfaces/entity-provider.interface"), exports);
|
|
45
|
+
__exportStar(require("./lib/interfaces/keys-of.type"), exports);
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MILLIS_PER_DAY = void 0;
|
|
4
|
+
const millis_per_hour_constant_1 = require("./millis-per-hour.constant");
|
|
5
|
+
exports.MILLIS_PER_DAY = millis_per_hour_constant_1.MILLIS_PER_HOUR * 24;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MILLIS_PER_HOUR = void 0;
|
|
4
|
+
const millis_per_minute_constant_1 = require("./millis-per-minute.constant");
|
|
5
|
+
exports.MILLIS_PER_HOUR = millis_per_minute_constant_1.MILLIS_PER_MINUTE * 60;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addOffset = void 0;
|
|
4
|
+
const millis_per_minute_constant_1 = require("../constants/millis-per-minute.constant");
|
|
5
|
+
const try_parse_date_function_1 = require("./try-parse-date.function");
|
|
6
|
+
function addOffset(input) {
|
|
7
|
+
const parsed = (0, try_parse_date_function_1.tryParseDate)(input);
|
|
5
8
|
if (!parsed) {
|
|
6
9
|
return;
|
|
7
10
|
}
|
|
8
11
|
const offset = (parsed).getTimezoneOffset();
|
|
9
|
-
return new Date(parsed.valueOf() + offset * MILLIS_PER_MINUTE);
|
|
12
|
+
return new Date(parsed.valueOf() + offset * millis_per_minute_constant_1.MILLIS_PER_MINUTE);
|
|
10
13
|
}
|
|
14
|
+
exports.addOffset = addOffset;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// https://github.com/lodash/lodash/blob/main/src/camelCase.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.camelCase = void 0;
|
|
5
|
+
const to_string_function_1 = require("./to-string.function");
|
|
6
|
+
const upper_first_function_1 = require("./upper-first.function");
|
|
7
|
+
const words_function_1 = require("./words.function");
|
|
5
8
|
/**
|
|
6
9
|
* Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
|
|
7
10
|
*
|
|
@@ -21,7 +24,8 @@ import { words } from './words.function';
|
|
|
21
24
|
* camelCase('__FOO_BAR__')
|
|
22
25
|
* // => 'fooBar'
|
|
23
26
|
*/
|
|
24
|
-
|
|
27
|
+
const camelCase = (string) => (0, words_function_1.words)((0, to_string_function_1.toString)(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => {
|
|
25
28
|
word = word.toLowerCase();
|
|
26
|
-
return result + (index ? upperFirst(word) : word);
|
|
29
|
+
return result + (index ? (0, upper_first_function_1.upperFirst)(word) : word);
|
|
27
30
|
}, '');
|
|
31
|
+
exports.camelCase = camelCase;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertObjectToLiteral = void 0;
|
|
4
|
+
function convertObjectToLiteral(literalFn, delimiter, keyValuePairs) {
|
|
2
5
|
return Object.entries(keyValuePairs)
|
|
3
6
|
.filter(([, v]) => !!v || v === 0 || v === false)
|
|
4
7
|
.map(([k, v]) => literalFn(k, v?.toString?.()))
|
|
5
8
|
.join(delimiter);
|
|
6
9
|
}
|
|
10
|
+
exports.convertObjectToLiteral = convertObjectToLiteral;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromBooleanString = void 0;
|
|
4
|
+
function fromBooleanString(value) {
|
|
2
5
|
return value === 'true';
|
|
3
6
|
}
|
|
7
|
+
exports.fromBooleanString = fromBooleanString;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromCalendarDate = void 0;
|
|
4
|
+
const add_offset_function_1 = require("./add-offset.function");
|
|
5
|
+
function fromCalendarDate(input) {
|
|
6
|
+
return (0, add_offset_function_1.addOffset)(input) || null;
|
|
4
7
|
}
|
|
8
|
+
exports.fromCalendarDate = fromCalendarDate;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromCsvString = void 0;
|
|
4
|
+
function fromCsvString(value) {
|
|
2
5
|
return value ? value.split(',').map((v) => v.trim()) : [];
|
|
3
6
|
}
|
|
7
|
+
exports.fromCsvString = fromCsvString;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// https://github.com/lodash/lodash/blob/main/src/.internal/getTag.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getTag = void 0;
|
|
2
5
|
const toString = Object.prototype.toString;
|
|
3
|
-
|
|
6
|
+
function getTag(value) {
|
|
4
7
|
if (value == null) {
|
|
5
8
|
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
6
9
|
}
|
|
7
10
|
return toString.call(value);
|
|
8
11
|
}
|
|
12
|
+
exports.getTag = getTag;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// https://github.com/lodash/lodash/blob/main/src/isSymbol.ts
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isSymbol = void 0;
|
|
5
|
+
const get_tag_function_1 = require("./get-tag.function");
|
|
6
|
+
function isSymbol(value) {
|
|
4
7
|
const type = typeof value;
|
|
5
8
|
return (type === 'symbol' ||
|
|
6
|
-
(type === 'object' && value != null && getTag(value) === '[object Symbol]'));
|
|
9
|
+
(type === 'object' && value != null && (0, get_tag_function_1.getTag)(value) === '[object Symbol]'));
|
|
7
10
|
}
|
|
11
|
+
exports.isSymbol = isSymbol;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.kebabCase = void 0;
|
|
4
|
+
const snake_case_function_1 = require("./snake-case.function");
|
|
5
|
+
function kebabCase(string) {
|
|
6
|
+
return (0, snake_case_function_1.snakeCase)(string).replace(/_/g, '-');
|
|
4
7
|
}
|
|
8
|
+
exports.kebabCase = kebabCase;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// credit https://stackoverflow.com/questions/15690706/recursively-looping-through-an-object-to-build-a-property-list/53620876#53620876
|
|
2
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.propertiesToArray = void 0;
|
|
5
|
+
function propertiesToArray(obj) {
|
|
3
6
|
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
4
7
|
const addDelimiter = (a, b) => a ? `${a}.${b}` : b;
|
|
5
8
|
const paths = (obj = {}, head = '') => {
|
|
@@ -13,3 +16,4 @@ export function propertiesToArray(obj) {
|
|
|
13
16
|
};
|
|
14
17
|
return paths(obj);
|
|
15
18
|
}
|
|
19
|
+
exports.propertiesToArray = propertiesToArray;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* eslint-disable no-control-regex */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.sanitizeFilename = void 0;
|
|
2
5
|
const _ = '_';
|
|
3
6
|
const asciiReplacementRegX = /\/|\?|:|\\|{|\^|'|\}|%|`|]|>|\[|~|<|#|\||"|!|\*/g;
|
|
4
7
|
const unicodeReplacementRegX = /[^\u0000-\u007F]/g;
|
|
5
|
-
|
|
8
|
+
function sanitizeFilename(filename) {
|
|
6
9
|
return filename.replace(unicodeReplacementRegX, _).replace(asciiReplacementRegX, _).replace(/_+/g, _).trim();
|
|
7
10
|
}
|
|
11
|
+
exports.sanitizeFilename = sanitizeFilename;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// source https://github.com/lodash/lodash/blob/master/snakeCase.js
|
|
2
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.snakeCase = void 0;
|
|
5
|
+
const words_function_1 = require("./words.function");
|
|
3
6
|
/**
|
|
4
7
|
* Converts `string` to
|
|
5
8
|
* [snake case](https://en.wikipedia.org/wiki/Snake_case).
|
|
@@ -23,6 +26,7 @@ import { words } from "./words.function";
|
|
|
23
26
|
* snakeCase('foo2bar')
|
|
24
27
|
* // => 'foo_2_bar'
|
|
25
28
|
*/
|
|
26
|
-
|
|
27
|
-
return (words(string.replace(/['\u2019]/g, '')).reduce((result, word, index) => (result + (index ? '_' : '') + word.toLowerCase()), ''));
|
|
29
|
+
function snakeCase(string) {
|
|
30
|
+
return ((0, words_function_1.words)(string.replace(/['\u2019]/g, '')).reduce((result, word, index) => (result + (index ? '_' : '') + word.toLowerCase()), ''));
|
|
28
31
|
}
|
|
32
|
+
exports.snakeCase = snakeCase;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subtractOffset = void 0;
|
|
4
|
+
const millis_per_minute_constant_1 = require("../constants/millis-per-minute.constant");
|
|
5
|
+
const try_parse_date_function_1 = require("./try-parse-date.function");
|
|
6
|
+
function subtractOffset(input) {
|
|
7
|
+
const parsed = (0, try_parse_date_function_1.tryParseDate)(input);
|
|
5
8
|
if (!parsed) {
|
|
6
9
|
return;
|
|
7
10
|
}
|
|
8
11
|
const offset = (parsed).getTimezoneOffset();
|
|
9
|
-
return new Date(parsed.valueOf() - offset * MILLIS_PER_MINUTE);
|
|
12
|
+
return new Date(parsed.valueOf() - offset * millis_per_minute_constant_1.MILLIS_PER_MINUTE);
|
|
10
13
|
}
|
|
14
|
+
exports.subtractOffset = subtractOffset;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBooleanString = void 0;
|
|
4
|
+
function toBooleanString(val) {
|
|
2
5
|
return (!!(val || false)).toString();
|
|
3
6
|
}
|
|
7
|
+
exports.toBooleanString = toBooleanString;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCalendarDate = void 0;
|
|
4
|
+
const subtract_offset_function_1 = require("./subtract-offset.function");
|
|
5
|
+
function toCalendarDate(input) {
|
|
6
|
+
const parsed = (0, subtract_offset_function_1.subtractOffset)(input);
|
|
4
7
|
if (!parsed) {
|
|
5
8
|
return;
|
|
6
9
|
}
|
|
7
10
|
return parsed?.toISOString().split('T')[0];
|
|
8
11
|
}
|
|
12
|
+
exports.toCalendarDate = toCalendarDate;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toDecimalBase = void 0;
|
|
4
|
+
function toDecimalBase(n, base = 16) {
|
|
2
5
|
const digits = n.toString().split('');
|
|
3
6
|
let answer = 0;
|
|
4
7
|
digits.reverse().forEach(function (d, i) {
|
|
@@ -16,3 +19,4 @@ export function toDecimalBase(n, base = 16) {
|
|
|
16
19
|
});
|
|
17
20
|
return answer;
|
|
18
21
|
}
|
|
22
|
+
exports.toDecimalBase = toDecimalBase;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toDollarsAndCents = void 0;
|
|
4
|
+
const to_words_function_1 = require("./to-words.function");
|
|
5
|
+
function toDollarsAndCents(number) {
|
|
3
6
|
const num = Number(number);
|
|
4
7
|
const decimal = (Math.round((num % 1) * 100)) / 100;
|
|
5
8
|
const int = num - decimal;
|
|
6
|
-
const dollars = `${toWords(int)} dollars`;
|
|
9
|
+
const dollars = `${(0, to_words_function_1.toWords)(int)} dollars`;
|
|
7
10
|
if (!decimal) {
|
|
8
11
|
return dollars;
|
|
9
12
|
}
|
|
10
|
-
return `${dollars} and ${toWords(decimal * 100)} cents`;
|
|
13
|
+
return `${dollars} and ${(0, to_words_function_1.toWords)(decimal * 100)} cents`;
|
|
11
14
|
}
|
|
15
|
+
exports.toDollarsAndCents = toDollarsAndCents;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// https://github.com/lodash/lodash/blob/main/src/toString.ts
|
|
2
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.toString = void 0;
|
|
5
|
+
const is_symbol_function_1 = require("./is-symbol.function");
|
|
3
6
|
/** Used as references for various `Number` constants. */
|
|
4
7
|
const INFINITY = 1 / 0;
|
|
5
|
-
|
|
8
|
+
function toString(value) {
|
|
6
9
|
if (value == null) {
|
|
7
10
|
return '';
|
|
8
11
|
}
|
|
@@ -14,9 +17,10 @@ export function toString(value) {
|
|
|
14
17
|
// Recursively convert values (susceptible to call stack limits).
|
|
15
18
|
return `${value.map((other) => (other == null ? other : toString(other)))}`;
|
|
16
19
|
}
|
|
17
|
-
if (isSymbol(value)) {
|
|
20
|
+
if ((0, is_symbol_function_1.isSymbol)(value)) {
|
|
18
21
|
return value.toString();
|
|
19
22
|
}
|
|
20
23
|
const result = `${value}`;
|
|
21
24
|
return result === '0' && 1 / value === -INFINITY ? '-0' : result;
|
|
22
25
|
}
|
|
26
|
+
exports.toString = toString;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toUniqueArray = void 0;
|
|
4
|
+
function toUniqueArray(elements) {
|
|
2
5
|
return Array.from(new Set(elements));
|
|
3
6
|
}
|
|
7
|
+
exports.toUniqueArray = toUniqueArray;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toWords = void 0;
|
|
1
4
|
const MAX_SAFE_INTEGER = 9007199254740991;
|
|
2
5
|
const TEN = 10;
|
|
3
6
|
const ONE_HUNDRED = 100;
|
|
@@ -14,7 +17,7 @@ const LESS_THAN_TWENTY = [
|
|
|
14
17
|
const TENTHS_LESS_THAN_HUNDRED = [
|
|
15
18
|
'zero', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'
|
|
16
19
|
];
|
|
17
|
-
|
|
20
|
+
function toWords(number) {
|
|
18
21
|
let words;
|
|
19
22
|
const num = parseInt(number, 10);
|
|
20
23
|
if (!isFinite(num)) {
|
|
@@ -26,6 +29,7 @@ export function toWords(number) {
|
|
|
26
29
|
words = generateWords(num);
|
|
27
30
|
return words;
|
|
28
31
|
}
|
|
32
|
+
exports.toWords = toWords;
|
|
29
33
|
function generateWords(number, words) {
|
|
30
34
|
let remainder, word;
|
|
31
35
|
if (number === 0) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tryParseDate = void 0;
|
|
4
|
+
function tryParseDate(input) {
|
|
2
5
|
if (!input) {
|
|
3
6
|
return;
|
|
4
7
|
}
|
|
@@ -11,3 +14,4 @@ export function tryParseDate(input) {
|
|
|
11
14
|
}
|
|
12
15
|
return date;
|
|
13
16
|
}
|
|
17
|
+
exports.tryParseDate = tryParseDate;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// source https://github.com/lodash/lodash/blob/master/.internal/unicodeWords.js
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.unicodeWords = void 0;
|
|
2
5
|
/** Used to compose unicode character classes. */
|
|
3
6
|
const rsAstralRange = '\\ud800-\\udfff';
|
|
4
7
|
const rsComboMarksRange = '\\u0300-\\u036f';
|
|
@@ -60,6 +63,7 @@ const reUnicodeWords = RegExp([
|
|
|
60
63
|
* @param {string} The string to inspect.
|
|
61
64
|
* @returns {Array} Returns the words of `string`.
|
|
62
65
|
*/
|
|
63
|
-
|
|
66
|
+
function unicodeWords(string) {
|
|
64
67
|
return string.match(reUnicodeWords);
|
|
65
68
|
}
|
|
69
|
+
exports.unicodeWords = unicodeWords;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upperFirst = void 0;
|
|
4
|
+
function upperFirst(string) {
|
|
2
5
|
if (!string) {
|
|
3
6
|
return string;
|
|
4
7
|
}
|
|
@@ -7,3 +10,4 @@ export function upperFirst(string) {
|
|
|
7
10
|
.map((curr, i) => curr[!i ? 'toUpperCase' : 'toLowerCase']())
|
|
8
11
|
.join('');
|
|
9
12
|
}
|
|
13
|
+
exports.upperFirst = upperFirst;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// source https://github.com/lodash/lodash/blob/master/words.js
|
|
2
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.words = void 0;
|
|
5
|
+
const unicode_words_const_1 = require("./unicode-words.const");
|
|
3
6
|
const hasUnicodeWord = RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/);
|
|
4
7
|
/** Used to match words composed of alphanumeric characters. */
|
|
5
8
|
const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
@@ -22,10 +25,11 @@ function asciiWords(string) {
|
|
|
22
25
|
* words('fred, barney, & pebbles', /[^, ]+/g)
|
|
23
26
|
* // => ['fred', 'barney', '&', 'pebbles']
|
|
24
27
|
*/
|
|
25
|
-
|
|
28
|
+
function words(string, pattern) {
|
|
26
29
|
if (pattern === undefined) {
|
|
27
|
-
const result = hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
|
|
30
|
+
const result = hasUnicodeWord(string) ? (0, unicode_words_const_1.unicodeWords)(string) : asciiWords(string);
|
|
28
31
|
return result || [];
|
|
29
32
|
}
|
|
30
33
|
return string.match(pattern) || [];
|
|
31
34
|
}
|
|
35
|
+
exports.words = words;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onivoro/isomorphic-common",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "onx Build",
|
|
12
|
-
"
|
|
12
|
+
"onx": "onx"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@onivoro/cli": "^0.0.
|
|
23
|
+
"@onivoro/cli": "^0.0.31",
|
|
24
24
|
"@types/jest": "^29.5.12",
|
|
25
25
|
"typescript": "^5.3.3"
|
|
26
26
|
}
|