New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

util-ex

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

util-ex - npm Package Compare versions

Comparing version 2.0.0-alpha.6 to 2.0.0-alpha.7

4

lib/createFunction.d.ts

@@ -5,3 +5,3 @@ /**

* @param {string} name - The name of the function.
* @param {string|string[]=} [args] - An array of argument names. or function body if it's string.
* @param {string|string[]=} [aArgs] - An array of argument names. or function body if it's string.
* @param {string} body - The function body as a string.

@@ -22,3 +22,3 @@ * @param {(string[]|Object)} [scope] - An array of scope names, or an object with scope names as keys and their corresponding values as values.

*/
export function createFunction(name: string, args?: (string | string[]) | undefined, body: string, scope?: (string[] | any), values?: any[], ...args: any[]): Function;
export function createFunction(name: string, aArgs?: (string | string[]) | undefined, body: string, scope?: (string[] | any), values?: any[], ...args: any[]): Function;
export default createFunction;

@@ -24,3 +24,3 @@ "use strict";

* @param {string} name - The name of the function.
* @param {string|string[]=} [args] - An array of argument names. or function body if it's string.
* @param {string|string[]=} [aArgs] - An array of argument names. or function body if it's string.
* @param {string} body - The function body as a string.

@@ -41,15 +41,15 @@ * @param {(string[]|Object)} [scope] - An array of scope names, or an object with scope names as keys and their corresponding values as values.

