@nejs/basic-extensions
Advanced tools
Comparing version 1.9.0 to 1.10.0
export const all: any; | ||
export default results; | ||
declare namespace results { | ||
export { Extensions }; | ||
export { Patches }; | ||
export { StaticPatches }; | ||
export { InstancePatches }; | ||
export { Controls }; | ||
export { Extensions as extensions }; | ||
@@ -12,3 +17,5 @@ export { Patches as patches }; | ||
export const Patches: Map<any, any>; | ||
export const StaticPatches: ((import("@nejs/extension").Patch | ObjectConstructor)[] | (import("@nejs/extension").Patch | FunctionConstructor)[] | (import("@nejs/extension").Patch | typeof Reflect)[] | (import("@nejs/extension").Patch | StringConstructor)[] | (import("@nejs/extension").Patch | SymbolConstructor)[])[]; | ||
export const InstancePatches: Object[][]; | ||
export const Controls: {}; | ||
import { GlobalFunctionsAndProps } from './globals.js'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Controls = exports.Patches = exports.Extensions = exports.all = void 0; | ||
exports.Controls = exports.InstancePatches = exports.StaticPatches = exports.Patches = exports.Extensions = exports.all = void 0; | ||
const functionextensions_js_1 = require("./functionextensions.js"); | ||
@@ -26,2 +26,3 @@ const objectextensions_js_1 = require("./objectextensions.js"); | ||
]; | ||
exports.StaticPatches = StaticPatches; | ||
const InstancePatches = [ | ||
@@ -34,2 +35,3 @@ [Object.prototype, objectextensions_js_1.ObjectPrototypeExtensions], | ||
]; | ||
exports.InstancePatches = InstancePatches; | ||
const Patches = new Map([ | ||
@@ -62,7 +64,11 @@ ...StaticPatches, | ||
}, | ||
enableStaticPatches(filter = (extension) => true) { | ||
StaticPatches.filter(filter).forEach(extension => extension.apply()); | ||
enableStaticPatches(filter = ([owner, extension]) => true) { | ||
const patches = StaticPatches.filter(toFilterFn(filter)); | ||
patches.forEach(([_, extension]) => extension.apply()); | ||
return patches; | ||
}, | ||
enableInstancePatches(filter = (extension) => true) { | ||
InstancePatches.filter(filter).forEach(extension => extension.apply()); | ||
enableInstancePatches(filter = ([owner, extension]) => true) { | ||
const patches = InstancePatches.filter(toFilterFn(filter)); | ||
patches.forEach(([_, extension]) => extension.apply()); | ||
return patches; | ||
}, | ||
@@ -79,7 +85,11 @@ enableExtensions() { | ||
}, | ||
disableStaticPatches(filter = (extension) => true) { | ||
StaticPatches.filter(filter).forEach(extension => extension.revert()); | ||
disableStaticPatches(filter = ([owner, extension]) => true) { | ||
const patches = StaticPatches.filter(toFilterFn(filter)); | ||
patches.forEach(([_, extension]) => extension.revert()); | ||
return patches; | ||
}, | ||
disableInstancePatches(filter = (extension) => true) { | ||
InstancePatches.filter(filter).forEach(extension => extension.revert()); | ||
disableInstancePatches(filter = ([owner, extension]) => true) { | ||
const patches = InstancePatches.filter(toFilterFn(filter)); | ||
patches.forEach(([_, extension]) => extension.revert()); | ||
return patches; | ||
}, | ||
@@ -110,2 +120,7 @@ disableExtensions() { | ||
...Controls, | ||
Extensions, | ||
Patches, | ||
StaticPatches, | ||
InstancePatches, | ||
Controls, | ||
extensions: Extensions, | ||
@@ -116,2 +131,23 @@ patches: Patches, | ||
exports.default = results; | ||
function toFilterFn(filter = ([owner, extension]) => true) { | ||
let filterFn = filter; | ||
if (typeof filterFn !== 'function') { | ||
const elements = Array.isArray(filter) ? filter : [filter]; | ||
filterFn = ([owner, _]) => { | ||
for (const element of elements) { | ||
const elementStr = String(element); | ||
if (elementStr.startsWith('^')) { | ||
if ((owner?.name ?? owner) != elementStr.substring(1)) { | ||
return true; | ||
} | ||
} | ||
if ((owner?.name ?? owner) == elementStr) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
} | ||
return filterFn; | ||
} | ||
//# sourceMappingURL=index.js.map |
export const all: any; | ||
export default results; | ||
declare namespace results { | ||
export { Extensions }; | ||
export { Patches }; | ||
export { StaticPatches }; | ||
export { InstancePatches }; | ||
export { Controls }; | ||
export { Extensions as extensions }; | ||
@@ -12,3 +17,5 @@ export { Patches as patches }; | ||
export const Patches: Map<any, any>; | ||
export const StaticPatches: ((import("@nejs/extension").Patch | ObjectConstructor)[] | (import("@nejs/extension").Patch | FunctionConstructor)[] | (import("@nejs/extension").Patch | typeof Reflect)[] | (import("@nejs/extension").Patch | StringConstructor)[] | (import("@nejs/extension").Patch | SymbolConstructor)[])[]; | ||
export const InstancePatches: Object[][]; | ||
export const Controls: {}; | ||
import { GlobalFunctionsAndProps } from './globals.js'; |
@@ -54,7 +54,11 @@ import { FunctionExtensions, FunctionPrototypeExtensions } from './functionextensions.js'; | ||
}, | ||
enableStaticPatches(filter = (extension) => true) { | ||
StaticPatches.filter(filter).forEach(extension => extension.apply()); | ||
enableStaticPatches(filter = ([owner, extension]) => true) { | ||
const patches = StaticPatches.filter(toFilterFn(filter)); | ||
patches.forEach(([_, extension]) => extension.apply()); | ||
return patches; | ||
}, | ||
enableInstancePatches(filter = (extension) => true) { | ||
InstancePatches.filter(filter).forEach(extension => extension.apply()); | ||
enableInstancePatches(filter = ([owner, extension]) => true) { | ||
const patches = InstancePatches.filter(toFilterFn(filter)); | ||
patches.forEach(([_, extension]) => extension.apply()); | ||
return patches; | ||
}, | ||
@@ -71,7 +75,11 @@ enableExtensions() { | ||
}, | ||
disableStaticPatches(filter = (extension) => true) { | ||
StaticPatches.filter(filter).forEach(extension => extension.revert()); | ||
disableStaticPatches(filter = ([owner, extension]) => true) { | ||
const patches = StaticPatches.filter(toFilterFn(filter)); | ||
patches.forEach(([_, extension]) => extension.revert()); | ||
return patches; | ||
}, | ||
disableInstancePatches(filter = (extension) => true) { | ||
InstancePatches.filter(filter).forEach(extension => extension.revert()); | ||
disableInstancePatches(filter = ([owner, extension]) => true) { | ||
const patches = InstancePatches.filter(toFilterFn(filter)); | ||
patches.forEach(([_, extension]) => extension.revert()); | ||
return patches; | ||
}, | ||
@@ -102,2 +110,7 @@ disableExtensions() { | ||
...Controls, | ||
Extensions, | ||
Patches, | ||
StaticPatches, | ||
InstancePatches, | ||
Controls, | ||
extensions: Extensions, | ||
@@ -108,3 +121,24 @@ patches: Patches, | ||
export default results; | ||
export { Extensions, Patches, Controls, }; | ||
export { Extensions, Patches, StaticPatches, InstancePatches, Controls, }; | ||
function toFilterFn(filter = ([owner, extension]) => true) { | ||
let filterFn = filter; | ||
if (typeof filterFn !== 'function') { | ||
const elements = Array.isArray(filter) ? filter : [filter]; | ||
filterFn = ([owner, _]) => { | ||
for (const element of elements) { | ||
const elementStr = String(element); | ||
if (elementStr.startsWith('^')) { | ||
if ((owner?.name ?? owner) != elementStr.substring(1)) { | ||
return true; | ||
} | ||
} | ||
if ((owner?.name ?? owner) == elementStr) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
} | ||
return filterFn; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -61,7 +61,7 @@ { | ||
"type": "module", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"dependencies": { | ||
"@nejs/extension": "^2.1.0" | ||
"@nejs/extension": "^2.2.0" | ||
}, | ||
"browser": "dist/@nejs/basic-extensions.bundle.1.8.0.js" | ||
"browser": "dist/@nejs/basic-extensions.bundle.1.9.0.js" | ||
} |
@@ -71,8 +71,12 @@ import { FunctionExtensions, FunctionPrototypeExtensions } from './functionextensions.js' | ||
enableStaticPatches(filter = (extension) => true) { | ||
StaticPatches.filter(filter).forEach(extension => extension.apply()) | ||
enableStaticPatches(filter = ([owner, extension]) => true) { | ||
const patches = StaticPatches.filter(toFilterFn(filter)) | ||
patches.forEach(([_, extension]) => extension.apply()) | ||
return patches | ||
}, | ||
enableInstancePatches(filter = (extension) => true) { | ||
InstancePatches.filter(filter).forEach(extension => extension.apply()) | ||
enableInstancePatches(filter = ([owner, extension]) => true) { | ||
const patches = InstancePatches.filter(toFilterFn(filter)) | ||
patches.forEach(([_, extension]) => extension.apply()) | ||
return patches | ||
}, | ||
@@ -93,8 +97,12 @@ | ||
disableStaticPatches(filter = (extension) => true) { | ||
StaticPatches.filter(filter).forEach(extension => extension.revert()) | ||
disableStaticPatches(filter = ([owner, extension]) => true) { | ||
const patches = StaticPatches.filter(toFilterFn(filter)) | ||
patches.forEach(([_, extension]) => extension.revert()) | ||
return patches | ||
}, | ||
disableInstancePatches(filter = (extension) => true) { | ||
InstancePatches.filter(filter).forEach(extension => extension.revert()) | ||
disableInstancePatches(filter = ([owner, extension]) => true) { | ||
const patches = InstancePatches.filter(toFilterFn(filter)) | ||
patches.forEach(([_, extension]) => extension.revert()) | ||
return patches | ||
}, | ||
@@ -133,2 +141,7 @@ | ||
...Controls, | ||
Extensions, | ||
Patches, | ||
StaticPatches, | ||
InstancePatches, | ||
Controls, | ||
extensions: Extensions, | ||
@@ -144,3 +157,29 @@ patches: Patches, | ||
Patches, | ||
StaticPatches, | ||
InstancePatches, | ||
Controls, | ||
} | ||
function toFilterFn(filter = ([owner, extension]) => true) { | ||
let filterFn = filter | ||
if (typeof filterFn !== 'function') { | ||
const elements = Array.isArray(filter) ? filter : [filter] | ||
filterFn = ([owner, _]) => { | ||
for (const element of elements) { | ||
const elementStr = String(element) | ||
if (elementStr.startsWith('^')) { | ||
if ((owner?.name ?? owner) != elementStr.substring(1)) { | ||
return true | ||
} | ||
} | ||
if ((owner?.name ?? owner) == elementStr) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
} | ||
return filterFn | ||
} |
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
2883255
15082
Updated@nejs/extension@^2.2.0