![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@hyperjump/pact
Advanced tools
Readme
Hyperjump Pact is a utility library for working with promises. Many promise implementations include these kinds of functions, but this is a promise-implementation agnostic library. All functions are curried and designed for pipelining.
npm install @hyperjump/pact --save
Run the tests
npm test
Run the tests with a continuous test runner
npm test -- --watch
The following is short demo using the [Hyperjump Browser][browser] whose use of promises is ideal for illustrating how these functions can be used. See the API section below to see all of the things you can do.
This example uses the API at https://swapi.hyperjump.io. It's a variation of the Star Wars API (SWAPI) implemented using the JRef media type.
const Hyperjump = require("@hyperjump/browser");
const Pact = require("@hyperjump/pact");
const characterHomeworlds = Pact.map(async (character) => {
const name = await character.name;
const homeworld = await character.homeworld.name;
return `${name} is from ${homeworld}`;
});
const ladies = Pact.pipeline([
Pact.filter(async (character) => (await character.gender) === "female"),
Pact.map((character) => character.name)
]);
const mass = Pact.reduce(async (acc, character) => {
return acc + (parseInt(await character.mass, 10) || 0);
}, 0);
(async function () {
const film = Hyperjump.fetch("https://swapi.hyperjump.io/api/films/1");
await film.title; // --> A New Hope
await characterHomeworlds(film.characters); // --> [ 'Luke Skywalker is from Tatooine',
// --> 'C-3PO is from Tatooine',
// --> 'R2-D2 is from Naboo',
// --> ... ]
await ladies(film.characters); // --> [ 'Leia Organa', 'Beru Whitesun lars' ]
await mass(film.characters); // --> 1290
}());
The documentation here is pretty light, but these are implementations of common higher-order functions and they work exactly like you would expect them to except that they work with promises.
(object<A>) => Promise<[string, A][]>
((A, number?) => any, A[]|Promise<A[]>, Options) => Promise<any>
((A, number?) => boolean|Promise<boolean>, A[]|Promise<A[]>, Options) => Promise<A[]>
((B, A, number?) => B, A[]|Promise<A[]>, B, Options) => Promise<B>
((A, number?) => boolean|Promise<boolean>, A[]|Promise<A[]>, Options) => Promise<boolean>
((A, number?) => boolean|Promise<boolean>, A|Promise<A>, Options) => Promise<boolean>
(Function[], any) => Promise<any>
Compose an array of functions that call the next function with result of the previous function.
(Promise<A>[]) => A[]
(object<Promise<A>>) => object<A>
allValues
is like all
except it resolves promise for each value in an object
rather than each item in an array.
FAQs
Higher order functions for iterators and async iterators
The npm package @hyperjump/pact receives a total of 22,667 weekly downloads. As such, @hyperjump/pact popularity was classified as popular.
We found that @hyperjump/pact demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.