Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Readme
Keyu (key utilities) provides flexible utilities to help you build solid projects without repeating yourself.
With this utilities you will be able to:
*compose functions independently if they return promises or actual values
Compose N functions, works with promises too.
const {compose} = require('keyu');
const sum1 = x => x+1;
const mult2 = x => x*2;
const dbSum = x => Promise.resolve(x+1);
const sumAndMult = compose(mult2,sum1);
const sumAndMultDB = compose(dbSum,mult2,sum1);
sumAndMult(1) // 4
sumAndMultDB(1) // Promise(5)
Compose N functions in reverse order, works promises too.
const {pipe} = require('keyu');
const sum1 = x => x+1;
const mult2 = x => x*2;
const dbSum = x => Promise.resolve(x+1);
const sumAndMult = pipe(sum1,mult2);
const sumAndMultDB = pipe(sum1, mult2, dbSum);
sumAndMult(1) // 4
sumAndMultDB(1) // Promise(5)
Maps an object based on the mapping function passed.
let obj = {a:1,b:2,c:3};
console.log(obj.map(value => value+1)) // {a:2}
console.log(obj.map((value, key) => `${key}:${value+1}`)) // {a:'a:2'}
functional programmming implementation:
const {map,compose} = require('keyu');
const sum1 = compose(map(x => x+1))
sum1([1]) // [2]
sum1({a:1}) // {a:2}
Filters an object based on the filter function passed.
let obj = {a:1,b:2,c:3};
console.log(obj.filter(value => value > 2)) // {c:3}
console.log(obj.filter((value, key) => value > 1 && key === 'c')) // {c:3}
functional programmming implementation:
const {filter,compose} = require('keyu');
const greaterThan5 = compose(filter(x => x > 5 ))
greaterThan5([1,2,3,4,5,6,7,8]) // [6,7,8]
greaterThan5({a:1,b:2,c:3,d:4,e:5,f:6,g:7}) // {f:6,g:7}
Promise.all executes an array of promises in parallel and returns all of them either they are sucessful or not without failing.
Promise.any([Promise.resolve(1),Promise.reject(2), Promise.resolve(3)]).then(console.log) // [ { value: 1 }, { error: 2 }, { value: 3 } ]
Promise.best execute an array of promises in parallel and returns the first one to be sucessful.
Promise.best([Promise.reject(1),Promise.resolve(2), Promise.resolve(3)]).then(console.log) // 2
Promise.best([Promise.reject(1),Promise.reject(2), Promise.reject(3)]).catch(console.log) // [1,2,3]
Converts safetly any input into a json, if it fails returns the default function value.
jsonOr(33)('{"a":1}') // -> {a:1}
jsonOr(33)(null) // -> 33
jsonOr(value => 33)(null) // -> 33
Converts safetly any input into a float, if it fails returns the default function value.
floatOr(33)('11.33') // -> 11.33
floatOr(33)(null) // -> 33
floatOr(value => 33)(null) // -> 33
Converts safetly any input into an integer, if it fails returns the default function value.
intOr(33)('11') // -> 11
intOr(33)(null) // -> 33
intOr(value => 33)(null) // -> 33
Set the amount of decimals for any given float safelty or returns cero precision.
setPrecision(3,'1.1234') // -> 1.234
FAQs
Key utilities for everyday use
The npm package keyu receives a total of 288 weekly downloads. As such, keyu popularity was classified as not popular.
We found that keyu 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
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.