Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

call-func

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

call-func - npm Package Compare versions

Comparing version 0.3.6 to 0.3.7

22

build/cjs/src/callfunc.js

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

exports["default"] = void 0;
var _reshowConstant = require("reshow-constant");
// @ts-check

@@ -13,25 +11,21 @@

* @param {Function|any} maybeFunc
* @param {Array} args
* @param {any[]} functionArguments
* @param {any} scope
* @param {any} def
* @param {any} defaultReturns
* @returns {any}
*/
var callFunc = function callFunc(maybeFunc, args, scope, def) {
if (args === void 0) {
args = [];
var callFunc = function callFunc(maybeFunc, functionArguments, scope, defaultReturns) {
if (functionArguments === void 0) {
functionArguments = [];
}
if (scope === void 0) {
scope = _reshowConstant.T_UNDEFINED;
}
if (def === void 0) {
def = _reshowConstant.T_UNDEFINED;
if (defaultReturns === void 0) {
defaultReturns = _reshowConstant.T_UNDEFINED;
}
return _reshowConstant.FUNCTION === typeof maybeFunc ? maybeFunc.apply(scope, args) : _reshowConstant.UNDEFINED !== typeof def ? def : maybeFunc;
return _reshowConstant.FUNCTION === typeof maybeFunc ? maybeFunc.apply(scope, functionArguments) : _reshowConstant.UNDEFINED !== typeof defaultReturns ? defaultReturns : maybeFunc;
};
var _default = callFunc;
exports["default"] = _default;
module.exports = exports.default;
"use strict";
var _interopRequireDefault = require("reshow-runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _callfunc = _interopRequireDefault(require("./callfunc.js"));
/**

@@ -17,7 +14,6 @@ * only run lasttime.

var _ref = option || {},
_ref$delay = _ref.delay,
delay = _ref$delay === void 0 ? 250 : _ref$delay,
args = _ref.args,
scope = _ref.scope;
_ref$delay = _ref.delay,
delay = _ref$delay === void 0 ? 250 : _ref$delay,
args = _ref.args,
scope = _ref.scope;
clearTimeout(timer);

@@ -29,5 +25,4 @@ timer = setTimeout(function () {

};
var _default = debounce;
exports["default"] = _default;
module.exports = exports.default;
"use strict";
var _interopRequireDefault = require("reshow-runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _callfunc = _interopRequireDefault(require("./callfunc.js"));
var defaultCall = function defaultCall(defaultFunc, func, scope) {

@@ -15,9 +12,7 @@ return function () {

}
return (0, _callfunc["default"])(func || defaultFunc, args, scope);
};
};
var _default = defaultCall;
exports["default"] = _default;
module.exports = exports.default;

@@ -5,3 +5,2 @@ "use strict";

exports["default"] = void 0;
/**

@@ -15,8 +14,6 @@ * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key

var _e$key;
return (_e$key = e.key) !== null && _e$key !== void 0 ? _e$key : e.keyCode;
};
var _default = getEventKey;
exports["default"] = _default;
module.exports = exports.default;
"use strict";
var _interopRequireDefault = require("reshow-runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.throttle = exports.register = exports.isRequired = exports.getEventKey = exports.defaultCall = exports["default"] = exports.debounce = exports.cleanAllRegister = void 0;
var _isRequired = _interopRequireDefault(require("./isRequired.js"));
exports.isRequired = _isRequired["default"];
var _throttle = _interopRequireDefault(require("./throttle.js"));
exports.throttle = _throttle["default"];
var _debounce = _interopRequireDefault(require("./debounce.js"));
exports.debounce = _debounce["default"];
var _defaultCall = _interopRequireDefault(require("./defaultCall.js"));
exports.defaultCall = _defaultCall["default"];
var _getEventKey = _interopRequireDefault(require("./getEventKey.js"));
exports.getEventKey = _getEventKey["default"];
var _register = require("./register.js");
exports.register = _register.register;
exports.cleanAllRegister = _register.cleanAllRegister;
var _callfunc = _interopRequireDefault(require("./callfunc.js"));
exports["default"] = _callfunc["default"];

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

exports["default"] = void 0;
var isRequired = function isRequired(name) {
throw new Error((name || "param") + " is required");
};
var _default = isRequired;
exports["default"] = _default;
module.exports = exports.default;
"use strict";
var _interopRequireDefault = require("reshow-runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.register = exports.cleanAllRegister = void 0;
var _classCallCheck2 = _interopRequireDefault(require("reshow-runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("reshow-runtime/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("reshow-runtime/helpers/defineProperty"));
var _reshowConstant = require("reshow-constant");
var _callfunc = _interopRequireDefault(require("./callfunc.js"));
var count = {

@@ -24,9 +17,6 @@ el: 0,

var wrapKey = "data-event-wrap-id";
var initEventWrap = function initEventWrap(el) {
var wrapId = el.getAttribute ? el.getAttribute(wrapKey) : el[wrapKey];
if (!wrapId) {
wrapId = ++count.el;
if (el.setAttribute) {

@@ -38,5 +28,3 @@ el.setAttribute(wrapKey, wrapId);

}
var obj = allWrapMap[wrapId];
if (!obj) {

@@ -46,10 +34,7 @@ obj = new EventWrap(wrapId, el);

}
return obj;
};
var EventWrap = /*#__PURE__*/function () {
function EventWrap(_id, el) {
var _this = this;
(0, _classCallCheck2["default"])(this, EventWrap);

@@ -61,15 +46,10 @@ (0, _defineProperty2["default"])(this, "optionMap", {});

var optionMap = _this.optionMap;
for (var _len = arguments.length, options = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
options[_key - 2] = arguments[_key];
}
optionMap[thisOptId] = [type, func].concat(options);
if (!_this.typeMap[type]) {
_this.typeMap[type] = [];
}
_this.typeMap[type].push(thisOptId);
(0, _callfunc["default"])(_this.el.addEventListener, optionMap[thisOptId], _this.el);

@@ -82,3 +62,2 @@ return thisOptId;

var id;
if (!isNaN(typeOrId) && optionMap[typeOrId]) {

@@ -91,8 +70,5 @@ id = typeOrId;

}
thisOptions = [typeOrId, func].concat(options);
}
(0, _callfunc["default"])(_this.el.removeEventListener, thisOptions, _this.el);
if (id) {

@@ -110,3 +86,2 @@ var type = thisOptions[0];

}
(0, _createClass2["default"])(EventWrap, [{

@@ -116,5 +91,3 @@ key: "cleanAll",

var _this2 = this;
var optionMap = this.optionMap;
if (null != type) {

@@ -135,9 +108,6 @@ if (this.typeMap[type]) {

}();
var register = function register(el) {
return initEventWrap(el);
};
exports.register = register;
var cleanAllRegister = function cleanAllRegister(type) {

@@ -148,3 +118,2 @@ (0, _reshowConstant.KEYS)(allWrapMap).forEach(function (key) {

};
exports.cleanAllRegister = cleanAllRegister;
"use strict";
var _interopRequireDefault = require("reshow-runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _callfunc = _interopRequireDefault(require("./callfunc.js"));
/**

@@ -15,19 +12,14 @@ * reduce run times.

var _threshhold;
threshhold = (_threshhold = threshhold) !== null && _threshhold !== void 0 ? _threshhold : 250;
var waiting = false;
var lastCall = false;
var run = function run(option) {
var _ref = option || {},
args = _ref.args,
scope = _ref.scope;
args = _ref.args,
scope = _ref.scope;
lastCall = false;
(0, _callfunc["default"])(func, args, scope);
};
return function (option) {
lastCall = true;
if (!waiting) {

@@ -38,3 +30,2 @@ waiting = true;

waiting = false;
if (needRunLast && lastCall) {

@@ -47,5 +38,4 @@ run(option);

};
var _default = throttle;
exports["default"] = _default;
module.exports = exports.default;
{
"version": "0.3.6",
"version": "0.3.7",
"name": "call-func",

@@ -35,6 +35,7 @@ "repository": {

"build:es": "BABEL_ENV=es babel src -d build/es/src --out-file-extension .mjs --root-mode upward",
"build:type": "npx -p typescript tsc src/index.js src/**/*.js --declaration --allowJs --emitDeclarationOnly --skipLibCheck --declarationDir types",
"build:type": "npx -p typescript tsc src/*.js --declaration --allowJs --emitDeclarationOnly --skipLibCheck --declarationDir types",
"build": "npm run clean && npm run build:cjs && npm run build:es && npm run build:type",
"mochaFor": "mocha -r global-jsdom/register",
"mocha": "npm run mochaFor -- 'build/es/**/__tests__/*.mjs'",
"test:report": "npm run build && npm run mochaFor -- --reporter mocha-junit-reporter --reporter-options mochaFile=./test_output/mocha.xml 'build/es/**/__tests__/*.mjs'",
"test": "npm run build && npm run mocha",

@@ -41,0 +42,0 @@ "prepublishOnly": "npm run test"

export default callFunc;
/**
* @param {Function|any} maybeFunc
* @param {Array} args
* @param {any[]} functionArguments
* @param {any} scope
* @param {any} def
* @param {any} defaultReturns
* @returns {any}
*/
declare function callFunc(maybeFunc: Function | any, args?: any[], scope?: any, def?: any): any;
declare function callFunc(maybeFunc: Function | any, functionArguments?: any[], scope?: any, defaultReturns?: any): any;

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

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

Sorry, the diff of this file is not supported yet

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