migrate from underscore to lodash

This commit is contained in:
Jeff Williams 2019-01-21 10:52:46 -08:00
parent 8d7a70c3f6
commit 3b8b0b479b
11 changed files with 20 additions and 31 deletions

2
cli.js
View File

@ -47,7 +47,7 @@ module.exports = (() => {
// TODO: docs
cli.loadConfig = () => {
const _ = require('underscore');
const _ = require('lodash');
const args = require('jsdoc/opts/args');
const Config = require('jsdoc/config');
let config;

View File

@ -1,7 +1,7 @@
/**
* @module jsdoc/doclet
*/
const _ = require('underscore');
const _ = require('lodash');
const jsdoc = {
env: require('jsdoc/env'),
name: require('jsdoc/name'),

View File

@ -2,7 +2,7 @@
* A collection of functions relating to JSDoc symbol name manipulation.
* @module jsdoc/name
*/
const _ = require('underscore');
const _ = require('lodash');
const escape = require('escape-string-regexp');
const hasOwnProp = Object.prototype.hasOwnProperty;

View File

@ -2,21 +2,16 @@
* Parse the command line arguments.
* @module jsdoc/opts/argparser
*/
const _ = require('underscore');
const util = require('util');
const _ = require('lodash');
const hasOwnProp = Object.prototype.hasOwnProperty;
function padding(length) {
return new Array(length + 1).join(' ');
}
function padLeft(str, length) {
return padding(length) + str;
return str.padStart(str.length + length);
}
function padRight(str, length) {
return str + padding(length);
return str.padEnd(str.length + length);
}
function findMaxLength(arr) {
@ -37,7 +32,7 @@ function concatWithMaxLength(items, maxLength) {
// to prevent endless loops, always use the first item, regardless of length
result += items.shift();
while ( items.length && (result.length + items[0].length < maxLength) ) {
while (items.length && (result.length + items[0].length < maxLength)) {
result += ` ${items.shift()}`;
}
@ -72,7 +67,7 @@ function formatHelpInfo({names, descriptions}) {
result += concatWithMaxLength(words, wrapDescriptionAt);
// if there's anything left, keep going until we've consumed the description
while (words.length) {
partialDescription = padding( maxNameLength + (MARGIN_LENGTH * 2) );
partialDescription = padLeft('', maxNameLength + (MARGIN_LENGTH * 2));
partialDescription += concatWithMaxLength(words, wrapDescriptionAt);
result += `\n${partialDescription}`;
}
@ -226,7 +221,7 @@ class ArgParser {
let arg;
let next;
let option;
const result = ( defaults && _.defaults({}, defaults) ) || {};
const result = (defaults && _.defaults({}, defaults)) || {};
let shortName;
let longName;
let name;
@ -252,7 +247,7 @@ class ArgParser {
}
if (option === null) {
throw new Error( util.format('Unknown command-line option "%s".', name) );
throw new Error(`Unknown command-line option "${name}".`);
}
if (option.hasValue) {
@ -260,7 +255,7 @@ class ArgParser {
i++;
if (value === null || value.charAt(0) === '-') {
throw new Error( util.format('The command-line option "%s" requires a value.', name) );
throw new Error(`The command-line option "${name}" requires a value.`);
}
}
else {

View File

@ -2,7 +2,7 @@
* Define tags that are known in JSDoc.
* @module jsdoc/tag/dictionary/definitions
*/
const _ = require('underscore');
const _ = require('lodash');
const jsdoc = {
env: require('jsdoc/env'),
name: require('jsdoc/name'),

View File

@ -2,7 +2,7 @@
* Wrapper for underscore's template utility to allow loading templates from files.
* @module jsdoc/template
*/
const _ = require('underscore');
const _ = require('lodash');
const fs = require('jsdoc/fs');
const path = require('path');

8
package-lock.json generated
View File

@ -5864,8 +5864,7 @@
"lodash": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
"dev": true
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
},
"lodash._reinterpolate": {
"version": "3.0.0",
@ -9858,11 +9857,6 @@
"integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=",
"dev": true
},
"underscore": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz",
"integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg=="
},
"underscore-contrib": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz",

View File

@ -1,7 +1,7 @@
{
"name": "jsdoc",
"version": "4.0.0-dev",
"revision": "1547932905034",
"revision": "1548096695580",
"description": "An API documentation generator for JavaScript.",
"keywords": [
"documentation",
@ -21,14 +21,14 @@
"escape-string-regexp": "~1.0.5",
"js2xmlparser": "~3.0.0",
"klaw": "~3.0.0",
"lodash": "^4.17.11",
"markdown-it": "~8.4.2",
"markdown-it-anchor": "~5.0.2",
"marked": "~0.6.0",
"mkdirp": "~0.5.1",
"requizzle": "~0.2.1",
"strip-json-comments": "~2.0.1",
"taffydb": "2.6.2",
"underscore": "~1.9.1"
"taffydb": "2.6.2"
},
"devDependencies": {
"ajv": "~6.7.0",

View File

@ -3,7 +3,7 @@
*
* @module plugins/eventDumper
*/
const _ = require('underscore');
const _ = require('lodash');
const doop = require('jsdoc/util/doop');
const dump = require('jsdoc/util/dumper').dump;
const env = require('jsdoc/env');

View File

@ -1,6 +1,6 @@
'use strict';
var _ = require('underscore');
var _ = require('lodash');
/**
* Socket class.

View File

@ -1,6 +1,6 @@
describe('jsdoc/doclet', () => {
// TODO: more tests
const _ = require('underscore');
const _ = require('lodash');
const jsdoc = {
doclet: require('jsdoc/doclet')
};