积累一些常用的npmjs库
注:编写md文档请参考《Markdown 入门参考》
A javascript library for formatting and manipulating numbers.
$ npm install numeral --save
A node.js package for Steven Levithan's excellent dateFormat() function.
$ npm install dateformat
$ dateformat --help
版本号工具
$ npm install semver
$ node
var semver = require('semver')
semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
semver.clean(' =v1.2.3 ') // '1.2.3'
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
semver.gt('1.2.3', '9.8.7') // false
semver.lt('1.2.3', '9.8.7') // true
Convert a dash/dot/underscore/space separated string to camelCase:
foo-bar
→fooBar
$ npm install --save camelcase
const camelCase = require('camelcase');
camelCase('foo-bar');
//=> 'fooBar'
camelCase('foo_bar');
//=> 'fooBar'
camelCase('Foo-Bar');
//=> 'fooBar'
camelCase('--foo.bar');
//=> 'fooBar'
camelCase('__foo__bar__');
//=> 'fooBar'
camelCase('foo bar');
//=> 'fooBar'
console.log(process.argv[3]);
//=> '--foo-bar'
camelCase(process.argv[3]);
//=> 'fooBar'
camelCase('foo', 'bar');
//=> 'fooBar'
camelCase('__foo__', '--bar');
//=> 'fooBar'
Convert a camelized string into a lowercased one with a custom separator
Example:unicornRainbow
→unicorn_rainbow
$ npm install --save decamelize
const decamelize = require('decamelize');
decamelize('unicornRainbow');
//=> 'unicorn_rainbow'
decamelize('unicornRainbow', '-');
//=> 'unicorn-rainbow'
Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with Node.js and installable via npm install --save async
, it can also be used directly in the browser.
For Documentation, visit https://caolan.github.io/async/
For Async v1.5.x documentation, go HERE
https://github.com/caolan/async.git
https://github.com/lodash/lodash
Lodash makes JavaScript easier by taking the hassle out of working with arrays,
numbers, objects, strings, etc. Lodash’s modular methods are great for:
- Iterating arrays, objects, & strings
- Manipulating & testing values
- Creating composite functions
Underscore.js is a utility-belt library for JavaScript that provides support for the usual functional suspects (each, map, reduce, filter...) without extending any core JavaScript objects.
Terminal string styling done right
https://github.com/chalk/chalk.git
colors.js used to be the most popular string styling module, but it has serious deficiencies like extending String.prototype
which causes all kinds of problems. Although there are other ones, they either do too much or not enough.
Chalk is a clean and focused alternative.
$ npm install chalk
const chalk = require('chalk');
console.log(chalk.blue('Hello world!'));
node.js 命令行接口的完整解决方案,灵感来自 Ruby 的 commander。
$ npm install commander