diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 218b15d..0000000 --- a/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -tmp -out -node_modules -npm-debug.log diff --git a/lib/transform.js b/lib/transform.js index e986258..b2d43c1 100644 --- a/lib/transform.js +++ b/lib/transform.js @@ -1,8 +1,8 @@ const testValue = require('test-value') const where = testValue.where const arrayify = require('array-back') -const extract = require('reduce-extract') const omit = require('lodash.omit') +const findReplace = require('find-replace') function pick (object, keys) { return keys.reduce((obj, key) => { @@ -13,6 +13,12 @@ function pick (object, keys) { }, {}) } +function extract (arr, fn) { + const result = arr.filter(fn) + findReplace(arr, fn) + return result +} + /** * @module transform */ @@ -271,7 +277,7 @@ function buildTodoList (doclet) { Combine @todo array with @done custom tags to make @todoList */ if (doclet.tags) { - const done = doclet.tags.reduce(extract({ title: 'done' }), []) + const done = extract(doclet.tags, t => t.title === 'done') if (!doclet.tags.length) delete doclet.tags todoList = todoList.concat(done.map(function (task) { return { done: true, task: task.value } @@ -286,7 +292,7 @@ function buildTodoList (doclet) { function extractTypicalName (doclet) { if (doclet.tags) { - const typicalName = doclet.tags.reduce(extract({ title: 'typicalname' }), []) + const typicalName = extract(doclet.tags, t => t.title === 'typicalname') if (typicalName.length) doclet.typicalname = typicalName[0].value } return doclet @@ -294,7 +300,7 @@ function extractTypicalName (doclet) { function extractCategory (doclet) { if (doclet.tags) { - const category = doclet.tags.reduce(extract({ title: 'category' }), []) + const category = extract(doclet.tags, t => t.title === 'category') if (category.length) doclet.category = category[0].value } return doclet @@ -302,7 +308,7 @@ function extractCategory (doclet) { function extractChainable (doclet) { if (doclet.tags) { - const chainable = doclet.tags.reduce(extract({ title: 'chainable' }), []) + const chainable = extract(doclet.tags, t => t.title === 'chainable') if (chainable.length) doclet.chainable = true } return doclet diff --git a/package-lock.json b/package-lock.json index 8e674c2..c00bdbf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,9 +10,9 @@ "license": "MIT", "dependencies": { "array-back": "^6.2.2", + "find-replace": "^5.0.1", "lodash.omit": "^4.5.0", - "reduce-extract": "^1.0.0", - "sort-array": "^4.1.5", + "sort-array": "^5.0.0", "test-value": "^3.0.0" }, "devDependencies": { @@ -53,16 +53,6 @@ "node": ">=12.17" } }, - "node_modules/@test-runner/core/node_modules/typical": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", - "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.17" - } - }, "node_modules/@test-runner/default-view": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/@test-runner/default-view/-/default-view-0.6.1.tgz", @@ -121,16 +111,6 @@ "node": ">=12.17" } }, - "node_modules/@test-runner/tom/node_modules/typical": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", - "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.17" - } - }, "node_modules/ansi-escape-sequences": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/ansi-escape-sequences/-/ansi-escape-sequences-6.2.2.tgz", @@ -265,6 +245,19 @@ "node": ">=6" } }, + "node_modules/command-line-args/node_modules/find-replace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", + "integrity": "sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-back": "^3.0.1" + }, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/command-line-args/node_modules/typical": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", @@ -339,9 +332,9 @@ } }, "node_modules/current-module-paths": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/current-module-paths/-/current-module-paths-1.1.1.tgz", - "integrity": "sha512-8Ga5T8oMXBaSsHq9Gj+bddX7kHSaJKsl2vaAd3ep51eQLkr4W18eFEmEZM5bLo1zrz8tt3jE1U8QK9QGhaLR4g==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/current-module-paths/-/current-module-paths-1.1.2.tgz", + "integrity": "sha512-H4s4arcLx/ugbu1XkkgSvcUZax0L6tXUqnppGniQb8l5VjUKGHoayXE5RiriiPhYDd+kjZnaok1Uig13PKtKYQ==", "dev": true, "license": "MIT", "engines": { @@ -383,26 +376,15 @@ } }, "node_modules/find-replace": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", - "integrity": "sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==", - "dev": true, + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-5.0.1.tgz", + "integrity": "sha512-o5/Y8HrCNRuFF5rdNTkX8Vhv6kTFTV0t1zIoigwlCdbkA9qaapRzxvWPND2VvlFa9LBI05Q1i8ml/saMqkOJUQ==", "license": "MIT", "dependencies": { - "array-back": "^3.0.1" + "array-back": "^6.2.2" }, "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/find-replace/node_modules/array-back": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", - "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" + "node": ">=14" } }, "node_modules/fs.realpath": { @@ -556,49 +538,6 @@ "node": ">=14" } }, - "node_modules/reduce-extract": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/reduce-extract/-/reduce-extract-1.0.0.tgz", - "integrity": "sha512-QF8vjWx3wnRSL5uFMyCjDeDc5EBMiryoT9tz94VvgjKfzecHAVnqmXAwQDcr7X4JmLc2cjkjFGCVzhMqDjgR9g==", - "license": "MIT", - "dependencies": { - "test-value": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/reduce-extract/node_modules/array-back": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", - "integrity": "sha512-1WxbZvrmyhkNoeYcizokbmh5oiOCIfyvGtcqbK3Ls1v1fKcquzxnQSceOx6tzq7jmai2kFLWIpGND2cLhH6TPw==", - "license": "MIT", - "dependencies": { - "typical": "^2.6.0" - }, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/reduce-extract/node_modules/test-value": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/test-value/-/test-value-1.1.0.tgz", - "integrity": "sha512-wrsbRo7qP+2Je8x8DsK8ovCGyxe3sYfQwOraIY/09A2gFXU9DYKiTF14W4ki/01AEh56kMzAmlj9CaHGDDUBJA==", - "license": "MIT", - "dependencies": { - "array-back": "^1.0.2", - "typical": "^2.4.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/reduce-extract/node_modules/typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha512-ofhi8kjIje6npGozTip9Fr8iecmYfEbS06i0JnIg+rh51KakryWF4+jX8lLKZVhy6N+ID45WYSFCxPOdTWCzNg==", - "license": "MIT" - }, "node_modules/reduce-flatten": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/reduce-flatten/-/reduce-flatten-2.0.0.tgz", @@ -610,25 +549,24 @@ } }, "node_modules/sort-array": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/sort-array/-/sort-array-4.1.5.tgz", - "integrity": "sha512-Ya4peoS1fgFN42RN1REk2FgdNOeLIEMKFGJvs7VTP3OklF8+kl2SkpVliZ4tk/PurWsrWRsdNdU+tgyOBkB9sA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/sort-array/-/sort-array-5.0.0.tgz", + "integrity": "sha512-Sg9MzajSGprcSrMIxsXyNT0e0JB47RJRfJspC+7co4Z5BdNsNl8FmWI+lXEpyKq+vkMG6pHgAhqyCO+bkDTfFQ==", "license": "MIT", "dependencies": { - "array-back": "^5.0.0", - "typical": "^6.0.1" + "array-back": "^6.2.2", + "typical": "^7.1.1" }, "engines": { - "node": ">=10" - } - }, - "node_modules/sort-array/node_modules/array-back": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-5.0.0.tgz", - "integrity": "sha512-kgVWwJReZWmVuWOQKEOohXKJX+nD02JAZ54D1RRWlv8L0NebauKAaFxACKzB74RTclt1+WNz5KHaLRDAPZbDEw==", - "license": "MIT", - "engines": { - "node": ">=10" + "node": ">=12.17" + }, + "peerDependencies": { + "@75lb/nature": "^0.1.1" + }, + "peerDependenciesMeta": { + "@75lb/nature": { + "optional": true + } } }, "node_modules/string-length": { @@ -771,18 +709,18 @@ "license": "MIT" }, "node_modules/typical": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-6.0.1.tgz", - "integrity": "sha512-+g3NEp7fJLe9DPa1TArHm9QAA7YciZmWnfAqEaFrBihQ7epOv9i99rjtgb6Iz0wh3WuQDjsCTDfgRoGnmHN81A==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", + "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==", "license": "MIT", "engines": { - "node": ">=10" + "node": ">=12.17" } }, "node_modules/walk-back": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/walk-back/-/walk-back-5.1.0.tgz", - "integrity": "sha512-Uhxps5yZcVNbLEAnb+xaEEMdgTXl9qAQDzKYejG2AZ7qPwRQ81lozY9ECDbjLPNWm7YsO1IK5rsP1KoQzXAcGA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/walk-back/-/walk-back-5.1.1.tgz", + "integrity": "sha512-e/FRLDVdZQWFrAzU6Hdvpm7D7m2ina833gIKLptQykRK49mmCYHLHq7UqjPDbxbKLZkTkW1rFqbengdE3sLfdw==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 24136ac..75fd964 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,9 @@ }, "dependencies": { "array-back": "^6.2.2", + "find-replace": "^5.0.1", "lodash.omit": "^4.5.0", - "reduce-extract": "^1.0.0", - "sort-array": "^4.1.5", + "sort-array": "^5.0.0", "test-value": "^3.0.0" }, "devDependencies": {