New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

project-name-generator

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

project-name-generator - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

.nvmrc

12

package.json
{
"name": "project-name-generator",
"version": "2.1.2",
"version": "2.1.3",
"description": "Generate a random, unique, heroku-like name for your app/project/server etc. e.g. \"resonant-silence\"",
"main": "src/generator.js",
"scripts": {
"test": "gulp test"
"test": "./node_modules/mocha/bin/mocha **/*.spec.js"
},

@@ -28,7 +28,7 @@ "repository": {

"devDependencies": {
"gulp": "^3.8.10",
"gulp-jasmine": "^1.0.1"
"mocha": "^3.0.2",
"must": "^0.13.2"
},
"dependencies": {
"lodash": "^3.1.0"
"lodash": "^4.14.2"
},

@@ -38,2 +38,2 @@ "bin": {

}
}
}

@@ -7,5 +7,2 @@ # Project Name Generator

##Note
This version introduces some breaking changes - please see the [tag 1.0.0](https://github.com/aceakash/project-name-generator/releases/tag/1.0.0) for the older version.
##Install

@@ -30,2 +27,4 @@ `npm install project-name-generator --save`

generate({ words: 2, alliterative: true }).spaced; // 'elegant experience'
```

@@ -49,2 +48,3 @@

* **number** (boolean) - Whether a numeric suffix is generated or not. The number is between 1 - 9999, both inclusive. Defaults to **false**.
* **alliterative** (boolean) - Whether to output words beginning with the same letter or not. Defaults to **false**.

@@ -69,2 +69,11 @@ `generate({ words: 3 })` will return:

`generate({ words: 2, number: false, alliterative: true })` will return:
```javascript
{
raw: [ 'elegant', 'experience' ],
dashed: 'elegant-experience',
spaced: 'elegant experience'
}
```
##Tests

@@ -78,4 +87,5 @@ To run tests locally:

The library has been tested with Node.js 4.2.6
##Build Status
![Build status](https://codeship.com/projects/c049a9a0-7fa1-0132-a98e-66b1976afe6a/status?branch=master)
var _ = require('lodash'),
nouns = require('../src/nouns'),
adjectives = require('../src/adjectives'),
generate = require('../src/generator');
generate = require('../src/generator'),
expect = require('must');
describe('generator', function () {
it('has a generate function', function () {
expect(typeof generate).toBe('function');
expect(generate).to.be.a(Function);
});

@@ -20,28 +21,28 @@

it('returns an object with keys: dashed, spaced, raw', function () {
expect(projName).toBeDefined();
expect(projName.dashed).toBeDefined();
expect(projName.spaced).toBeDefined();
expect(projName.raw).toBeDefined();
expect(projName).to.not.be.undefined();
expect(projName.dashed).to.not.be.undefined();
expect(projName.spaced).to.not.be.undefined();
expect(projName.raw).to.not.be.undefined();
});
it('has a property raw which is an array of two strings', function () {
expect(projName.raw.length).toBe(2);
expect(typeof projName.raw[0]).toBe('string');
expect(typeof projName.raw[1]).toBe('string');
expect(projName.raw.length).to.be(2);
expect(typeof projName.raw[0]).to.be('string');
expect(typeof projName.raw[1]).to.be('string');
});
it('has an array raw, the first item of which is from the adjectives array', function () {
expect(_.contains(adjectives, projName.raw[0])).toBe(true);
expect(_.includes(adjectives, projName.raw[0])).to.be(true);
});
it('has an array raw, the second item of which is from the nouns array', function () {
expect(_.contains(nouns, projName.raw[1])).toBe(true);
expect(_.includes(nouns, projName.raw[1])).to.be(true);
});
it("has a property dashed, which is a string of raw's items joined with a dash", function () {
expect(projName.dashed).toBe(projName.raw.join('-'));
expect(projName.dashed).to.be(projName.raw.join('-'));
});
it("has a property spaced, which is a string of raw's items joined with a space", function () {
expect(projName.spaced).toBe(projName.raw.join(' '));
expect(projName.spaced).to.be(projName.raw.join(' '));
});

@@ -55,5 +56,5 @@ });

projName = generate({});
expect(projName.raw.length).toBe(2);
expect(typeof projName.raw[0]).toBe('string');
expect(typeof projName.raw[1]).toBe('string');
expect(projName.raw.length).to.be(2);
expect(typeof projName.raw[0]).to.be('string');
expect(typeof projName.raw[1]).to.be('string');
});

@@ -63,6 +64,6 @@

projName = generate({number: true});
expect(projName.raw.length).toBe(3);
expect(typeof projName.raw[0]).toBe('string');
expect(typeof projName.raw[1]).toBe('string');
expect(typeof projName.raw[2]).toBe('number');
expect(projName.raw.length).to.be(3);
expect(typeof projName.raw[0]).to.be('string');
expect(typeof projName.raw[1]).to.be('string');
expect(typeof projName.raw[2]).to.be('number');
});

@@ -72,14 +73,14 @@

projName = generate({words: 3});
expect(projName.raw.length).toBe(3);
expect(_.contains(adjectives, projName.raw[0])).toBe(true);
expect(_.contains(adjectives, projName.raw[1])).toBe(true);
expect(_.contains(nouns, projName.raw[2])).toBe(true);
expect(projName.raw.length).to.be(3);
expect(_.includes(adjectives, projName.raw[0])).to.be(true);
expect(_.includes(adjectives, projName.raw[1])).to.be(true);
expect(_.includes(nouns, projName.raw[2])).to.be(true);
projName = generate({words: 5});
expect(projName.raw.length).toBe(5);
expect(_.contains(adjectives, projName.raw[0])).toBe(true);
expect(_.contains(adjectives, projName.raw[1])).toBe(true);
expect(_.contains(adjectives, projName.raw[2])).toBe(true);
expect(_.contains(adjectives, projName.raw[3])).toBe(true);
expect(_.contains(nouns, projName.raw[4])).toBe(true);
expect(projName.raw.length).to.be(5);
expect(_.includes(adjectives, projName.raw[0])).to.be(true);
expect(_.includes(adjectives, projName.raw[1])).to.be(true);
expect(_.includes(adjectives, projName.raw[2])).to.be(true);
expect(_.includes(adjectives, projName.raw[3])).to.be(true);
expect(_.includes(nouns, projName.raw[4])).to.be(true);
});

@@ -89,8 +90,16 @@

projName = generate({words: 3, number: true});
expect(projName.raw.length).toBe(4);
expect(_.contains(adjectives, projName.raw[0])).toBe(true);
expect(_.contains(adjectives, projName.raw[1])).toBe(true);
expect(_.contains(nouns, projName.raw[2])).toBe(true);
expect(typeof projName.raw[3]).toBe('number');
expect(projName.raw.length).to.be(4);
expect(_.includes(adjectives, projName.raw[0])).to.be(true);
expect(_.includes(adjectives, projName.raw[1])).to.be(true);
expect(_.includes(nouns, projName.raw[2])).to.be(true);
expect(typeof projName.raw[3]).to.be('number');
});
it('with {words: 2, number: false, alliterative: true}, has 1 adjective and 1 noun beginning with same letter', function() {
projName = generate({words: 2, number: false, alliterative: true});
expect(projName.raw.length).to.be(2);
expect(_.includes(adjectives, projName.raw[0])).to.be(true);
expect(_.includes(nouns, projName.raw[1])).to.be(true);
expect(projName.raw[0].substring(0, 1).toLowerCase() === projName.raw[1].substring(0, 1).toLowerCase()).to.be(true);
});
});

@@ -102,7 +111,7 @@ });

var name = require('../src/generator').generate();
expect(name.dashed).toBeDefined();
expect(name.spaced).toBeDefined();
expect(name.raw).toBeDefined();
expect(name.dashed).to.not.be.undefined();
expect(name.spaced).to.not.be.undefined();
expect(name.raw).to.not.be.undefined();
});
});
});
var _ = require('lodash'),
nouns = require('../src/nouns'),
adjectives = require('../src/adjectives'),
helpers = require('./spec-helpers');
helpers = require('./spec-helpers'),
expect = require('must');

@@ -11,7 +12,7 @@ describe('nouns', stringArrayTestSuite.bind(this, nouns));

it('is an array', function () {
expect(helpers.isArray(collection)).toBe(true);
expect(helpers.isArray(collection)).to.be(true);
});
it('has at least one item', function () {
expect(collection.length).toBeGreaterThan(0);
expect(collection.length).to.be.gt(0);
});

@@ -23,19 +24,19 @@

});
expect(everyItemIsAString).toBe(true);
expect(everyItemIsAString).to.be(true);
});
it('has every item with no spaces', function () {
var anyItemWithSpaces = _.any(collection, function (item) {
var anyItemWithSpaces = _.some(collection, function (item) {
return item.indexOf(' ') !== -1;
});
expect(anyItemWithSpaces).toBe(false);
expect(anyItemWithSpaces).to.be(false);
});
it('has every item with no dashes', function () {
var anyItemWithDashes = _.any(collection, function (item) {
var anyItemWithDashes = _.some(collection, function (item) {
return item.indexOf('-') !== -1;
});
expect(anyItemWithDashes).toBe(false);
expect(anyItemWithDashes).to.be(false);
});
}

@@ -13,2 +13,3 @@ #! /usr/bin/env node

var spaced = false;
var alliterative = false;
for (x=0; x<args.length; x++){

@@ -38,6 +39,10 @@ switch(args[x]){

break;
case "-a":
case "--alliterative":
alliterative = true;
break;
}
}
var project_name = generate({words: words, number: number});
var project_name = generate({words: words, number: number, alliterative: alliterative});

@@ -44,0 +49,0 @@ if (dashed){

@@ -12,3 +12,4 @@ var _ = require('lodash'),

number: false,
words: 2
words: 2,
alliterative: false,
};

@@ -29,6 +30,13 @@ options = _.merge(defaults, options || {});

_.times(options.words - 1, function () {
raw.push(_.sample(adjectives).toLowerCase());
if (options.alliterative && raw.length)
raw.push(_.sample(getAlliterativeMatches(adjectives, raw[0].substring(0, 1))));
else
raw.push(_.sample(adjectives).toLowerCase());
});
raw.push(_.sample(nouns).toLowerCase());
if (options.alliterative)
raw.push(_.sample(getAlliterativeMatches(nouns, raw[0].substring(0, 1))));
else
raw.push(_.sample(nouns).toLowerCase());
if (options.number) {

@@ -39,1 +47,6 @@ raw.push(_.random(1, 9999));

}
function getAlliterativeMatches(arr, letter) {
var check = letter.toLowerCase();
return _.filter(arr, function(elm) { return elm.substring(0, 1).toLowerCase() === check; });
}

@@ -278,3 +278,2 @@ module.exports = [

"finger",
"finger",
"fire",

@@ -281,0 +280,0 @@ "fireman",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc