NodeJS module generator/boilerplate.
- Babel - Write next generation JavaScript today;
- Jest - JavaScript testing framework used by Facebook;
- ESLint - Make sure you are writing a quality code;
- Flow - A static type checker for JavaScript used heavily within Facebook;
- Travis CI - Automate tests and linting for every push or pull request;
- Documentation - A documentation system so good, you'll actually write documentation.
The easiest way to use nod is through the Yeoman Generator.
$ npm install -g yo generator-nod
$ yo nod
If you don't want to use the generator, you can also download or git clone
this repo
$ git clone https://github.com/diegohaz/nod my-module
$ cd my-module
$ rm -rf .git
$ npm install # or yarn
Just make sure to edit package.json
, README.md
and LICENSE
files accordingly with your module's info.
$ npm test # run tests with Jest
$ npm run coverage # run tests with coverage and open it on browser
$ npm run lint # lint code
$ npm run docs # generate docs
$ npm run build # generate docs and transpile code
$ npm run watch # watch code changes and run scripts automatically
$ npm run patch # bump patch version and publish to npm e.g. 0.0.1
$ npm run minor # bump minor version and publish to npm e.g. 0.1.0
$ npm run major # bump major version and publish to npm e.g. 1.0.0
You can use those modules as a reference when creating yours. If you have built something with Nod, send a PR (try to write a helpful description for Nod users).
- styled-tools - Module using
flow-typed
, targeted to browser. - styled-theme - Module with
gh-pages
, targeted to browser. - webpack-blocks-happypack - Uses Jest snapshots.
- webpack-blocks-split-vendor - Has peer dependencies.
Check if a variable is an array
Parameters
variable
any
Shallow check if two arrays are equal not just in content but also in order
Parameters
Returns boolean
Find a value in an array of objects
Parameters
key
string the name of the specific key to searchvalue
any the value you need to findarr
Array the array of objects
Returns {}
Find a value in an array of node objects
Parameters
key
string the name of the specific key to searchvalue
any the value you need to findarr
Array the array of objects
Returns ({} | undefined | boolean)
Helper function with shorter syntax with type coercion
Parameters
key
anyarr
Array
Returns {}
Find an index in an array of node objects
Parameters
key
string the name of the specific key to searchvalue
any the value you need to findarr
Array the array of objects
Find the index of a value in an array of objects
Parameters
value
anyarr
array
Returns number
Check if value is in array
Parameters
value
anyarr
array
Returns boolean
Get the intersection data from two primitive arrays
Parameters
Returns array
Return index of array otherwise false
Parameters
value
anyarr
array
Returns (number | bool)
Make an array unique
Parameters
arr
Array
Returns Array arr
Returns the length of array, skips undefined
type from the count
Parameters
arr
Array
Returns Number
This function says hello.
Parameters
name
string Some name to say hello for.
Returns string The hello.
Checks if an object is empty Do note that an empty object in javascript is a truthy value, so we have to use this function to check for an empty object
Parameters
obj
Returns any boolean
Duck-typing to check if a key is trying to access a nested value
Parameters
key
string
Returns boolean
Key-path accessor to get value from nested object
Parameters
obj
{} the nested objectedpath
string @example 'foo.bar'
Returns any
Check if a key exists in an object Note; if key exist, but value is null, returns true.
Parameters
obj
{}key
string
Returns Boolean
Access a node object with an undetermined nested or single key
Parameters
node
{}key
string
Returns any
Check if a variable is an Object
Parameters
v
any
Returns boolean
Check if a variable is a function
Parameters
v
any
Returns boolean
Get object from JSON string
Parameters
json
string
Returns {}
Get JSON string from object
Parameters
obj
{}
Returns string
Get JSON From key and value
Parameters
k
anyv
any
Returns string
Returns a substring between a set of start and end characters
Parameters
Returns string
Returns a substring before the last occurence of a character
Parameters
Returns string
Returns a substring after the last occurence of a character
Parameters
Returns string
Converts underscores to spaces
Parameters
str
string
Returns string
Capitalize the first letter of a string
Parameters
str
string
Convert camel case to sentence
Parameters
str
string
MIT © Diego Haz