helper
expand
Expand the system base type function
- Number
padLeft
Number1 "001" Number123 "23"
- String
firstUpperCase
'people'firstUpperCase People
firstLowerCase
'People'firstLowerCase people
label
"http://{0}/{1}"label"www.cmpp.com" "index.html" "http://www.cmpp.com/index.html"
replaceAll(reallyDo, replaceWith, ignoreCase)
- @reallyDo (String | RegExp) A string that is replaced
- @replaceWidth (String) Replace the string
- @ignoreCase (Boolean) Whether or not case is ignored
var str = "xxxXxxx"; console; //print aaaXaaaconsole; //print aaaaaaa
- Array
isRepeat
- Object
merge
merge two object property
var a = foo: 'foo'name:'a' b = bar: 'bar'name:'b' ; a;// => { foo: 'foo', bar: 'bar',name:'b' }
==Notice==
Object.assign has the similar features
trim
clean up empty attributes
var o = person: id: null name: 'pauly' age: 10 info: 'information' work: love: null year: 5 do: fire: 'fire' gun: null mall: book: null o; person: name: "pauly" age: 10 info: "information" work: year: 5 do: fire: "fire"
- Function
partial
similar the Function.bind, only the order of the parameters are different
{ console}; showArg45 //print 1,2,3,4,5 showArg45//print 4,5,1,2,3
- Promise
wrap(done)
- @done (Function) The done function
wrap the result {err,value}
{ var res = await { ; }; console; //=> {err:'error'}} ;
Promise.arouse(asyncFn)
promisify asyncFunction
{ return "infomation";} let promise = Promise;
type
var type = require('pz.helper').type;
name
console; //print Number
is${Type} : isString,isNumber,isBoolean ...
type //=> true