js-build-tools 5.1.1 → 5.3.0
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/README.md +348 -284
- package/dist/build.js +7 -2
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +32 -16
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +16 -16
- package/dist/bundleMinify.js +13 -13
- package/dist/compileReadme.js +10 -10
- package/dist/copyFonts.js +13 -13
- package/dist/default.js +15 -15
- package/dist/dist.js +10 -10
- package/dist/distLint.js +16 -16
- package/dist/distMinify.js +13 -13
- package/dist/images.js +10 -10
- package/dist/partials/addToReadme.js +17 -17
- package/dist/partials/beginWatcher.js +12 -12
- package/dist/partials/clean.js +14 -14
- package/dist/partials/copyFor.js +12 -12
- package/dist/partials/distFor.js +21 -21
- package/dist/partials/distForSrc.js +11 -11
- package/dist/partials/distSeries.js +19 -19
- package/dist/partials/imagesFor.js +48 -48
- package/dist/partials/minifyFor.js +16 -16
- package/dist/partials/readmeTemplate.js +14 -14
- package/dist/partials/removeDirectory.js +29 -29
- package/dist/partials/runOnChange.js +28 -28
- package/dist/partials/sassFor.js +28 -28
- package/dist/partials/standardLint.js +75 -75
- package/dist/partials/tsFor.js +82 -82
- package/dist/partials/typeDocsFor.js +214 -0
- package/dist/partials.js +7 -0
- package/dist/partials.min.js +1 -1
- package/dist/sass.js +10 -10
- package/dist/test-helpers/setUp.js +89 -89
- package/dist/test-helpers/standardLintWithRealStandard.js +27 -27
- package/dist/testFull.js +20 -20
- package/dist/testHelpers.js +10 -10
- package/dist/testQuick.js +22 -22
- package/dist/typeDocs.js +14 -0
- package/dist/typeDocs.min.js +1 -0
- package/dist/typeScript.js +9 -9
- package/dist/utilities/dotGet.js +46 -46
- package/dist/utilities/dotNotate.js +46 -46
- package/dist/utilities/dotSet.js +37 -37
- package/dist/utilities/isObject.js +8 -8
- package/dist/utilities/strAfter.js +11 -11
- package/dist/utilities/strBefore.js +11 -11
- package/dist/watchFull.js +10 -10
- package/dist/watchTest.js +16 -16
- package/functions/build.mjs +7 -2
- package/functions/build.test.mjs +29 -0
- package/functions/bundle.mjs +20 -4
- package/functions/bundle.test.mjs +74 -0
- package/functions/partials/typeDocsFor.mjs +194 -0
- package/functions/partials/typeDocsFor.test.mjs +183 -0
- package/functions/partials.mjs +1 -0
- package/functions/partials.test.mjs +1 -1
- package/functions/typeDocs.mjs +9 -0
- package/functions/typeDocs.test.mjs +11 -0
- package/gulp.config.mjs +32 -0
- package/gulpfile.base.js +2 -0
- package/gulpfile.base.mjs +1 -0
- package/package.json +12 -7
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.standardLint = exports.loadStandardViaSubprocess = void 0;
|
|
7
|
-
require("core-js/modules/es.json.stringify.js");
|
|
8
|
-
var _nodeChild_process = require("node:child_process");
|
|
9
|
-
// Jest's CommonJS transform cannot load `standard` (ESM-only) or run a real dynamic import(), so tests that need
|
|
10
|
-
// genuine Standard behavior run the actual `standard` package in a plain Node subprocess instead of faking it.
|
|
11
|
-
const script = 'import { readFileSync } from \'node:fs\'\n' + 'import standard from \'standard\'\n' + 'const { text, options } = JSON.parse(readFileSync(0, \'utf8\'))\n' + 'process.stdout.write(JSON.stringify(await standard.lintText(text, options)))\n';
|
|
12
|
-
const loadStandardViaSubprocess = () => Promise.resolve({
|
|
13
|
-
lintText: (text, options) => Promise.resolve().then(() => JSON.parse((0, _nodeChild_process.execFileSync)(process.execPath, ['--input-type=module', '--eval', script], {
|
|
14
|
-
input: JSON.stringify({
|
|
15
|
-
text,
|
|
16
|
-
options
|
|
17
|
-
}),
|
|
18
|
-
encoding: 'utf8',
|
|
19
|
-
cwd: process.cwd(),
|
|
20
|
-
maxBuffer: 256 * 1024 * 1024
|
|
21
|
-
})))
|
|
22
|
-
});
|
|
23
|
-
exports.loadStandardViaSubprocess = loadStandardViaSubprocess;
|
|
24
|
-
const actual = jest.requireActual('../partials/standardLint.js');
|
|
25
|
-
|
|
26
|
-
// Drop-in replacement for the partial module (see jest.mock in the lint/build tests): same API, real Standard.
|
|
27
|
-
const standardLint = options => actual.standardLint(options, loadStandardViaSubprocess);
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.standardLint = exports.loadStandardViaSubprocess = void 0;
|
|
7
|
+
require("core-js/modules/es.json.stringify.js");
|
|
8
|
+
var _nodeChild_process = require("node:child_process");
|
|
9
|
+
// Jest's CommonJS transform cannot load `standard` (ESM-only) or run a real dynamic import(), so tests that need
|
|
10
|
+
// genuine Standard behavior run the actual `standard` package in a plain Node subprocess instead of faking it.
|
|
11
|
+
const script = 'import { readFileSync } from \'node:fs\'\n' + 'import standard from \'standard\'\n' + 'const { text, options } = JSON.parse(readFileSync(0, \'utf8\'))\n' + 'process.stdout.write(JSON.stringify(await standard.lintText(text, options)))\n';
|
|
12
|
+
const loadStandardViaSubprocess = () => Promise.resolve({
|
|
13
|
+
lintText: (text, options) => Promise.resolve().then(() => JSON.parse((0, _nodeChild_process.execFileSync)(process.execPath, ['--input-type=module', '--eval', script], {
|
|
14
|
+
input: JSON.stringify({
|
|
15
|
+
text,
|
|
16
|
+
options
|
|
17
|
+
}),
|
|
18
|
+
encoding: 'utf8',
|
|
19
|
+
cwd: process.cwd(),
|
|
20
|
+
maxBuffer: 256 * 1024 * 1024
|
|
21
|
+
})))
|
|
22
|
+
});
|
|
23
|
+
exports.loadStandardViaSubprocess = loadStandardViaSubprocess;
|
|
24
|
+
const actual = jest.requireActual('../partials/standardLint.js');
|
|
25
|
+
|
|
26
|
+
// Drop-in replacement for the partial module (see jest.mock in the lint/build tests): same API, real Standard.
|
|
27
|
+
const standardLint = options => actual.standardLint(options, loadStandardViaSubprocess);
|
|
28
28
|
exports.standardLint = standardLint;
|
package/dist/testFull.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
-
Object.defineProperty(exports, '__esModule', {
|
|
5
|
-
value: true
|
|
6
|
-
})
|
|
7
|
-
exports.testFull = void 0
|
|
8
|
-
const gulpConfig = _interopRequireWildcard(require('../gulp.config.js'))
|
|
9
|
-
const _jest = require('jest')
|
|
10
|
-
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
+
Object.defineProperty(exports, '__esModule', {
|
|
5
|
+
value: true
|
|
6
|
+
})
|
|
7
|
+
exports.testFull = void 0
|
|
8
|
+
const gulpConfig = _interopRequireWildcard(require('../gulp.config.js'))
|
|
9
|
+
const _jest = require('jest')
|
|
10
|
+
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
|
11
11
|
/**
|
|
12
12
|
* Run all tests with jest.
|
|
13
13
|
* Configure where tests are located by using 'testPath'.
|
|
14
14
|
* @memberOf module:js-build-tools
|
|
15
15
|
* @returns {Promise<*>}
|
|
16
|
-
*/
|
|
17
|
-
const testFull = () => {
|
|
18
|
-
let testPath = gulpConfig.get('test.path')
|
|
19
|
-
if (!Array.isArray(testPath)) {
|
|
20
|
-
// The testPath must be an array of strings
|
|
21
|
-
testPath = [testPath]
|
|
22
|
-
}
|
|
23
|
-
return (0, _jest.runCLI)(gulpConfig.get('test.options'), testPath)
|
|
24
|
-
}
|
|
25
|
-
exports.testFull = testFull
|
|
16
|
+
*/
|
|
17
|
+
const testFull = () => {
|
|
18
|
+
let testPath = gulpConfig.get('test.path')
|
|
19
|
+
if (!Array.isArray(testPath)) {
|
|
20
|
+
// The testPath must be an array of strings
|
|
21
|
+
testPath = [testPath]
|
|
22
|
+
}
|
|
23
|
+
return (0, _jest.runCLI)(gulpConfig.get('test.options'), testPath)
|
|
24
|
+
}
|
|
25
|
+
exports.testFull = testFull
|
package/dist/testHelpers.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
-
Object.defineProperty(exports, '__esModule', {
|
|
5
|
-
value: true
|
|
6
|
-
})
|
|
7
|
-
exports.testHelpers = void 0
|
|
8
|
-
const _testHelpers = _interopRequireWildcard(require('./test-helpers/setUp.js'))
|
|
9
|
-
exports.testHelpers = _testHelpers
|
|
10
|
-
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
+
Object.defineProperty(exports, '__esModule', {
|
|
5
|
+
value: true
|
|
6
|
+
})
|
|
7
|
+
exports.testHelpers = void 0
|
|
8
|
+
const _testHelpers = _interopRequireWildcard(require('./test-helpers/setUp.js'))
|
|
9
|
+
exports.testHelpers = _testHelpers
|
|
10
|
+
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
package/dist/testQuick.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
-
Object.defineProperty(exports, '__esModule', {
|
|
5
|
-
value: true
|
|
6
|
-
})
|
|
7
|
-
exports.testQuick = void 0
|
|
8
|
-
const gulpConfig = _interopRequireWildcard(require('../gulp.config.js'))
|
|
9
|
-
const _jest = require('jest')
|
|
10
|
-
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.weak-map.delete-all.js')
|
|
4
|
+
Object.defineProperty(exports, '__esModule', {
|
|
5
|
+
value: true
|
|
6
|
+
})
|
|
7
|
+
exports.testQuick = void 0
|
|
8
|
+
const gulpConfig = _interopRequireWildcard(require('../gulp.config.js'))
|
|
9
|
+
const _jest = require('jest')
|
|
10
|
+
function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; let o; let i; const f = { __proto__: null, default: e }; if (e === null || typeof e !== 'object' && typeof e !== 'function') return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f) } for (const t in e) t !== 'default' && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f })(e, t) }
|
|
11
11
|
/**
|
|
12
12
|
* Run the Jest tests for files which have been modified (based on git status).
|
|
13
13
|
* Configure where tests are located by using 'testPath'.
|
|
14
14
|
* @memberOf module:js-build-tools
|
|
15
15
|
* @returns {Promise<*>}
|
|
16
|
-
*/
|
|
17
|
-
const testQuick = () => {
|
|
18
|
-
let testPath = gulpConfig.get('test.path')
|
|
19
|
-
if (!Array.isArray(testPath)) {
|
|
20
|
-
// The testPath must be an array of strings
|
|
21
|
-
testPath = [testPath]
|
|
22
|
-
}
|
|
23
|
-
return (0, _jest.runCLI)({
|
|
24
|
-
onlyChanged: true
|
|
25
|
-
}, testPath)
|
|
26
|
-
}
|
|
27
|
-
exports.testQuick = testQuick
|
|
16
|
+
*/
|
|
17
|
+
const testQuick = () => {
|
|
18
|
+
let testPath = gulpConfig.get('test.path')
|
|
19
|
+
if (!Array.isArray(testPath)) {
|
|
20
|
+
// The testPath must be an array of strings
|
|
21
|
+
testPath = [testPath]
|
|
22
|
+
}
|
|
23
|
+
return (0, _jest.runCLI)({
|
|
24
|
+
onlyChanged: true
|
|
25
|
+
}, testPath)
|
|
26
|
+
}
|
|
27
|
+
exports.testQuick = testQuick
|
package/dist/typeDocs.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.typeDocs = void 0
|
|
7
|
+
const _typeDocsFor = require('./partials/typeDocsFor.js')
|
|
8
|
+
/**
|
|
9
|
+
* Generate the HTML documentation of a TypeScript project from its source, with the modules mirroring the source
|
|
10
|
+
* folders. Turn it on with docs.enabled, see {@link module:partials.typeDocsFor}.
|
|
11
|
+
* @memberOf module:js-build-tools
|
|
12
|
+
* @returns {Function}
|
|
13
|
+
*/
|
|
14
|
+
const typeDocs = exports.typeDocs = (0, _typeDocsFor.typeDocsFor)()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.typeDocs=void 0;var _typeDocsFor=require("./partials/typeDocsFor.js");const typeDocs=exports.typeDocs=(0,_typeDocsFor.typeDocsFor)();
|
package/dist/typeScript.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.typeScript = void 0
|
|
7
|
-
const _tsFor = require('./partials/tsFor.js')
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.typeScript = void 0
|
|
7
|
+
const _tsFor = require('./partials/tsFor.js')
|
|
8
8
|
/**
|
|
9
9
|
* Simplified typescript task using tsFor.
|
|
10
10
|
* @memberOf module:js-build-tools
|
|
11
11
|
* @returns {Function}
|
|
12
|
-
*/
|
|
13
|
-
const typeScript = exports.typeScript = (0, _tsFor.tsFor)()
|
|
12
|
+
*/
|
|
13
|
+
const typeScript = exports.typeScript = (0, _tsFor.tsFor)()
|
package/dist/utilities/dotGet.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dotGet = void 0;
|
|
7
|
-
var _isObject = require("./isObject.js");
|
|
8
|
-
var _strAfter = require("./strAfter.js");
|
|
9
|
-
var _strBefore = require("./strBefore.js");
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dotGet = void 0;
|
|
7
|
+
var _isObject = require("./isObject.js");
|
|
8
|
+
var _strAfter = require("./strAfter.js");
|
|
9
|
+
var _strBefore = require("./strBefore.js");
|
|
10
10
|
/**
|
|
11
11
|
* Get a nested property value from an object.
|
|
12
12
|
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotGet.ts Sí, funciona}
|
|
@@ -14,41 +14,41 @@ var _strBefore = require("./strBefore.js");
|
|
|
14
14
|
* @param {string} [dotNotation=''] - The path to the property
|
|
15
15
|
* @param {string|null} [defaultValue=null] - The default value to return if the property is not found
|
|
16
16
|
* @returns {*} The value of the property
|
|
17
|
-
*/
|
|
18
|
-
const dotGet = (arrayObject = {}, dotNotation = '', defaultValue = null) => {
|
|
19
|
-
if (!dotNotation) {
|
|
20
|
-
return arrayObject;
|
|
21
|
-
}
|
|
22
|
-
let key = (0, _strBefore.strBefore)(dotNotation, '.');
|
|
23
|
-
const lastKey = !key;
|
|
24
|
-
if (lastKey) {
|
|
25
|
-
key = dotNotation;
|
|
26
|
-
}
|
|
27
|
-
if (key === '*') {
|
|
28
|
-
const result = [];
|
|
29
|
-
for (let wildKey in arrayObject) {
|
|
30
|
-
const wildValue = arrayObject[wildKey];
|
|
31
|
-
if (lastKey) {
|
|
32
|
-
result[wildKey] = wildValue;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (!(0, _isObject.isObject)(wildValue)) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
result[wildKey] = dotGet(wildValue, (0, _strAfter.strAfter)(dotNotation, '.'), defaultValue);
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
if (lastKey) {
|
|
43
|
-
return arrayObject[dotNotation] ?? defaultValue;
|
|
44
|
-
}
|
|
45
|
-
if (typeof arrayObject[key] === 'undefined') {
|
|
46
|
-
return defaultValue;
|
|
47
|
-
}
|
|
48
|
-
const next = arrayObject[key];
|
|
49
|
-
if (!(0, _isObject.isObject)(next)) {
|
|
50
|
-
return defaultValue;
|
|
51
|
-
}
|
|
52
|
-
return dotGet(next, (0, _strAfter.strAfter)(dotNotation, '.'), defaultValue);
|
|
53
|
-
};
|
|
17
|
+
*/
|
|
18
|
+
const dotGet = (arrayObject = {}, dotNotation = '', defaultValue = null) => {
|
|
19
|
+
if (!dotNotation) {
|
|
20
|
+
return arrayObject;
|
|
21
|
+
}
|
|
22
|
+
let key = (0, _strBefore.strBefore)(dotNotation, '.');
|
|
23
|
+
const lastKey = !key;
|
|
24
|
+
if (lastKey) {
|
|
25
|
+
key = dotNotation;
|
|
26
|
+
}
|
|
27
|
+
if (key === '*') {
|
|
28
|
+
const result = [];
|
|
29
|
+
for (let wildKey in arrayObject) {
|
|
30
|
+
const wildValue = arrayObject[wildKey];
|
|
31
|
+
if (lastKey) {
|
|
32
|
+
result[wildKey] = wildValue;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (!(0, _isObject.isObject)(wildValue)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
result[wildKey] = dotGet(wildValue, (0, _strAfter.strAfter)(dotNotation, '.'), defaultValue);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
if (lastKey) {
|
|
43
|
+
return arrayObject[dotNotation] ?? defaultValue;
|
|
44
|
+
}
|
|
45
|
+
if (typeof arrayObject[key] === 'undefined') {
|
|
46
|
+
return defaultValue;
|
|
47
|
+
}
|
|
48
|
+
const next = arrayObject[key];
|
|
49
|
+
if (!(0, _isObject.isObject)(next)) {
|
|
50
|
+
return defaultValue;
|
|
51
|
+
}
|
|
52
|
+
return dotGet(next, (0, _strAfter.strAfter)(dotNotation, '.'), defaultValue);
|
|
53
|
+
};
|
|
54
54
|
exports.dotGet = dotGet;
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dotNotate = void 0;
|
|
7
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
-
require("core-js/modules/esnext.iterator.map.js");
|
|
9
|
-
var _isObject = require("./isObject.js");
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dotNotate = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
9
|
+
var _isObject = require("./isObject.js");
|
|
10
10
|
/**
|
|
11
11
|
* Convert an array of keys into a regex, return a function to test if incoming keys match.
|
|
12
12
|
* @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
|
|
13
13
|
* @returns {Function} The dot-notated array
|
|
14
|
-
*/
|
|
15
|
-
const handleRetainObjects = (retainObjects = []) => {
|
|
16
|
-
if (!retainObjects.length) {
|
|
14
|
+
*/
|
|
15
|
+
const handleRetainObjects = (retainObjects = []) => {
|
|
16
|
+
if (!retainObjects.length) {
|
|
17
17
|
/**
|
|
18
18
|
* Bypass the test function if there are no retainObjects.
|
|
19
19
|
* @returns {false}
|
|
20
|
-
*/
|
|
21
|
-
return (currentKey, value, results) => false;
|
|
22
|
-
}
|
|
23
|
-
retainObjects = retainObjects.map(key => key.replace('\.', '\\.'));
|
|
24
|
-
const retainRegex = new RegExp(`(${retainObjects.join('|')})$`);
|
|
20
|
+
*/
|
|
21
|
+
return (currentKey, value, results) => false;
|
|
22
|
+
}
|
|
23
|
+
retainObjects = retainObjects.map(key => key.replace('\.', '\\.'));
|
|
24
|
+
const retainRegex = new RegExp(`(${retainObjects.join('|')})$`);
|
|
25
25
|
/**
|
|
26
26
|
* Test if a key should be retained as an object.
|
|
27
27
|
* @param {string} currentKey - The key to test
|
|
28
28
|
* @param {*} value - The value of the key
|
|
29
29
|
* @param {Object} results - The result object to add to
|
|
30
30
|
* @returns {boolean}
|
|
31
|
-
*/
|
|
32
|
-
return (currentKey, value, results) => {
|
|
33
|
-
if (!currentKey.match(retainRegex)) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
results[currentKey] = value;
|
|
37
|
-
return true;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
31
|
+
*/
|
|
32
|
+
return (currentKey, value, results) => {
|
|
33
|
+
if (!currentKey.match(retainRegex)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
results[currentKey] = value;
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
41
|
/**
|
|
42
42
|
* The underlying logic function for converting arrays to dot-notation.
|
|
43
43
|
* @param {Object} arrayObject - The array or object to dot-notate
|
|
@@ -45,29 +45,29 @@ const handleRetainObjects = (retainObjects = []) => {
|
|
|
45
45
|
* @param {string} [prepend=''] - The path for the property being processed
|
|
46
46
|
* @param {Object<string, *>} [results={}] - The final notated object to return
|
|
47
47
|
* @returns {Object<string, *>} The dot-notated object
|
|
48
|
-
*/
|
|
49
|
-
const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) => {
|
|
50
|
-
for (let key in arrayObject) {
|
|
51
|
-
const value = arrayObject[key];
|
|
52
|
-
const currentKey = `${prepend}${key}`;
|
|
53
|
-
if (didRetain(currentKey, value, results)) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if ((0, _isObject.isObject)(value)) {
|
|
57
|
-
performDotNotate(value, didRetain, `${currentKey}.`, results);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
results[currentKey] = value;
|
|
61
|
-
}
|
|
62
|
-
return results;
|
|
63
|
-
};
|
|
64
|
-
|
|
48
|
+
*/
|
|
49
|
+
const performDotNotate = (arrayObject, didRetain, prepend = '', results = {}) => {
|
|
50
|
+
for (let key in arrayObject) {
|
|
51
|
+
const value = arrayObject[key];
|
|
52
|
+
const currentKey = `${prepend}${key}`;
|
|
53
|
+
if (didRetain(currentKey, value, results)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if ((0, _isObject.isObject)(value)) {
|
|
57
|
+
performDotNotate(value, didRetain, `${currentKey}.`, results);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
results[currentKey] = value;
|
|
61
|
+
}
|
|
62
|
+
return results;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
65
|
/**
|
|
66
66
|
* Convert an array or object to a single dimensional associative array with dot notation.
|
|
67
67
|
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotNotate.ts Sí, funciona}
|
|
68
68
|
* @param {Object} arrayObject - The array or object to dot-notate
|
|
69
69
|
* @param {Array.<string>} [retainObjects=[]] - An array of keys to retain as objects
|
|
70
70
|
* @returns {Object<string, *>} The dot-notated object
|
|
71
|
-
*/
|
|
72
|
-
const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects));
|
|
71
|
+
*/
|
|
72
|
+
const dotNotate = (arrayObject, retainObjects = []) => performDotNotate(arrayObject, handleRetainObjects(retainObjects));
|
|
73
73
|
exports.dotNotate = dotNotate;
|
package/dist/utilities/dotSet.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dotSet = void 0;
|
|
7
|
-
var _isObject = require("./isObject.js");
|
|
8
|
-
var _strAfter = require("./strAfter.js");
|
|
9
|
-
var _strBefore = require("./strBefore.js");
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dotSet = void 0;
|
|
7
|
+
var _isObject = require("./isObject.js");
|
|
8
|
+
var _strAfter = require("./strAfter.js");
|
|
9
|
+
var _strBefore = require("./strBefore.js");
|
|
10
10
|
/**
|
|
11
11
|
* Set a nested property value an object.
|
|
12
12
|
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/dotSet.ts Sí, funciona}
|
|
@@ -14,32 +14,32 @@ var _strBefore = require("./strBefore.js");
|
|
|
14
14
|
* @param {string} dotNotation - The path for the property
|
|
15
15
|
* @param {*} value - The default value to return if the property is not found
|
|
16
16
|
* @returns {Object} The modified object
|
|
17
|
-
*/
|
|
18
|
-
const dotSet = (arrayObject, dotNotation, value = null) => {
|
|
19
|
-
let key = (0, _strBefore.strBefore)(dotNotation, '.');
|
|
20
|
-
const lastKey = !key;
|
|
21
|
-
if (lastKey) {
|
|
22
|
-
key = dotNotation;
|
|
23
|
-
}
|
|
24
|
-
if (key === '*') {
|
|
25
|
-
for (let wildKey in arrayObject) {
|
|
26
|
-
if (lastKey) {
|
|
27
|
-
arrayObject[wildKey] = value;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (!(0, _isObject.isObject)(arrayObject[wildKey])) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
dotSet(arrayObject[wildKey], (0, _strAfter.strAfter)(dotNotation, '.'), value);
|
|
34
|
-
}
|
|
35
|
-
return arrayObject;
|
|
36
|
-
}
|
|
37
|
-
if (lastKey) {
|
|
38
|
-
arrayObject[dotNotation] = value;
|
|
39
|
-
return arrayObject;
|
|
40
|
-
}
|
|
41
|
-
const next = arrayObject[key] ?? [];
|
|
42
|
-
arrayObject[key] = dotSet(next, (0, _strAfter.strAfter)(dotNotation, '.'), value);
|
|
43
|
-
return arrayObject;
|
|
44
|
-
};
|
|
17
|
+
*/
|
|
18
|
+
const dotSet = (arrayObject, dotNotation, value = null) => {
|
|
19
|
+
let key = (0, _strBefore.strBefore)(dotNotation, '.');
|
|
20
|
+
const lastKey = !key;
|
|
21
|
+
if (lastKey) {
|
|
22
|
+
key = dotNotation;
|
|
23
|
+
}
|
|
24
|
+
if (key === '*') {
|
|
25
|
+
for (let wildKey in arrayObject) {
|
|
26
|
+
if (lastKey) {
|
|
27
|
+
arrayObject[wildKey] = value;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (!(0, _isObject.isObject)(arrayObject[wildKey])) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
dotSet(arrayObject[wildKey], (0, _strAfter.strAfter)(dotNotation, '.'), value);
|
|
34
|
+
}
|
|
35
|
+
return arrayObject;
|
|
36
|
+
}
|
|
37
|
+
if (lastKey) {
|
|
38
|
+
arrayObject[dotNotation] = value;
|
|
39
|
+
return arrayObject;
|
|
40
|
+
}
|
|
41
|
+
const next = arrayObject[key] ?? [];
|
|
42
|
+
arrayObject[key] = dotSet(next, (0, _strAfter.strAfter)(dotNotation, '.'), value);
|
|
43
|
+
return arrayObject;
|
|
44
|
+
};
|
|
45
45
|
exports.dotSet = dotSet;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isObject = void 0;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isObject = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Check if the provided thing is an object / array.
|
|
9
9
|
* Original source concepts from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/objects/isObject.ts Sí, funciona}
|
|
10
10
|
* @param {*} object
|
|
11
11
|
* @returns {boolean}
|
|
12
|
-
*/
|
|
13
|
-
const isObject = object => typeof object === 'object' && object !== null;
|
|
12
|
+
*/
|
|
13
|
+
const isObject = object => typeof object === 'object' && object !== null;
|
|
14
14
|
exports.isObject = isObject;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.strAfter = void 0;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.strAfter = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Retrieve the string part after the search match.
|
|
9
9
|
* Original source from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/strings/strAfter.ts Sí, funciona}
|
|
10
10
|
* @param {string} str
|
|
11
11
|
* @param {string} search
|
|
12
12
|
* @returns {string}
|
|
13
|
-
*/
|
|
14
|
-
const strAfter = (str, search) => {
|
|
15
|
-
const index = str.indexOf(search);
|
|
16
|
-
return index === -1 ? '' : str.substring(index + search.length);
|
|
17
|
-
};
|
|
13
|
+
*/
|
|
14
|
+
const strAfter = (str, search) => {
|
|
15
|
+
const index = str.indexOf(search);
|
|
16
|
+
return index === -1 ? '' : str.substring(index + search.length);
|
|
17
|
+
};
|
|
18
18
|
exports.strAfter = strAfter;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.strBefore = void 0;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.strBefore = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Retrieve the string part before the search match.
|
|
9
9
|
* Original source from {@link https://github.com/jheagle/si-funciona/blob/main/src/helpers/strings/strBefore.ts Sí, funciona}
|
|
10
10
|
* @param {string} str
|
|
11
11
|
* @param {string} search
|
|
12
12
|
* @returns {string}
|
|
13
|
-
*/
|
|
14
|
-
const strBefore = (str, search) => {
|
|
15
|
-
const index = str.indexOf(search);
|
|
16
|
-
return index === -1 ? '' : str.slice(0, index);
|
|
17
|
-
};
|
|
13
|
+
*/
|
|
14
|
+
const strBefore = (str, search) => {
|
|
15
|
+
const index = str.indexOf(search);
|
|
16
|
+
return index === -1 ? '' : str.slice(0, index);
|
|
17
|
+
};
|
|
18
18
|
exports.strBefore = strBefore;
|
package/dist/watchFull.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
})
|
|
6
|
-
exports.watchFull = void 0
|
|
7
|
-
const _partials = require('./partials.js')
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
})
|
|
6
|
+
exports.watchFull = void 0
|
|
7
|
+
const _partials = require('./partials.js')
|
|
8
8
|
/**
|
|
9
9
|
* Watch for changes and run the distribution for the changed files, then bundle and test the changed files.
|
|
10
10
|
* @memberOf module:js-build-tools
|
|
11
11
|
* @returns {FSWatcher}
|
|
12
|
-
*/
|
|
13
|
-
const watchFull = () => (0, _partials.beginWatcher)().on('change', _partials.runOnChange)
|
|
14
|
-
exports.watchFull = watchFull
|
|
12
|
+
*/
|
|
13
|
+
const watchFull = () => (0, _partials.beginWatcher)().on('change', _partials.runOnChange)
|
|
14
|
+
exports.watchFull = watchFull
|