@appliedblockchain/helpers
Advanced tools
Comparing version 2.6.3 to 2.6.4
@@ -9,3 +9,3 @@ // @flow | ||
function defaultCmp(x /*: any */, y /*: any */) /*: -1 | 0 | 1 */ { | ||
return x == y ? | ||
return x === y ? | ||
0 : | ||
@@ -12,0 +12,0 @@ x < y ? -1 : 1 |
@@ -28,2 +28,4 @@ // @flow | ||
for (let i = 0; i < promises.length; i++) { | ||
// eslint-disable-next-line no-loop-func | ||
yield await new Promise(resolve => { | ||
@@ -30,0 +32,0 @@ if (results.length) { |
@@ -0,1 +1,3 @@ | ||
/* eslint-disable no-param-reassign */ | ||
// Unrolled f1600 based on https://github.com/emn178/js-sha3 Chen, Yi-Cyuan, MIT | ||
@@ -2,0 +4,0 @@ |
// @flow | ||
/* eslint-disable new-cap */ | ||
@@ -3,0 +4,0 @@ const { inspect } = require('util') |
@@ -7,3 +7,2 @@ // @flow | ||
const hexOfBuffer = require('./hex-of-buffer') | ||
const hexOfHex0x = require('./hex-of-hex0x') | ||
const publicKeyOfPrivateKey = require('./public-key-of-private-key') | ||
@@ -10,0 +9,0 @@ const addressOfPublicKey = require('./address-of-public-key') |
@@ -5,3 +5,2 @@ // @flow | ||
const rejectTimeout = require('./reject-timeout') | ||
const numberOfHex0x = require('./number-of-hex0x') | ||
const logOf = require('./log-of') | ||
@@ -8,0 +7,0 @@ |
// @flow | ||
/** Captures extra stack trace, usage `await foo().catch(makeRetrace())`. */ | ||
/** Captures extra stack trace, usage `await foo().catch(makeRetrace())`. | ||
`err` argument is being modified with new stack value. */ | ||
function makeRetrace() { | ||
@@ -8,2 +9,4 @@ const captured = {} | ||
return (err /*: Error */) => { | ||
// eslint-disable-next-line no-param-reassign | ||
err.stack = [ | ||
@@ -10,0 +13,0 @@ ...err.stack.split('\n'), |
@@ -11,2 +11,4 @@ // @flow | ||
.reduce((r, [ k, v ]) => { | ||
// eslint-disable-next-line no-param-reassign | ||
r[k] = f(v, k, value) | ||
@@ -13,0 +15,0 @@ return r |
@@ -27,3 +27,3 @@ // @flow | ||
if (!meta) { | ||
throw new TypeError(`Expected meta.`) | ||
throw new TypeError('Expected meta.') | ||
} | ||
@@ -30,0 +30,0 @@ meta[key] = value |
{ | ||
"name": "@appliedblockchain/helpers", | ||
"version": "2.6.3", | ||
"version": "2.6.4", | ||
"description": "No dependency, single file helpers.", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"doc": "npx documentation readme --section=Api *.js", | ||
"test": "npx flow check && npx jest", | ||
"test": "flow check && eslint . && jest", | ||
"patch": "npm test && npm version patch && git push && git push --tags && npm publish", | ||
@@ -21,3 +21,23 @@ "minor": "npm test && npm version minor && git push && git push --tags && npm publish" | ||
] | ||
} | ||
}, | ||
"devDependencies": { | ||
"@appliedblockchain/eslint-config": "2.6.0", | ||
"eslint": "5.16.0", | ||
"flow-bin": "0.101.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@appliedblockchain", | ||
"rules": { | ||
"no-param-reassign": [ | ||
2, | ||
{ | ||
"props": true | ||
} | ||
] | ||
} | ||
}, | ||
"eslintIgnore": [ | ||
"flow-typed/*", | ||
"wip/*" | ||
] | ||
} |
// @flow | ||
const { inspect } = require('util') | ||
const { randomBytes } = require('crypto') | ||
@@ -26,3 +25,3 @@ const { pbkdf2 } = require('crypto') | ||
derivedKey: Buffer | ||
|}> */ { | ||
|}> */ { /* eslint-disable-line brace-style */ | ||
const hash = defaultHash | ||
@@ -29,0 +28,0 @@ const prf = defaultPrf |
// @flow | ||
const { inspect } = require('util') | ||
const { min, max } = Math | ||
const { max } = Math | ||
const { now } = Date | ||
@@ -73,3 +73,3 @@ const { parse } = require('url') | ||
'Connection': 'keep-alive', | ||
'Keep-Alive': 'timeout=10, max=1024', | ||
'Keep-Alive': 'timeout=10, max=1024' | ||
} : | ||
@@ -80,2 +80,3 @@ {} | ||
const { protocol, host, hostname, port } = parse(url) | ||
const protocolPort = protocol === 'https:' ? 443 : 80 | ||
const options = { | ||
@@ -86,3 +87,3 @@ agent, | ||
hostname, | ||
port, | ||
port: port ? parseInt(port, 10) : protocolPort, | ||
method: 'POST', | ||
@@ -108,4 +109,4 @@ headers: { | ||
const buffer = Buffer.concat(chunks) | ||
const json = parseJson(buffer.toString('utf8')) | ||
req.emit('settle', void 0, { code, headers, json, buffer }) | ||
const json_ = parseJson(buffer.toString('utf8')) | ||
req.emit('settle', void 0, { code, headers, json: json_, buffer }) | ||
}) | ||
@@ -112,0 +113,0 @@ res.on('error', err => req.emit('settle', err)) |
// @flow | ||
const { inspect } = require('util') | ||
const { randomBytes } = require('crypto') | ||
@@ -29,3 +28,3 @@ const scrypt = require('./crypto-scrypt') | ||
derivedKey: Buffer | ||
|}> */ { | ||
|}> */ { /* eslint-disable-line brace-style */ | ||
const effectiveSalt = salt || randomBytes(32) | ||
@@ -32,0 +31,0 @@ if (!isBuffer(effectiveSalt)) { |
@@ -5,3 +5,2 @@ // @flow | ||
const defaultCmp = require('./default-cmp') | ||
const { min } = Math | ||
@@ -8,0 +7,0 @@ /** |
@@ -5,3 +5,2 @@ // @flow | ||
const defaultCmp = require('./default-cmp') | ||
const { min } = Math | ||
@@ -8,0 +7,0 @@ /** |
@@ -6,3 +6,3 @@ // @flow | ||
function sortedKeys(value /*: mixed */, cmp /*:: ?: (string, string) => -1 | 0 | 1 */ = defaultCmp) /*: string[] */ { | ||
function sortedKeys(value /*: Object */, cmp /*:: ?: (string, string) => -1 | 0 | 1 */ = defaultCmp) /*: string[] */ { | ||
const keys = keysOf(value) | ||
@@ -9,0 +9,0 @@ keys.sort(cmp) |
@@ -76,3 +76,4 @@ // @flow | ||
resolveNonce(address /*: string */, nonce /*: number */) { | ||
resolveNonce(address /*: string */, nonce_ /*: number */) { | ||
let nonce = nonce_ | ||
assert(!this.nonces.has(address), `Expected nonce for ${inspect(address)} to be undefined.`) | ||
@@ -79,0 +80,0 @@ const executors = this.executors.get(address) |
@@ -5,3 +5,2 @@ // @flow | ||
const isSafePositive = require('./is-safe-positive') | ||
const { min } = Math | ||
@@ -8,0 +7,0 @@ /** Spread `n` calls to `f` function `ms` milliseconds apart. */ |
@@ -21,4 +21,6 @@ // @flow | ||
function mask(bytes /*: Buffer */, version /*:: ?: number */ = 4, variant /*:: ?: Symbol */ = variantRfc4122) /*: Buffer */ { | ||
function mask(bytes_ /*: Buffer */, version /*:: ?: number */ = 4, variant /*:: ?: Symbol */ = variantRfc4122) /*: Buffer */ { | ||
const bytes = Buffer.from(bytes_) | ||
if (!isBuffer(bytes) || bytes.length !== 16) { | ||
@@ -30,3 +32,3 @@ throw new TypeError(`Expected buffer of 16 bytes, got ${inspect(bytes)}.`) | ||
case variantUnknown: | ||
break; | ||
break | ||
case variantNcs: | ||
@@ -33,0 +35,0 @@ bytes[8] = bytes[8] & 0x7f |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
108515
3112
5
3