Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@appliedblockchain/helpers

Package Overview
Dependencies
Maintainers
15
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appliedblockchain/helpers - npm Package Compare versions

Comparing version 2.10.0 to 3.0.2

15

Changelog.md
# Changelog
## [v3.0.2](../../compare/v3.0.1...v3.0.2) (2019-08-21)
* Dropping auto doc generation, it's broken on some files.
## [v3.0.1](../../compare/v3.0.0...v3.0.1) (2019-08-21)
* No changes.
## [v3.0.0](../../compare/v2.10.0...v3.0.0) (2019-08-21)
* Updating npms. Adding docs/* to eslint ignore.
* Updating types of indexed-by-key.
* Changing predicate on once-if/result-of-predicate to single value.
* Updating changelog and readme.
## [v2.10.0](../../compare/v2.9.0...v2.10.0) (2019-08-13)

@@ -4,0 +19,0 @@

2

indexed-by-key.js

@@ -5,3 +5,3 @@ // @flow

Non-existing keys will be indexed under `undefined` key. */
function indexedByKey/*:: <T> */(xs /*: T[] */, key /*: string */) /*: { [string]: T } */ {
function indexedByKey/*:: <K: string, T: { [K]: string }> */(xs /*: T[] */, key /*: K */) /*: { [string]: T } */ {
return xs.reduce((r, _) => {

@@ -8,0 +8,0 @@ r[_[key]] = _

@@ -7,8 +7,8 @@ // @flow

function onceIf(
function onceIf/*:: <T = any> */(
emitter /*: events$EventEmitter */,
eventName /*: string */,
predicate /*: () => boolean | Promise<boolean> */,
predicate /*: (value: T) => boolean | Promise<boolean> */,
timeout /*: number */
) /*: Promise<any> */ {
) /*: Promise<T> */ {
return new Promise((resolve, reject) => {

@@ -27,4 +27,4 @@ let timeoutId, listener

listener = async (...args) => {
if (await resultOfPredicate(predicate, ...args)) {
listener = async (value /*: T */) => {
if (await resultOfPredicate(predicate, value)) {
if (listener) {

@@ -38,3 +38,3 @@ emitter.off(eventName, listener)

}
resolve(...args)
resolve(value)
}

@@ -41,0 +41,0 @@ }

{
"name": "@appliedblockchain/helpers",
"version": "2.10.0",
"version": "3.0.2",
"description": "No dependency, single file helpers.",

@@ -11,3 +11,3 @@ "main": "index.js",

"minor": "npm test && npm version minor && git push && git push --tags && npm publish",
"postversion": "changelog > Changelog.md && git add Changelog.md && npm run doc && git add Readme.md && git commit -m \"Updating changelog and readme.\" && git push && git push --tags"
"postversion": "changelog > Changelog.md && git add Changelog.md && git commit -m \"Updating changelog.\" && git push && git push --tags"
},

@@ -26,4 +26,4 @@ "keywords": [],

"@appliedblockchain/eslint-config": "2.6.0",
"eslint": "5.16.0",
"flow-bin": "0.101.0"
"eslint": "6.2.1",
"flow-bin": "0.105.2"
},

@@ -43,4 +43,5 @@ "eslintConfig": {

"flow-typed/*",
"wip/*"
"wip/*",
"docs/*"
]
}

@@ -5,20 +5,17 @@ // @flow

/*::
type Predicate = (...args: any[]) => boolean | Promise<boolean>
*/
const log = logOf('result-of-predicate')
async function resultOfPredicate(f /*: Predicate */, ...args /*: any[] */) /*: Promise<boolean> */ {
async function resultOfPredicate/*:: <T = any> */(
predicate /*: (value: T) => boolean | Promise<boolean> */,
value /*: T */
) /*: Promise<boolean> */ {
try {
return Promise.resolve(f(...args))
return Promise.resolve(predicate(value))
.then(_ => !!_)
.catch(err => {
log.warn('Error while trying to evaluate predicate.', err)
log.warn('Error while trying to evaluate async predicate.', err)
return false
})
} catch (err) {
log.warn('Error while trying to evaluate predicate.', err)
log.warn('Error while trying to evaluate sync predicate.', err)
return false

@@ -25,0 +22,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc