@@ -52,3 +52,3 @@ /* | ||
| }, | ||
| onTap: (i, run, done, doneBreak) => { | ||
| onTap: (i, run, done, _doneBreak) => { | ||
| let code = ""; | ||
@@ -72,6 +72,6 @@ if (i > 0) { | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
@@ -78,0 +78,0 @@ function AsyncParallelBailHook(args = [], name = undefined) { |
@@ -21,6 +21,6 @@ /* | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
@@ -27,0 +27,0 @@ function AsyncParallelHook(args = [], name = undefined) { |
@@ -26,6 +26,6 @@ /* | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
@@ -32,0 +32,0 @@ function AsyncSeriesBailHook(args = [], name = undefined) { |
@@ -21,6 +21,6 @@ /* | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
@@ -27,0 +27,0 @@ function AsyncSeriesHook(args = [], name = undefined) { |
@@ -21,6 +21,6 @@ /* | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
@@ -27,0 +27,0 @@ function AsyncSeriesLoopHook(args = [], name = undefined) { |
@@ -11,3 +11,3 @@ /* | ||
| class AsyncSeriesWaterfallHookCodeFactory extends HookCodeFactory { | ||
| content({ onError, onResult, onDone }) { | ||
| content({ onError, onResult, _onDone }) { | ||
| return this.callTapsSeries({ | ||
@@ -19,3 +19,3 @@ onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true), | ||
| code += `${this._args[0]} = ${result};\n`; | ||
| code += `}\n`; | ||
| code += "}\n"; | ||
| code += next(); | ||
@@ -31,10 +31,11 @@ return code; | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
| function AsyncSeriesWaterfallHook(args = [], name = undefined) { | ||
| if (args.length < 1) | ||
| if (args.length < 1) { | ||
| throw new Error("Waterfall hooks must have at least one argument"); | ||
| } | ||
| const hook = new Hook(args, name); | ||
@@ -41,0 +42,0 @@ hook.constructor = AsyncSeriesWaterfallHook; |
+19
-13
@@ -14,14 +14,16 @@ /* | ||
| const CALL_DELEGATE = function (...args) { | ||
| function CALL_DELEGATE(...args) { | ||
| this.call = this._createCall("sync"); | ||
| return this.call(...args); | ||
| }; | ||
| const CALL_ASYNC_DELEGATE = function (...args) { | ||
| } | ||
| function CALL_ASYNC_DELEGATE(...args) { | ||
| this.callAsync = this._createCall("async"); | ||
| return this.callAsync(...args); | ||
| }; | ||
| const PROMISE_DELEGATE = function (...args) { | ||
| } | ||
| function PROMISE_DELEGATE(...args) { | ||
| this.promise = this._createCall("promise"); | ||
| return this.promise(...args); | ||
| }; | ||
| } | ||
@@ -42,9 +44,13 @@ class Hook { | ||
| // eslint-disable-next-line no-self-assign | ||
| this.compile = this.compile; | ||
| // eslint-disable-next-line no-self-assign | ||
| this.tap = this.tap; | ||
| // eslint-disable-next-line no-self-assign | ||
| this.tapAsync = this.tapAsync; | ||
| // eslint-disable-next-line no-self-assign | ||
| this.tapPromise = this.tapPromise; | ||
| } | ||
| compile(options) { | ||
| compile(_options) { | ||
| throw new Error("Abstract: should be overridden"); | ||
@@ -58,3 +64,3 @@ } | ||
| args: this._args, | ||
| type: type | ||
| type | ||
| }); | ||
@@ -156,8 +162,8 @@ } | ||
| i--; | ||
| const x = this.taps[i]; | ||
| this.taps[i + 1] = x; | ||
| const xStage = x.stage || 0; | ||
| const tap = this.taps[i]; | ||
| this.taps[i + 1] = tap; | ||
| const xStage = tap.stage || 0; | ||
| if (before) { | ||
| if (before.has(x.name)) { | ||
| before.delete(x.name); | ||
| if (before.has(tap.name)) { | ||
| before.delete(tap.name); | ||
| continue; | ||
@@ -164,0 +170,0 @@ } |
+37
-51
@@ -21,11 +21,9 @@ /* | ||
| this.args(), | ||
| '"use strict";\n' + | ||
| this.header() + | ||
| this.contentWithInterceptors({ | ||
| onError: (err) => `throw ${err};\n`, | ||
| onResult: (result) => `return ${result};\n`, | ||
| resultReturns: true, | ||
| onDone: () => "", | ||
| rethrowIfPossible: true | ||
| }) | ||
| `"use strict";\n${this.header()}${this.contentWithInterceptors({ | ||
| onError: (err) => `throw ${err};\n`, | ||
| onResult: (result) => `return ${result};\n`, | ||
| resultReturns: true, | ||
| onDone: () => "", | ||
| rethrowIfPossible: true | ||
| })}` | ||
| ); | ||
@@ -38,12 +36,10 @@ break; | ||
| }), | ||
| '"use strict";\n' + | ||
| this.header() + | ||
| this.contentWithInterceptors({ | ||
| onError: (err) => `_callback(${err});\n`, | ||
| onResult: (result) => `_callback(null, ${result});\n`, | ||
| onDone: () => "_callback();\n" | ||
| }) | ||
| `"use strict";\n${this.header()}${this.contentWithInterceptors({ | ||
| onError: (err) => `_callback(${err});\n`, | ||
| onResult: (result) => `_callback(null, ${result});\n`, | ||
| onDone: () => "_callback();\n" | ||
| })}` | ||
| ); | ||
| break; | ||
| case "promise": | ||
| case "promise": { | ||
| let errorHelperUsed = false; | ||
@@ -79,2 +75,3 @@ const content = this.contentWithInterceptors({ | ||
| break; | ||
| } | ||
| } | ||
@@ -94,3 +91,3 @@ this.deinit(); | ||
| this.options = options; | ||
| this._args = options.args.slice(); | ||
| this._args = [...options.args]; | ||
| } | ||
@@ -105,5 +102,3 @@ | ||
| if (this.options.interceptors.length > 0) { | ||
| const onError = options.onError; | ||
| const onResult = options.onResult; | ||
| const onDone = options.onDone; | ||
| const { onError, onResult, onDone } = options; | ||
| let code = ""; | ||
@@ -162,5 +157,4 @@ for (let i = 0; i < this.options.interceptors.length; i++) { | ||
| return code; | ||
| } else { | ||
| return this.content(options); | ||
| } | ||
| return this.content(options); | ||
| } | ||
@@ -170,7 +164,3 @@ | ||
| let code = ""; | ||
| if (this.needContext()) { | ||
| code += "var _context = {};\n"; | ||
| } else { | ||
| code += "var _context;\n"; | ||
| } | ||
| code += this.needContext() ? "var _context = {};\n" : "var _context;\n"; | ||
| code += "var _x = this._x;\n"; | ||
@@ -238,7 +228,7 @@ if (this.options.interceptors.length > 0) { | ||
| break; | ||
| case "async": | ||
| case "async": { | ||
| let cbCode = ""; | ||
| if (onResult) | ||
| cbCode += `(function(_err${tapIndex}, _result${tapIndex}) {\n`; | ||
| else cbCode += `(function(_err${tapIndex}) {\n`; | ||
| cbCode += onResult | ||
| ? `(function(_err${tapIndex}, _result${tapIndex}) {\n` | ||
| : `(function(_err${tapIndex}) {\n`; | ||
| cbCode += `if(_err${tapIndex}) {\n`; | ||
@@ -260,2 +250,3 @@ cbCode += onError(`_err${tapIndex}`); | ||
| break; | ||
| } | ||
| case "promise": | ||
@@ -278,3 +269,5 @@ code += `var _hasResult${tapIndex} = false;\n`; | ||
| code += `if(_hasResult${tapIndex}) throw _err${tapIndex};\n`; | ||
| code += onError(`_err${tapIndex}`); | ||
| code += onError( | ||
| `!_err${tapIndex} ? new Error('Tap function (tapPromise) rejects "' + _err${tapIndex} + '" value') : _err${tapIndex}` | ||
| ); | ||
| code += "});\n"; | ||
@@ -309,3 +302,3 @@ break; | ||
| code += current(); | ||
| code += `}\n`; | ||
| code += "}\n"; | ||
| current = () => `${somethingReturns ? "return " : ""}_next${i}();\n`; | ||
@@ -321,6 +314,3 @@ } | ||
| onResult: | ||
| onResult && | ||
| ((result) => { | ||
| return onResult(i, result, done, doneBreak); | ||
| }), | ||
| onResult && ((result) => onResult(i, result, done, doneBreak)), | ||
| onDone: !onResult && done, | ||
@@ -363,5 +353,5 @@ rethrowIfPossible: | ||
| code += doneBreak(true); | ||
| code += `} else {\n`; | ||
| code += "} else {\n"; | ||
| code += next(); | ||
| code += `}\n`; | ||
| code += "}\n"; | ||
| return code; | ||
@@ -415,7 +405,7 @@ }, | ||
| if (onDone) return "if(--_counter === 0) _done();\n"; | ||
| else return "--_counter;"; | ||
| return "--_counter;"; | ||
| }; | ||
| const doneBreak = (skipDone) => { | ||
| if (skipDone || !onDone) return "_counter = 0;\n"; | ||
| else return "_counter = 0;\n_done();\n"; | ||
| return "_counter = 0;\n_done();\n"; | ||
| }; | ||
@@ -443,7 +433,3 @@ code += "if(_counter <= 0) break;\n"; | ||
| }), | ||
| onDone: | ||
| !onResult && | ||
| (() => { | ||
| return done(); | ||
| }), | ||
| onDone: !onResult && (() => done()), | ||
| rethrowIfPossible | ||
@@ -461,9 +447,9 @@ }), | ||
| let allArgs = this._args; | ||
| if (before) allArgs = [before].concat(allArgs); | ||
| if (after) allArgs = allArgs.concat(after); | ||
| if (before) allArgs = [before, ...allArgs]; | ||
| if (after) allArgs = [...allArgs, after]; | ||
| if (allArgs.length === 0) { | ||
| return ""; | ||
| } else { | ||
| return allArgs.join(", "); | ||
| } | ||
| return allArgs.join(", "); | ||
| } | ||
@@ -470,0 +456,0 @@ |
+11
-3
@@ -49,11 +49,19 @@ /* | ||
| HookMap.prototype.tap = util.deprecate(function (key, options, fn) { | ||
| HookMap.prototype.tap = util.deprecate(function tap(key, options, fn) { | ||
| return this.for(key).tap(options, fn); | ||
| }, "HookMap#tap(key,…) is deprecated. Use HookMap#for(key).tap(…) instead."); | ||
| HookMap.prototype.tapAsync = util.deprecate(function (key, options, fn) { | ||
| HookMap.prototype.tapAsync = util.deprecate(function tapAsync( | ||
| key, | ||
| options, | ||
| fn | ||
| ) { | ||
| return this.for(key).tapAsync(options, fn); | ||
| }, "HookMap#tapAsync(key,…) is deprecated. Use HookMap#for(key).tapAsync(…) instead."); | ||
| HookMap.prototype.tapPromise = util.deprecate(function (key, options, fn) { | ||
| HookMap.prototype.tapPromise = util.deprecate(function tapPromise( | ||
| key, | ||
| options, | ||
| fn | ||
| ) { | ||
| return this.for(key).tapPromise(options, fn); | ||
@@ -60,0 +68,0 @@ }, "HookMap#tapPromise(key,…) is deprecated. Use HookMap#for(key).tapPromise(…) instead."); |
+13
-13
@@ -7,14 +7,14 @@ /* | ||
| exports.__esModule = true; | ||
| exports.SyncHook = require("./SyncHook"); | ||
| exports.SyncBailHook = require("./SyncBailHook"); | ||
| exports.SyncWaterfallHook = require("./SyncWaterfallHook"); | ||
| exports.SyncLoopHook = require("./SyncLoopHook"); | ||
| exports.AsyncParallelHook = require("./AsyncParallelHook"); | ||
| exports.AsyncParallelBailHook = require("./AsyncParallelBailHook"); | ||
| exports.AsyncSeriesHook = require("./AsyncSeriesHook"); | ||
| exports.AsyncSeriesBailHook = require("./AsyncSeriesBailHook"); | ||
| exports.AsyncSeriesLoopHook = require("./AsyncSeriesLoopHook"); | ||
| exports.AsyncSeriesWaterfallHook = require("./AsyncSeriesWaterfallHook"); | ||
| exports.HookMap = require("./HookMap"); | ||
| exports.MultiHook = require("./MultiHook"); | ||
| module.exports.AsyncParallelBailHook = require("./AsyncParallelBailHook"); | ||
| module.exports.AsyncParallelHook = require("./AsyncParallelHook"); | ||
| module.exports.AsyncSeriesBailHook = require("./AsyncSeriesBailHook"); | ||
| module.exports.AsyncSeriesHook = require("./AsyncSeriesHook"); | ||
| module.exports.AsyncSeriesLoopHook = require("./AsyncSeriesLoopHook"); | ||
| module.exports.AsyncSeriesWaterfallHook = require("./AsyncSeriesWaterfallHook"); | ||
| module.exports.HookMap = require("./HookMap"); | ||
| module.exports.MultiHook = require("./MultiHook"); | ||
| module.exports.SyncBailHook = require("./SyncBailHook"); | ||
| module.exports.SyncHook = require("./SyncHook"); | ||
| module.exports.SyncLoopHook = require("./SyncLoopHook"); | ||
| module.exports.SyncWaterfallHook = require("./SyncWaterfallHook"); | ||
| module.exports.__esModule = true; |
+1
-3
@@ -7,4 +7,2 @@ /* | ||
| const Hook = require("./Hook"); | ||
| class MultiHook { | ||
@@ -49,3 +47,3 @@ constructor(hooks, name = undefined) { | ||
| return new MultiHook( | ||
| this.hooks.map((h) => h.withOptions(options)), | ||
| this.hooks.map((hook) => hook.withOptions(options)), | ||
| this.name | ||
@@ -52,0 +50,0 @@ ); |
@@ -35,6 +35,6 @@ /* | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
@@ -41,0 +41,0 @@ function SyncBailHook(args = [], name = undefined) { |
+2
-2
@@ -30,6 +30,6 @@ /* | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
@@ -36,0 +36,0 @@ function SyncHook(args = [], name = undefined) { |
@@ -30,6 +30,6 @@ /* | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
@@ -36,0 +36,0 @@ function SyncLoopHook(args = [], name = undefined) { |
@@ -18,3 +18,3 @@ /* | ||
| code += `${this._args[0]} = ${result};\n`; | ||
| code += `}\n`; | ||
| code += "}\n"; | ||
| code += next(); | ||
@@ -40,10 +40,11 @@ return code; | ||
| const COMPILE = function (options) { | ||
| function COMPILE(options) { | ||
| factory.setup(this, options); | ||
| return factory.create(options); | ||
| }; | ||
| } | ||
| function SyncWaterfallHook(args = [], name = undefined) { | ||
| if (args.length < 1) | ||
| if (args.length < 1) { | ||
| throw new Error("Waterfall hooks must have at least one argument"); | ||
| } | ||
| const hook = new Hook(args, name); | ||
@@ -50,0 +51,0 @@ hook.constructor = SyncWaterfallHook; |
@@ -7,11 +7,13 @@ /* | ||
| exports.deprecate = (fn, msg) => { | ||
| module.exports.deprecate = (fn, msg) => { | ||
| let once = true; | ||
| return function () { | ||
| return function deprecate() { | ||
| if (once) { | ||
| console.warn("DeprecationWarning: " + msg); | ||
| // eslint-disable-next-line no-console | ||
| console.warn(`DeprecationWarning: ${msg}`); | ||
| once = false; | ||
| } | ||
| // eslint-disable-next-line prefer-rest-params | ||
| return fn.apply(this, arguments); | ||
| }; | ||
| }; |
+36
-17
| { | ||
| "name": "tapable", | ||
| "version": "2.2.2", | ||
| "author": "Tobias Koppers @sokra", | ||
| "version": "2.2.3", | ||
| "description": "Just a little module for plugins.", | ||
| "license": "MIT", | ||
| "homepage": "https://github.com/webpack/tapable", | ||
@@ -12,24 +10,22 @@ "repository": { | ||
| }, | ||
| "devDependencies": { | ||
| "@babel/core": "^7.4.4", | ||
| "@babel/preset-env": "^7.4.4", | ||
| "babel-jest": "^24.8.0", | ||
| "jest": "^24.8.0", | ||
| "prettier": "^3.5.3", | ||
| "prettier-1": "npm:prettier@^1" | ||
| "funding": { | ||
| "type": "opencollective", | ||
| "url": "https://opencollective.com/webpack" | ||
| }, | ||
| "engines": { | ||
| "node": ">=6" | ||
| }, | ||
| "files": ["lib", "!lib/__tests__", "tapable.d.ts"], | ||
| "license": "MIT", | ||
| "author": "Tobias Koppers @sokra", | ||
| "main": "lib/index.js", | ||
| "types": "./tapable.d.ts", | ||
| "browser": { | ||
| "util": "./lib/util-browser.js" | ||
| }, | ||
| "types": "./tapable.d.ts", | ||
| "files": ["lib", "!lib/__tests__", "tapable.d.ts"], | ||
| "scripts": { | ||
| "lint": "yarn fmt:check", | ||
| "lint": "yarn lint:code && yarn fmt:check", | ||
| "lint:code": "eslint --cache .", | ||
| "fmt": "yarn fmt:base --log-level warn --write", | ||
| "fmt:check": "yarn fmt:base --check", | ||
| "fmt:base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .", | ||
| "fmt:base": "node ./node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .", | ||
| "fix": "yarn fix:code && yarn fmt", | ||
| "fix:code": "yarn lint:code --fix", | ||
| "test": "jest" | ||
@@ -41,3 +37,26 @@ }, | ||
| } | ||
| }, | ||
| "devDependencies": { | ||
| "@babel/core": "^7.4.4", | ||
| "@babel/preset-env": "^7.4.4", | ||
| "@eslint/js": "^9.28.0", | ||
| "@eslint/markdown": "^7.1.0", | ||
| "@stylistic/eslint-plugin": "^5.2.3", | ||
| "babel-jest": "^24.8.0", | ||
| "globals": "^16.2.0", | ||
| "eslint": "^9.28.0", | ||
| "eslint-config-webpack": "^4.6.3", | ||
| "eslint-config-prettier": "^10.1.5", | ||
| "eslint-plugin-import": "^2.31.0", | ||
| "eslint-plugin-jest": "^29.0.1", | ||
| "eslint-plugin-n": "^17.19.0", | ||
| "eslint-plugin-prettier": "^5.4.1", | ||
| "eslint-plugin-unicorn": "^60.0.0", | ||
| "jest": "^24.8.0", | ||
| "prettier": "^3.5.3", | ||
| "prettier-1": "npm:prettier@^1" | ||
| }, | ||
| "engines": { | ||
| "node": ">=6" | ||
| } | ||
| } |
+23
-17
@@ -7,11 +7,11 @@ # Tapable | ||
| const { | ||
| AsyncParallelBailHook, | ||
| AsyncParallelHook, | ||
| AsyncSeriesBailHook, | ||
| AsyncSeriesHook, | ||
| AsyncSeriesWaterfallHook, | ||
| SyncBailHook, | ||
| SyncHook, | ||
| SyncBailHook, | ||
| SyncWaterfallHook, | ||
| SyncLoopHook, | ||
| AsyncParallelHook, | ||
| AsyncParallelBailHook, | ||
| AsyncSeriesHook, | ||
| AsyncSeriesBailHook, | ||
| AsyncSeriesWaterfallHook | ||
| SyncWaterfallHook | ||
| } = require("tapable"); | ||
@@ -74,8 +74,7 @@ ``` | ||
| "GoogleMapsPlugin", | ||
| (source, target, routesList) => { | ||
| (source, target, routesList) => | ||
| // return a promise | ||
| return google.maps.findRoute(source, target).then((route) => { | ||
| google.maps.findRoute(source, target).then((route) => { | ||
| routesList.add(route); | ||
| }); | ||
| } | ||
| }) | ||
| ); | ||
@@ -111,3 +110,3 @@ myCar.hooks.calculateRoutes.tapAsync( | ||
| * to do that, use SyncWaterfallHook and AsyncSeriesWaterfallHook respectively | ||
| **/ | ||
| */ | ||
@@ -123,6 +122,6 @@ setSpeed(newSpeed) { | ||
| .promise(source, target, routesList) | ||
| .then((res) => { | ||
| .then((res) => | ||
| // res is undefined for AsyncParallelHook | ||
| return routesList.getRoutes(); | ||
| }); | ||
| routesList.getRoutes() | ||
| ); | ||
| } | ||
@@ -270,3 +269,7 @@ | ||
| name: string | Tap, | ||
| fn: (context?, ...args, callback: (err, result: Result) => void) => void | ||
| fn: ( | ||
| context?, | ||
| ...args, | ||
| callback: (err: Error | null, result: Result) => void | ||
| ) => void | ||
| ) => void; | ||
@@ -314,3 +317,6 @@ tapPromise: ( | ||
| promise: (...args) => Promise<Result>; | ||
| callAsync: (...args, callback: (err, result: Result) => void) => void; | ||
| callAsync: ( | ||
| ...args, | ||
| callback: (err: Error | null, result: Result) => void | ||
| ) => void; | ||
| } | ||
@@ -317,0 +323,0 @@ |
+4
-2
@@ -97,4 +97,5 @@ type FixedSizeArray<T extends number, U> = T extends 0 | ||
| T, | ||
| R = AsArray<T>[0], | ||
| AdditionalOptions = UnsetAdditionalOptions | ||
| > extends SyncHook<T, AsArray<T>[0], AdditionalOptions> {} | ||
| > extends SyncHook<T, R, AdditionalOptions> {} | ||
@@ -140,4 +141,5 @@ declare class AsyncHook< | ||
| T, | ||
| R = AsArray<T>[0], | ||
| AdditionalOptions = UnsetAdditionalOptions | ||
| > extends AsyncHook<T, AsArray<T>[0], AdditionalOptions> {} | ||
| > extends AsyncHook<T, R, AdditionalOptions> {} | ||
@@ -144,0 +146,0 @@ type HookFactory<H> = (key: any, hook?: H) => H; |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
48060
1.79%1294
0.15%333
1.83%3
-25%18
200%