@poppinss/utils
Advanced tools
Comparing version 2.1.3 to 2.2.0
@@ -0,3 +1,5 @@ | ||
export { base64 } from './src/base64'; | ||
export * as lodash from './src/lodash'; | ||
export { Exception } from './src/Exception'; | ||
export { safeEqual } from './src/safeEqual'; | ||
export { fsReadAll } from './src/fsReadAll'; | ||
@@ -8,1 +10,2 @@ export { requireAll } from './src/requireAll'; | ||
export { resolveFrom } from './src/resolveFrom'; | ||
export { randomString } from './src/randomString'; |
@@ -18,5 +18,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var base64_1 = require("./src/base64"); | ||
exports.base64 = base64_1.base64; | ||
exports.lodash = __importStar(require("./src/lodash")); | ||
var Exception_1 = require("./src/Exception"); | ||
exports.Exception = Exception_1.Exception; | ||
var safeEqual_1 = require("./src/safeEqual"); | ||
exports.safeEqual = safeEqual_1.safeEqual; | ||
var fsReadAll_1 = require("./src/fsReadAll"); | ||
@@ -32,1 +36,3 @@ exports.fsReadAll = fsReadAll_1.fsReadAll; | ||
exports.resolveFrom = resolveFrom_1.resolveFrom; | ||
var randomString_1 = require("./src/randomString"); | ||
exports.randomString = randomString_1.randomString; |
{ | ||
"name": "@poppinss/utils", | ||
"version": "2.1.3", | ||
"version": "2.2.0", | ||
"description": "Handy utilities for repetitive work", | ||
@@ -32,3 +32,3 @@ "main": "build/index.js", | ||
"@adonisjs/fold": "^6.2.3", | ||
"@adonisjs/mrm-preset": "^2.2.4", | ||
"@adonisjs/mrm-preset": "^2.3.0", | ||
"@poppinss/dev-utils": "^1.0.4", | ||
@@ -35,0 +35,0 @@ "@types/node": "^13.11.0", |
@@ -21,2 +21,9 @@ # Utils | ||
- [Exported methods](#exported-methods) | ||
- [Base 64 Encode/Decode](#base-64-encodedecode) | ||
- [encode](#encode) | ||
- [decode](#decode) | ||
- [urlEncode](#urlencode) | ||
- [urlDecode](#urldecode) | ||
- [Random String](#random-string) | ||
- [Safe equal](#safe-equal) | ||
@@ -179,3 +186,45 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
## Base 64 Encode/Decode | ||
Following helpers for base64 encoding/decoding also exists. | ||
#### encode | ||
```ts | ||
import { base64 } from '@poppinss/utils' | ||
base64.encode('hello world') | ||
base64.encode(Buffer.from('hello world', 'binary')) | ||
``` | ||
#### decode | ||
```ts | ||
import { base64 } from '@poppinss/utils' | ||
base64.decode(base64.encode('hello world')) | ||
base64.decode(base64.encode(Buffer.from('hello world', 'binary')), 'binary') | ||
``` | ||
#### urlEncode | ||
Same as `encode`, but safe for URLS and Filenames | ||
#### urlDecode | ||
Same as `decode`, but decodes the `urlEncode` output values | ||
## Random String | ||
A helper to generate random strings of a given length. Uses `crypto` under the hood. | ||
```ts | ||
import { randomString } from '@poppinss/utils' | ||
randomString(32) | ||
randomString(128) | ||
``` | ||
## Safe equal | ||
Compares two values by avoid [timing attack](https://en.wikipedia.org/wiki/Timing_attack). Accepts any input that can be passed to `Buffer.from` | ||
```ts | ||
import { safeValue } from '@poppinss/utils' | ||
if (safeValue('foo', 'foo')) { | ||
} | ||
``` | ||
[circleci-image]: https://img.shields.io/circleci/project/github/poppinss/utils/master.svg?style=for-the-badge&logo=circleci | ||
@@ -182,0 +231,0 @@ [circleci-url]: https://circleci.com/gh/poppinss/utils "circleci" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49048
26
572
239