*/
function createFunction(name, args, body, scope, values) {
function createFunction(name, aArgs, body, scope, values) {
if (arguments.length === 1) {
return (0, _createFunction.default)(`function ${name}(){}`);
}
if (typeof args === 'string') {
if (typeof aArgs === 'string') {
values = scope;
scope = body;
body = args;
args = [];
} else if (args == null) {
args = [];
body = aArgs;
aArgs = [];
} else if (aArgs == null) {
aArgs = [];
}
body = `function ${name}(${args.join(', ')}) {\n${body}\n}`;
body = `function ${name}(${aArgs.join(', ')}) {\n${body}\n}`;
return (0, _createFunction.default)(body, scope, values);

@@ -56,0 +56,0 @@ }

@@ -87,3 +87,3 @@ /**

export default inject;
declare function createArguments(args: any, ...args: any[]): any;
declare function createArguments(aArgs: any, ...args: any[]): any;
declare function isArguments(v: any): any;

@@ -173,5 +173,7 @@ "use strict";

}
function createArguments(args) {
if (arguments.length !== 1 || !Array.isArray(args)) args = arguments;
const result = Array.apply(null, args);
function createArguments(aArgs) {
if (arguments.length !== 1 || !Array.isArray(aArgs)) {
aArgs = arguments;
}
const result = Array.apply(null, aArgs);
(0, _defineProperty.default)(result, '__arguments__', true);

@@ -178,0 +180,0 @@ return result;

@@ -9,3 +9,3 @@ /**

* @param {string|Function} name The name of the function or the function itself.
* @param {string[]} args An array of argument names for the function.
* @param {string[]} aArgs An array of argument names for the function.
* @param {string} body The body of the function.

@@ -28,3 +28,3 @@ * @param {object} scope The scope for the function.

*/
export function newFunction(name: string | Function, args: string[], body: string, scope: object, values: object, ...args: any[]): Function;
export function newFunction(name: string | Function, aArgs: string[], body: string, scope: object, values: object, ...args: any[]): Function;
export default newFunction;

@@ -34,3 +34,3 @@ "use strict";

* @param {string|Function} name The name of the function or the function itself.
* @param {string[]} args An array of argument names for the function.
* @param {string[]} aArgs An array of argument names for the function.
* @param {string} body The body of the function.

@@ -53,3 +53,3 @@ * @param {object} scope The scope for the function.

*/
function newFunction(name, args, body, scope, values) {
function newFunction(name, aArgs, body, scope, values) {
if (arguments.length === 1) {

@@ -62,14 +62,14 @@ if (!(0, _function.default)(name)) {

if ((0, _function.default)(name)) {
scope = args;
scope = aArgs;
values = body;
} else {
if ((0, _string.default)(args)) {
if ((0, _string.default)(aArgs)) {
values = scope;
scope = body;
body = args;
args = [];
} else if (args == null) {
args = [];
body = aArgs;
aArgs = [];
} else if (aArgs == null) {
aArgs = [];
}
name = `function ${name}(${args.join(', ')}) {\n${body}\n}`;
name = `function ${name}(${aArgs.join(', ')}) {\n${body}\n}`;
}

@@ -76,0 +76,0 @@ return (0, _createFunction.default)(name, scope, values);

@@ -5,3 +5,3 @@ {

"homepage": "https://github.com/snowyu/util-ex.js",
"version": "2.0.0-alpha.6",
"version": "2.0.0-alpha.7",
"author": {

@@ -77,4 +77,4 @@ "name": "Riceball LEE",

"dependencies": {
"inherits-ex": "^2.1.0-alpha.5"
"inherits-ex": "^2.1.0-alpha.6"
}
}

@@ -17,3 +17,3 @@ import _createFunc from "./_create-function.js";

* @param {string} name - The name of the function.
* @param {string|string[]=} [args] - An array of argument names. or function body if it's string.
* @param {string|string[]=} [aArgs] - An array of argument names. or function body if it's string.
* @param {string} body - The function body as a string.

@@ -34,17 +34,17 @@ * @param {(string[]|Object)} [scope] - An array of scope names, or an object with scope names as keys and their corresponding values as values.

*/
export function createFunction(name, args, body, scope, values) {
export function createFunction(name, aArgs, body, scope, values) {
if (arguments.length === 1) {
return _createFunc(`function ${ name }(){}`);
}
if (typeof args === 'string') {
if (typeof aArgs === 'string') {
values = scope;
scope = body;
body = args;
args = [];
} else if (args == null) {
args = [];
body = aArgs;
aArgs = [];
} else if (aArgs == null) {
aArgs = [];
}
body = `function ${ name }(${ args.join(', ') }) {\n${ body }\n}`;
body = `function ${ name }(${ aArgs.join(', ') }) {\n${ body }\n}`;
return _createFunc(body, scope, values);
};
export default createFunction;

@@ -165,6 +165,5 @@ import defineProperty from "inherits-ex/lib/defineProperty";

function createArguments(args) {
if (arguments.length !== 1 || !Array.isArray(args))
args = arguments;
const result = Array.apply(null, args);
function createArguments(aArgs) {
if (arguments.length !== 1 || !Array.isArray(aArgs)) {aArgs = arguments}
const result = Array.apply(null, aArgs);
defineProperty(result, '__arguments__', true);

@@ -171,0 +170,0 @@ return result;

@@ -27,3 +27,3 @@ import createFunc from './_create-function.js';

* @param {string|Function} name The name of the function or the function itself.
* @param {string[]} args An array of argument names for the function.
* @param {string[]} aArgs An array of argument names for the function.
* @param {string} body The body of the function.

@@ -46,3 +46,3 @@ * @param {object} scope The scope for the function.

*/
export function newFunction(name, args, body, scope, values) {
export function newFunction(name, aArgs, body, scope, values) {
if (arguments.length === 1) {

@@ -55,14 +55,14 @@ if (!isFunctionStr(name)) {

if (isFunctionStr(name)) {
scope = args;
scope = aArgs;
values = body;
} else {
if (isString(args)) {
if (isString(aArgs)) {
values = scope;
scope = body;
body = args;
args = [];
} else if (args == null) {
args = [];
body = aArgs;
aArgs = [];
} else if (aArgs == null) {
aArgs = [];
}
name = `function ${ name }(${ args.join(', ') }) {\n${ body }\n}`;
name = `function ${ name }(${ aArgs.join(', ') }) {\n${ body }\n}`;
}

@@ -69,0 +69,0 @@ return createFunc(name, scope, values);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc