@pnp/core-commonjs
Advanced tools
Comparing version 3.0.0-v3nightly.20220028 to 3.0.0-v3nightly.20220030
@@ -7,5 +7,6 @@ import { Timeline, TimelinePipe } from "../timeline.js"; | ||
* @param behavior replace = observers are cleared before adding, append preserves any observers already present | ||
* @param filter If provided filters the moments from which the observers are copied. It should return true for each moment to include. | ||
* @returns The mutated this | ||
*/ | ||
export declare function CopyFrom(source: Timeline<any>, behavior?: "replace" | "append"): TimelinePipe; | ||
export declare function CopyFrom(source: Timeline<any>, behavior?: "replace" | "append", filter?: (moment: string) => boolean): TimelinePipe; | ||
//# sourceMappingURL=copy-from.d.ts.map |
@@ -11,7 +11,8 @@ "use strict"; | ||
* @param behavior replace = observers are cleared before adding, append preserves any observers already present | ||
* @param filter If provided filters the moments from which the observers are copied. It should return true for each moment to include. | ||
* @returns The mutated this | ||
*/ | ||
function CopyFrom(source, behavior = "append") { | ||
function CopyFrom(source, behavior = "append", filter) { | ||
return (instance) => { | ||
return Reflect.apply(copyObservers, instance, [source, behavior]); | ||
return Reflect.apply(copyObservers, instance, [source, behavior, filter]); | ||
}; | ||
@@ -28,8 +29,11 @@ } | ||
*/ | ||
function copyObservers(source, behavior) { | ||
function copyObservers(source, behavior, filter) { | ||
if (!util_js_1.objectDefinedNotNull(source) || !util_js_1.objectDefinedNotNull(source.observers)) { | ||
return this; | ||
} | ||
if (!util_js_1.isFunc(filter)) { | ||
filter = () => true; | ||
} | ||
const clonedSource = timeline_js_1.cloneObserverCollection(source.observers); | ||
const keys = Object.keys(clonedSource); | ||
const keys = Object.keys(clonedSource).filter(filter); | ||
for (let i = 0; i < keys.length; i++) { | ||
@@ -36,0 +40,0 @@ const key = keys[i]; |
@@ -25,3 +25,5 @@ "use strict"; | ||
const extensions = factoryExtensions.get(Reflect.get(proto, ObjExtensionsSym)); | ||
r = extend(r, extensions); | ||
if (extensions) { | ||
r = extend(r, extensions); | ||
} | ||
} | ||
@@ -78,12 +80,15 @@ const proxied = new Proxy(r, { | ||
const proto = Reflect.getPrototypeOf(factory); | ||
if (!Reflect.has(proto, ObjExtensionsSym)) { | ||
Reflect.defineProperty(proto, ObjExtensionsSym, { | ||
value: util_js_1.getGUID(), | ||
}); | ||
if (proto) { | ||
if (!Reflect.has(proto, ObjExtensionsSym)) { | ||
Reflect.defineProperty(proto, ObjExtensionsSym, { | ||
value: util_js_1.getGUID(), | ||
}); | ||
} | ||
const key = proto[ObjExtensionsSym]; | ||
if (!factoryExtensions.has(key)) { | ||
factoryExtensions.set(key, []); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
extendCol(factoryExtensions.get(key), extensions); | ||
} | ||
const key = proto[ObjExtensionsSym]; | ||
if (!factoryExtensions.has(key)) { | ||
factoryExtensions.set(key, []); | ||
} | ||
extendCol(factoryExtensions.get(key), extensions); | ||
} | ||
@@ -90,0 +95,0 @@ exports.extendFactory = extendFactory; |
{ | ||
"name": "@pnp/core-commonjs", | ||
"version": "3.0.0-v3nightly.20220028", | ||
"version": "3.0.0-v3nightly.20220030", | ||
"description": "pnp - provides shared functionality across all pnp libraries", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -17,3 +17,3 @@ export declare type DateAddInterval = "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second"; | ||
*/ | ||
export declare function combine(...paths: string[]): string; | ||
export declare function combine(...paths: (string | null | undefined)[]): string; | ||
/** | ||
@@ -54,3 +54,3 @@ * Gets a random string of chars length | ||
*/ | ||
export declare function stringIsNullOrEmpty(s: string): boolean; | ||
export declare function stringIsNullOrEmpty(s: string | undefined | null): s is undefined | null | ""; | ||
/** | ||
@@ -60,3 +60,3 @@ * Determines if an object is both defined and not null | ||
*/ | ||
export declare function objectDefinedNotNull(obj: any): boolean; | ||
export declare function objectDefinedNotNull<T>(obj: T | undefined | null): obj is T; | ||
/** | ||
@@ -74,3 +74,3 @@ * Shorthand for JSON.stringify | ||
*/ | ||
export declare function hOP(o: any, p: string): boolean; | ||
export declare function hOP<T extends string>(o: any, p: T): boolean; | ||
/** | ||
@@ -77,0 +77,0 @@ * Generates a ~unique hash code |
@@ -55,2 +55,3 @@ "use strict"; | ||
.filter(path => !stringIsNullOrEmpty(path)) | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
.map(path => path.replace(/^[\\|/]/, "").replace(/[\\|/]$/, "")) | ||
@@ -124,3 +125,3 @@ .join("/") | ||
function stringIsNullOrEmpty(s) { | ||
return s === undefined || s === null || s.length < 1; | ||
return typeof s === "undefined" || s === null || s.length < 1; | ||
} | ||
@@ -127,0 +128,0 @@ exports.stringIsNullOrEmpty = stringIsNullOrEmpty; |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
80410
1300