
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
promise-fallback
Advanced tools
Function for promise fallback flow control Returns the first resolution that is not null or undefined
Installation
npm install promise-fallback
Require
var fallback = require('./fallback.js').fallback
#Usage
fallback(array); //returns promise
#example
function lookupDataByKey() {
return fallback([
localCache[key], //this could be a value like 2 or null
cachedPromises[key], //this could be a promise that resolves to a value
function() { //this could resolve to our data
//this only gets called if the previous attempts resolve to null/undefined
return getDataFromRedisAsync(key);
},
function() { //this could resolve to our data
//this only gets called if the previous attempts resolve to null/undefined
return getDataFromDatabaseAsync(key);
},
function() { //our data was not found throw an error
//this only gets called if the previous attempts resolve to null/undefined
throw new Error('Data not found with key: ' + key);
},
function() { //this code will NEVER execute because the previous attempt rejected
return 22;
}
]);
}
#Build
sh build.sh
or
coffee -p --no-header -c src/fallback.coffee > fallback.js
#Test
sh test.sh
or
mocha --compilers coffee:coffee-script/register -R spec --timeout 10000 $@
FAQs
Library for handling empty promise resolutions
We found that promise-fallback demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.