|
7 | 7 | [](https://www.npmjs.com/package/metautil) |
8 | 8 | [](https://github.com/metarhia/metautil/blob/master/LICENSE) |
9 | 9 |
|
10 | | -## Contributors |
| 10 | +## Usage |
11 | 11 |
|
12 | | -See github for full [contributors list](https://github.com/metarhia/metautil/graphs/contributors) |
| 12 | +- Install: `npm install metautil` |
| 13 | +- Require: `const metautil = require('metautil');` |
| 14 | + |
| 15 | +## Common utilities |
| 16 | + |
| 17 | +- `random(min: number, max?: number): number` |
| 18 | +- `sample(arr: Array<any>): any` |
| 19 | +- `ipToInt(ip?: string): number` |
| 20 | +- `parseHost(host?: string): string` |
| 21 | +- `parseParams(params: string): object` |
| 22 | +- `replace(str: string, substr: string, newstr: string): string` |
| 23 | +- `split(s: string, separator: string): [string, string]` |
| 24 | +- `fileExt(fileName: string): string` |
| 25 | +- `between(s: string, prefix: string, suffix: string): string` |
| 26 | +- `isFirstUpper(s: string): boolean` |
| 27 | +- `toLowerCamel(s: string): string` |
| 28 | +- `toUpperCamel(s: string): string` |
| 29 | +- `isConstant(s: string): boolean` |
| 30 | +- `nowDate(date?: Date): string` |
| 31 | +- `duration(s: string | number): number` |
| 32 | +- `makePrivate(instance: object): object` |
| 33 | +- `protect(allowMixins: Array<string>, ...namespaces: Array<object>): void` |
| 34 | +- `parseCookies(cookie: string): object` |
| 35 | +- `createAbortController(): AbortController` |
| 36 | +- `timeout(msec: number, signal?: EventEmitter): Promise<void>` |
| 37 | +- `delay(msec: number, signal?: EventEmitter): Promise<void>` |
| 38 | + |
| 39 | +## Crypto utilities |
| 40 | + |
| 41 | +- `cryptoRandom(): number` |
| 42 | +- `generateKey(length: number, possible: string): string` |
| 43 | +- `crcToken(secret: string, key: string): string` |
| 44 | +- `generateToken(secret: string, characters: string, length: number): string` |
| 45 | +- `validateToken(secret: string, token: string): boolean` |
| 46 | +- `hashPassword(password: string): Promise<string>` |
| 47 | +- `validatePassword(password: string, serHash: string): Promise<boolean>` |
| 48 | + |
| 49 | +## Async abstractions |
| 50 | + |
| 51 | +- `new Semaphore(concurrency: number, size?: number, timeout?: number)` |
| 52 | + |
| 53 | +## License & Contributors |
| 54 | + |
| 55 | +Copyright (c) 2017-2021 [Metarhia contributors](https://github.com/metarhia/metautil/graphs/contributors). |
| 56 | +Metautil is [MIT licensed](./LICENSE).\ |
| 57 | +Metautil is a part of [Metarhia](https://github.com/metarhia) technology stack. |
0 commit comments