Socket
Book a DemoInstallSign in
Socket

@pnp/core

Package Overview
Dependencies
Maintainers
12
Versions
1135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnp/core - npm Package Compare versions

Comparing version

to
3.4.0-v3nightly.20220613

13

moments.d.ts

@@ -9,2 +9,15 @@ import { ObserverAction, ObserverFunction, Timeline } from "./timeline.js";

/**
* Defines a moment that executes each observer asynchronously in parallel awaiting all promises to resolve or reject before continuing
*
* @returns The final set of arguments
*/
export declare function asyncBroadcast<T extends ObserverFunction<void>>(): (observers: T[], ...args: [...Parameters<T>]) => Promise<any[]>;
/**
* Defines a moment that executes each observer synchronously, passing the returned arguments as the arguments to the next observer.
* This is very much like the redux pattern taking the arguments as the state which each observer may modify then returning a new state
*
* @returns The final set of arguments
*/
export declare function reduce<T extends ObserverFunction<[...Parameters<T>]>>(): (observers: T[], ...args: [...Parameters<T>]) => [...Parameters<T>];
/**
* Defines a moment that executes each observer asynchronously, awaiting the result and passes the returned arguments as the arguments to the next observer.

@@ -11,0 +24,0 @@ * This is very much like the redux pattern taking the arguments as the state which each observer may modify then returning a new state

@@ -16,2 +16,39 @@ import { isArray } from "./util.js";

/**
* Defines a moment that executes each observer asynchronously in parallel awaiting all promises to resolve or reject before continuing
*
* @returns The final set of arguments
*/
export function asyncBroadcast() {
return async function (observers, ...args) {
// get our initial values
const r = args;
const obs = [...observers];
const promises = [];
// process each handler which updates our "state" in order
for (let i = 0; i < obs.length; i++) {
promises.push(Reflect.apply(obs[i], this, r));
}
return Promise.all(promises);
};
}
/**
* Defines a moment that executes each observer synchronously, passing the returned arguments as the arguments to the next observer.
* This is very much like the redux pattern taking the arguments as the state which each observer may modify then returning a new state
*
* @returns The final set of arguments
*/
export function reduce() {
return function (observers, ...args) {
// get our initial values
let r = args;
const obs = [...observers];
// process each handler which updates our "state" in order
// returning the new "state" as a tuple [...Parameters<T>]
for (let i = 0; i < obs.length; i++) {
r = Reflect.apply(obs[i], this, r);
}
return r;
};
}
/**
* Defines a moment that executes each observer asynchronously, awaiting the result and passes the returned arguments as the arguments to the next observer.

@@ -18,0 +55,0 @@ * This is very much like the redux pattern taking the arguments as the state which each observer may modify then returning a new state

56

package.json
{
"name": "@pnp/core",
"version": "3.3.2",
"description": "pnp - provides shared functionality across all pnp libraries",
"main": "./index.js",
"typings": "./index",
"dependencies": {
"tslib": "2.3.1"
},
"funding": {
"type": "individual",
"url": "https://github.com/sponsors/patrick-rodgers/"
},
"type": "module",
"engines": {
"node": ">=14.15.1"
},
"author": {
"name": "Microsoft and other contributors"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/pnp/pnpjs/issues"
},
"homepage": "https://github.com/pnp/pnpjs",
"repository": {
"type": "git",
"url": "git:github.com/pnp/pnpjs"
}
"name": "@pnp/core",
"version": "3.4.0-v3nightly.20220613",
"description": "pnp - provides shared functionality across all pnp libraries",
"main": "./index.js",
"typings": "./index",
"dependencies": {
"tslib": "2.4.0"
},
"funding": {
"type": "individual",
"url": "https://github.com/sponsors/patrick-rodgers/"
},
"type": "module",
"engines": {
"node": ">=14.15.1"
},
"author": {
"name": "Microsoft and other contributors"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/pnp/pnpjs/issues"
},
"homepage": "https://github.com/pnp/pnpjs",
"repository": {
"type": "git",
"url": "git:github.com/pnp/pnpjs"
}
}

@@ -131,12 +131,11 @@ import { broadcast, lifecycle } from "./moments.js";

*/
async start(init) {
try {
// initialize our timeline
this.emit.init();
// execute the timeline
// (this await is required to ensure dispose is called AFTER execute completes)
// we do not catch here so that any promise rejects in execute bubble up to the caller
return await this.execute(init);
}
finally {
start(init) {
// initialize our timeline
this.emit.init();
// execute the timeline and get a ref to the promise
// this gives the implementation of execute the ability to mutate the promise object, which
// enabled us to add the cancel behavior, and opens up another piece of flexibility in the framework
const p = this.execute(init);
// attach our dispose logic
p.finally(() => {
try {

@@ -153,3 +152,4 @@ // provide an opportunity for cleanup of the timeline

}
}
});
return p;
}

@@ -156,0 +156,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.