1.3.1 • Published 9 years ago
chili-js v1.3.1
ChiliJs
Usefuls variables for node env.
## Install NPM
$ npm install chili-js --saveYarn
$ yarn add chili-jsFeatures / API
Path
#### Shortcuts
path.join()=>join()path.parse()=>parse()path.normalize()=>normalize()path.relative()=>relative_path()path.sep=>separator
#### Functions
String.prototype.relativeTo()It returnspath.relative(pth1, pth2)aspth1.relativeTo(pth2)```js require('chili-js'); join( home, 'Desktop', 'myFolder' ).relativeTo( join(home, 'Documents') ); //=> ../../Documents ```
JSON Shortcuts
JSON.jparse()=>jparse()JSON.jstringify()=>jstringify()
Console Shortcuts
console.log()=>log()console.warn()=>warn()console.error()=>err()
FS Shortcuts
fs.writeFile()=>write()fs.writeFileSync()=>writeSync()fs.readFile()=>read()fs.readFileSync()=>readSync()
Variables
home who is the /Users/<user>/ (~ path)
and user who is the <user> in ~ path.
Standalone Functions
String.prototype.capitalize(divider, joiner)This function provides to
capitalizea word.... 'hello world'.capitalize() //=> 'Hello World'It can also parse a word
... 'hello-world'.capitalize('-') //=> 'Hello-World' 'hello-world'.capitalize('-', ' ') //=> 'Hello World' 'hello world'.capitalize(' ', '-') //=> Hello-WorldArray.prototype.sum()This function provides to
sumall items in array... [1, 2, 3].sum() //=> 6If an item in
arrayis not a number it will be ignored.... ['a', 15, 'b', 5, 'c'].sum() //=> 20