1 | # node-lei-utils
|
2 |
|
3 | 安装
|
4 |
|
5 | ```bash
|
6 | $ npm install lei-utils --save
|
7 | ```
|
8 |
|
9 |
|
10 | 一些常用的工具函数
|
11 |
|
12 | + `bugfree (doNotOutput)`
|
13 | + `format (f)`
|
14 | + `sha1 (text)`
|
15 | + `md5 (text)`
|
16 | + `fileSha1 (filename, callback)`
|
17 | + `fileMd5 (filename, callback)`
|
18 | + `hash (method, text)`
|
19 | + `encryptPassword (password)`
|
20 | + `validatePassword (password, encrypted)`
|
21 | + `encryptData (data, secret)`
|
22 | + `decryptData (str, secret)`
|
23 | + `randomString (size, chars)`
|
24 | + `randomNumber (size)`
|
25 | + `randomLetter (size)`
|
26 | + `date (format, timestamp)`
|
27 | + `noop (err)`
|
28 | + `isString (str)`
|
29 | + `isInteger (str)`
|
30 | + `isNumber (str)`
|
31 | + `cloneObject (obj)`
|
32 | + `merge ()`
|
33 | + `jsonStringify (data, space)`
|
34 | + `argumentsToArray (args)`
|
35 | + `getArrayLastItem (arr)`
|
36 | + `throttleAsync (fn, maxCount)`
|
37 | + `inheritsEventEmitter (fn)`
|
38 | + `inherits (fn, superConstructor)`
|
39 | + `extend (obj)`
|
40 | + `extends (obj)`
|
41 | + `array`
|
42 | + `last (arr)`
|
43 | + `head (arr)`
|
44 | + `first (arr)`
|
45 | + `rest (arr)`
|
46 | + `copy (arr)`
|
47 | + `concat ()`
|
48 | + `customError (name, info)`
|
49 | + `isPromise (p)`
|
50 | + `promise`
|
51 | + `call (fn)`
|
52 | + `all (_args)`
|
53 | + `ipToInt (ip)`
|
54 | + `toBuffer (data)`
|
55 | + `encrypt (algorithm, key, data)`
|
56 | + `encryptStream (algorithm, key, inStream)`
|
57 | + `decrypt (algorithm, key, data)`
|
58 | + `decryptStream (algorithm, key, inStream)`
|
59 | + `hashTransform (method, callback)`
|
60 | + `createPromiseCallback ()`
|
61 |
|
62 |
|
63 |
|
64 | # License
|
65 |
|
66 | ```
|
67 | The MIT License (MIT)
|
68 |
|
69 | Copyright (c) 2014-2015 老雷
|
70 |
|
71 | Permission is hereby granted, free of charge, to any person obtaining a copy
|
72 | of this software and associated documentation files (the "Software"), to deal
|
73 | in the Software without restriction, including without limitation the rights
|
74 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
75 | copies of the Software, and to permit persons to whom the Software is
|
76 | furnished to do so, subject to the following conditions:
|
77 |
|
78 | The above copyright notice and this permission notice shall be included in all
|
79 | copies or substantial portions of the Software.
|
80 |
|
81 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
82 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
83 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
84 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
85 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
86 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
87 | SOFTWARE.
|
88 | ```
|