@onivoro/isomorphic-common 0.0.10 → 0.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onivoro/isomorphic-common",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "main": "./src/index.js",
5
5
  "type": "commonjs"
6
6
  }
package/src/index.d.ts CHANGED
@@ -8,12 +8,14 @@ export * from './lib/functions/from-boolean-string.function';
8
8
  export * from './lib/functions/from-calendar-date.function';
9
9
  export * from './lib/functions/from-csv-string.function';
10
10
  export * from './lib/functions/parse-bool.function';
11
+ export * from './lib/functions/properties-to-array.function';
11
12
  export * from './lib/functions/sanitize-filename.function';
12
13
  export * from './lib/functions/snake-case.function';
13
14
  export * from './lib/functions/subtract-offset.function';
14
15
  export * from './lib/functions/to-boolean-string.function';
15
16
  export * from './lib/functions/to-calendar-date.function';
16
17
  export * from './lib/functions/to-csv-string.function';
18
+ export * from './lib/functions/to-decimal-base.function';
17
19
  export * from './lib/functions/to-locale-date-string.function';
18
20
  export * from './lib/functions/to-locale-time-string.function';
19
21
  export * from './lib/functions/to-unique-array.function';
package/src/index.js CHANGED
@@ -11,12 +11,14 @@ tslib_1.__exportStar(require("./lib/functions/from-boolean-string.function"), ex
11
11
  tslib_1.__exportStar(require("./lib/functions/from-calendar-date.function"), exports);
12
12
  tslib_1.__exportStar(require("./lib/functions/from-csv-string.function"), exports);
13
13
  tslib_1.__exportStar(require("./lib/functions/parse-bool.function"), exports);
14
+ tslib_1.__exportStar(require("./lib/functions/properties-to-array.function"), exports);
14
15
  tslib_1.__exportStar(require("./lib/functions/sanitize-filename.function"), exports);
15
16
  tslib_1.__exportStar(require("./lib/functions/snake-case.function"), exports);
16
17
  tslib_1.__exportStar(require("./lib/functions/subtract-offset.function"), exports);
17
18
  tslib_1.__exportStar(require("./lib/functions/to-boolean-string.function"), exports);
18
19
  tslib_1.__exportStar(require("./lib/functions/to-calendar-date.function"), exports);
19
20
  tslib_1.__exportStar(require("./lib/functions/to-csv-string.function"), exports);
21
+ tslib_1.__exportStar(require("./lib/functions/to-decimal-base.function"), exports);
20
22
  tslib_1.__exportStar(require("./lib/functions/to-locale-date-string.function"), exports);
21
23
  tslib_1.__exportStar(require("./lib/functions/to-locale-time-string.function"), exports);
22
24
  tslib_1.__exportStar(require("./lib/functions/to-unique-array.function"), exports);
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/isomorphic-common/src/index.ts"],"names":[],"mappings":";;;AAAA,kFAAwD;AACxD,mFAAyD;AACzD,qFAA2D;AAE3D,8EAAoD;AACpD,8EAAoD;AACpD,6FAAmE;AACnE,uFAA6D;AAC7D,sFAA4D;AAC5D,mFAAyD;AACzD,8EAAoD;AACpD,qFAA2D;AAC3D,8EAAoD;AACpD,mFAAyD;AACzD,qFAA2D;AAC3D,oFAA0D;AAC1D,iFAAuD;AACvD,yFAA+D;AAC/D,yFAA+D;AAC/D,mFAAyD;AACzD,kFAAwD;AACxD,8EAAoD;AACpD,+EAAqD;AACrD,yEAA+C;AAE/C,kGAAwE;AACxE,qFAA2D;AAC3D,wEAA8C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/isomorphic-common/src/index.ts"],"names":[],"mappings":";;;AAAA,kFAAwD;AACxD,mFAAyD;AACzD,qFAA2D;AAE3D,8EAAoD;AACpD,8EAAoD;AACpD,6FAAmE;AACnE,uFAA6D;AAC7D,sFAA4D;AAC5D,mFAAyD;AACzD,8EAAoD;AACpD,uFAA6D;AAC7D,qFAA2D;AAC3D,8EAAoD;AACpD,mFAAyD;AACzD,qFAA2D;AAC3D,oFAA0D;AAC1D,iFAAuD;AACvD,mFAAyD;AACzD,yFAA+D;AAC/D,yFAA+D;AAC/D,mFAAyD;AACzD,kFAAwD;AACxD,8EAAoD;AACpD,+EAAqD;AACrD,yEAA+C;AAE/C,kGAAwE;AACxE,qFAA2D;AAC3D,wEAA8C"}
@@ -0,0 +1 @@
1
+ export declare function propertiesToArray(obj: any): any;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // credit https://stackoverflow.com/questions/15690706/recursively-looping-through-an-object-to-build-a-property-list/53620876#53620876
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.propertiesToArray = void 0;
5
+ function propertiesToArray(obj) {
6
+ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
7
+ const addDelimiter = (a, b) => a ? `${a}.${b}` : b;
8
+ const paths = (obj = {}, head = '') => {
9
+ return Object.entries(obj)
10
+ .reduce((product, [key, value]) => {
11
+ let fullPath = addDelimiter(head, key);
12
+ return isObject(value) ?
13
+ product.concat(paths(value, fullPath))
14
+ : product.concat(fullPath);
15
+ }, []);
16
+ };
17
+ return paths(obj);
18
+ }
19
+ exports.propertiesToArray = propertiesToArray;
20
+ //# sourceMappingURL=properties-to-array.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties-to-array.function.js","sourceRoot":"","sources":["../../../../../../libs/isomorphic-common/src/lib/functions/properties-to-array.function.ts"],"names":[],"mappings":";AAAA,uIAAuI;;;AAEvI,SAAgB,iBAAiB,CAAC,GAAG;IACjC,MAAM,QAAQ,GAAG,GAAG,CAAC,EAAE,CACnB,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1D,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAC1B,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAExB,MAAM,KAAK,GAAG,CAAC,GAAG,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;QAClC,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;aACrB,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC9B,IAAI,QAAQ,GAAG,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;YACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;gBACtC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAClC,CAAC,EAAE,EAAE,CAAC,CAAC;IACf,CAAC,CAAA;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAlBD,8CAkBC"}
@@ -0,0 +1 @@
1
+ export declare function toDecimalBase(n: string | number, base?: number): number;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toDecimalBase = void 0;
4
+ function toDecimalBase(n, base = 16) {
5
+ const digits = n.toString().split('');
6
+ let answer = 0;
7
+ digits.reverse().forEach(function (d, i) {
8
+ let actualNumber = Number(d);
9
+ if (!actualNumber && actualNumber !== 0) {
10
+ const codeAt = d.charCodeAt(0);
11
+ if (codeAt >= 97) {
12
+ actualNumber = codeAt - 87;
13
+ }
14
+ else {
15
+ actualNumber = codeAt - 55;
16
+ }
17
+ }
18
+ answer = answer + actualNumber * Math.pow(base, i);
19
+ });
20
+ return answer;
21
+ }
22
+ exports.toDecimalBase = toDecimalBase;
23
+ //# sourceMappingURL=to-decimal-base.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-decimal-base.function.js","sourceRoot":"","sources":["../../../../../../libs/isomorphic-common/src/lib/functions/to-decimal-base.function.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa,CAAC,CAAkB,EAAE,IAAI,GAAG,EAAE;IACvD,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAEtC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACnC,IAAI,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAE7B,IAAI,CAAC,YAAY,IAAI,YAAY,KAAK,CAAC,EAAE;YACrC,MAAM,MAAM,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAE/B,IAAI,MAAM,IAAI,EAAE,EAAE;gBACd,YAAY,GAAG,MAAM,GAAG,EAAE,CAAC;aAC9B;iBAAM;gBACH,YAAY,GAAG,MAAM,GAAG,EAAE,CAAC;aAC9B;SACJ;QAED,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC;AAtBD,sCAsBC"}