Skip to content

cuihandong/npm-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

npm-util

积累一些常用的npmjs库

注:编写md文档请参考《Markdown 入门参考》

目录

格式类

numeral

A javascript library for formatting and manipulating numbers.

安装

$ npm install numeral --save

dateformat

A node.js package for Steven Levithan's excellent dateFormat() function.

Installation

$ npm install dateformat
$ dateformat --help

semver

版本号工具

Usage

$ 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

camelcase

Convert a dash/dot/underscore/space separated string to camelCase: foo-barfooBar

Install

$ npm install --save camelcase

Usage

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'

decamelize

Convert a camelized string into a lowercased one with a custom separator
Example: unicornRainbowunicorn_rainbow

Install

$ npm install --save decamelize

Usage

const decamelize = require('decamelize');

decamelize('unicornRainbow');
//=> 'unicorn_rainbow'

decamelize('unicornRainbow', '-');
//=> 'unicorn-rainbow'

程序流

async

Async Logo

Build Status via Travis CI NPM version Coverage Status Join the chat at https://gitter.im/caolan/async libhive - Open source examples

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


lodash

Site | Docs | FP Guide

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

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.


chalk



chalk


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.

Install

$ npm install chalk

Usage

const chalk = require('chalk');

console.log(chalk.blue('Hello world!'));

Commander.js

NPM Version NPM Downloads

node.js 命令行接口的完整解决方案,灵感来自 Ruby 的 commander

安装

$ npm install commander

About

积累一些常用的npmjs库

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published