simple-human-ids
Advanced tools
Comparing version 2.0.2 to 2.0.3
{ | ||
"name": "simple-human-ids", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Generate human-readable ids from lists of easy-to-spell words", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -22,12 +22,17 @@ const shuffle = require( 'shuffle-array' ); | ||
const defaultAdjectives = require( '../data/adjectives' ); | ||
const defaultAdverbs = require( '../data/adverbs' ); | ||
const defaultNouns = require( '../data/nouns' ); | ||
const defaultVerbs = require( '../data/verbs' ); | ||
// Construct our lists with defaults | ||
function construct( numbers = generateNumbers(), adjectives = getList( 'adjectives' ), nouns = getList( 'nouns' ), | ||
verbs = getList( 'verbs' ), adverbs = getList( 'adverbs' ) ){ | ||
function construct( numbers = generateNumbers(), adjectives = defaultAdjectives, nouns = defaultNouns, | ||
verbs = defaultVerbs, adverbs = defaultAdverbs ){ | ||
// Guard against Null | ||
const numbersInternal = numbers != null ? numbers.slice(0) : generateNumbers(); | ||
const adjectivesInternal = guardNull( adjectives, 'adjectives' ); | ||
const nounsInternal = guardNull( nouns, 'nouns' ); | ||
const verbsInternal = guardNull( verbs, 'verbs' ); | ||
const adverbsInternal = guardNull( adverbs, 'adverbs' ); | ||
const adjectivesInternal = adjectives != null ? adjectives.slice(0) : defaultAdjectives.slice(0); | ||
const nounsInternal = nouns != null ? nouns.slice(0) : defaultNouns.slice(0); | ||
const verbsInternal = verbs != null ? verbs.slice(0) : defaultVerbs.slice(0); | ||
const adverbsInternal = adverbs != null ? adverbs.slice(0) : defaultAdverbs.slice(0); | ||
@@ -45,6 +50,2 @@ | ||
function guardNull( list, name ){ | ||
return list != null ? list.slice(0) : getList( name ); | ||
} | ||
function generateNumbers(){ | ||
@@ -65,23 +66,5 @@ | ||
let fs; | ||
let path; | ||
function getList( subject ){ | ||
// Import filesystem and path utilities if not already imported | ||
if( !fs ){ | ||
fs = require( 'fs' ); | ||
} | ||
if( !path ){ | ||
path = require( 'path' ); | ||
} | ||
const filePath = path.join( __dirname, '..', 'data', subject + '.txt' ); | ||
const file = fs.readFileSync( filePath, 'utf8' ); | ||
return file.trim().split( '\n' ); | ||
} | ||
module.exports.new = next; | ||
module.exports.configure = configure; | ||
module.exports.construct = construct; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10892
13
306
1
1