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

@rpldy/life-events

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rpldy/life-events - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

lib/cjs/lifePack.js

6

lib/cjs/consts.js

@@ -6,4 +6,6 @@ "use strict";

});
exports.LESYM = void 0;
exports.LE_PACK_SYM = exports.LESYM = void 0;
var LESYM = Symbol["for"]("__le__");
exports.LESYM = LESYM;
exports.LESYM = LESYM;
var LE_PACK_SYM = Symbol["for"]("__le__pack__");
exports.LE_PACK_SYM = LE_PACK_SYM;

@@ -8,2 +8,8 @@ "use strict";

});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function get() {
return _lifeEvents["default"];
}
});
Object.defineProperty(exports, "addLife", {

@@ -21,11 +27,17 @@ enumerable: true,

});
exports["default"] = void 0;
Object.defineProperty(exports, "createLifePack", {
enumerable: true,
get: function get() {
return _lifePack["default"];
}
});
var _lifeEvents = _interopRequireWildcard(require("./lifeEvents"));
var _lifePack = _interopRequireDefault(require("./lifePack"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _default = _lifeEvents["default"];
exports["default"] = _default;
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -18,2 +18,10 @@ "use strict";

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -38,7 +46,7 @@

//TODO: implement STATS
var getLE = function getLE(obj) {
var getLE = function (obj) {
return obj ? obj[_consts.LESYM] : null;
};
var getValidLE = function getValidLE(obj) {
var getValidLE = function (obj) {
var le = getLE(obj);

@@ -53,3 +61,3 @@

var isLE = function isLE(obj) {
var isLE = function (obj) {
return !!getLE(obj);

@@ -60,3 +68,3 @@ };

var addRegistration = function addRegistration(obj, name, cb) {
var addRegistration = function (obj, name, cb) {
var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

@@ -70,7 +78,2 @@ (0, _utils.validateFunction)(cb, "cb");

var regItem = {
name: name,
cb: cb,
once: once
};
var namedRegistry = le.registry[name] || [];

@@ -82,3 +85,7 @@

//only add same callback for a name once
namedRegistry.push(regItem);
namedRegistry.push({
name: name,
cb: cb,
once: once
});
le.registry[name] = namedRegistry;

@@ -92,3 +99,3 @@ }

var findRegistrations = function findRegistrations(obj, name) {
var findRegistrations = function (obj, name) {
var registry = getValidLE(obj).registry;

@@ -106,3 +113,3 @@ return name ? registry[name] ? registry[name].slice() : [] : // $FlowFixMe - flow doesnt know about Array.prototype.flat yet...

var getPublicMethods = function getPublicMethods() {
var getPublicMethods = function () {
return Object.entries(publicMethods).reduce(function (res, _ref) {

@@ -130,3 +137,3 @@ var _ref2 = _slicedToArray(_ref, 2),

var createApi = function createApi(target) {
var createApi = function (target) {
return Object.keys(apiMethods).reduce(function (res, name) {

@@ -140,3 +147,3 @@ res[name] = apiMethods[name].bind(target);

var cleanRegistryForName = function cleanRegistryForName(obj, name) {
var cleanRegistryForName = function (obj, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

@@ -150,3 +157,3 @@ var registry = getValidLE(obj).registry;

var removeRegItem = function removeRegItem(obj, name, cb) {
var removeRegItem = function (obj, name, cb) {
var registry = getValidLE(obj).registry;

@@ -193,2 +200,11 @@

if (regs.length) {
var _args$;
var packValue;
if (args.length === 1 && ((_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$[_consts.LE_PACK_SYM]) === true) {
//life-pack always returns array as params to spread
packValue = args[0].resolve();
}
results = regs.map(function (r) {

@@ -201,3 +217,5 @@ var result;

if (!args.length) {
if (packValue) {
result = r.cb.apply(r, _toConsumableArray(packValue));
} else if (!args.length) {
result = r.cb();

@@ -271,3 +289,3 @@ } else if (args.length === 1) {

var defineLifeData = function defineLifeData(target, options) {
var defineLifeData = function (target, options) {
var events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];

@@ -286,3 +304,3 @@ var registry = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

var addLife = function addLife(target) {
var addLife = function (target) {
var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

@@ -289,0 +307,0 @@ var options = arguments.length > 2 ? arguments[2] : undefined;

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

var validateFunction = function validateFunction(f, name) {
var validateFunction = function (f, name) {
if (!(0, _shared.isFunction)(f)) {

@@ -19,3 +19,3 @@ throw new Error("'".concat(name, "' is not a valid function"));

var isUndefined = function isUndefined(val) {
var isUndefined = function (val) {
return typeof val === "undefined";

@@ -22,0 +22,0 @@ };

@@ -1,1 +0,2 @@

export var LESYM = Symbol["for"]("__le__");
export var LESYM = Symbol["for"]("__le__");
export var LE_PACK_SYM = Symbol["for"]("__le__pack__");

@@ -1,3 +0,2 @@

import addLife, { isLE } from "./lifeEvents";
export default addLife;
export { addLife, isLE };
export { default, default as addLife, isLE } from "./lifeEvents";
export { default as createLifePack } from "./lifePack";

@@ -0,1 +1,9 @@

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -22,10 +30,10 @@

import { validateFunction, isUndefined } from "./utils";
import { LESYM } from "./consts";
import { LESYM, LE_PACK_SYM } from "./consts";
//TODO: implement STATS
var getLE = function getLE(obj) {
var getLE = function (obj) {
return obj ? obj[LESYM] : null;
};
var getValidLE = function getValidLE(obj) {
var getValidLE = function (obj) {
var le = getLE(obj);

@@ -40,7 +48,7 @@

var isLE = function isLE(obj) {
var isLE = function (obj) {
return !!getLE(obj);
};
var addRegistration = function addRegistration(obj, name, cb) {
var addRegistration = function (obj, name, cb) {
var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

@@ -54,7 +62,2 @@ validateFunction(cb, "cb");

var regItem = {
name: name,
cb: cb,
once: once
};
var namedRegistry = le.registry[name] || [];

@@ -66,3 +69,7 @@

//only add same callback for a name once
namedRegistry.push(regItem);
namedRegistry.push({
name: name,
cb: cb,
once: once
});
le.registry[name] = namedRegistry;

@@ -76,3 +83,3 @@ }

var findRegistrations = function findRegistrations(obj, name) {
var findRegistrations = function (obj, name) {
var registry = getValidLE(obj).registry;

@@ -90,3 +97,3 @@ return name ? registry[name] ? registry[name].slice() : [] : // $FlowFixMe - flow doesnt know about Array.prototype.flat yet...

var getPublicMethods = function getPublicMethods() {
var getPublicMethods = function () {
return Object.entries(publicMethods).reduce(function (res, _ref) {

@@ -114,3 +121,3 @@ var _ref2 = _slicedToArray(_ref, 2),

var createApi = function createApi(target) {
var createApi = function (target) {
return Object.keys(apiMethods).reduce(function (res, name) {

@@ -124,3 +131,3 @@ res[name] = apiMethods[name].bind(target);

var cleanRegistryForName = function cleanRegistryForName(obj, name) {
var cleanRegistryForName = function (obj, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

@@ -134,3 +141,3 @@ var registry = getValidLE(obj).registry;

var removeRegItem = function removeRegItem(obj, name, cb) {
var removeRegItem = function (obj, name, cb) {
var registry = getValidLE(obj).registry;

@@ -177,2 +184,11 @@

if (regs.length) {
var _args$;
var packValue;
if (args.length === 1 && ((_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$[LE_PACK_SYM]) === true) {
//life-pack always returns array as params to spread
packValue = args[0].resolve();
}
results = regs.map(function (r) {

@@ -185,3 +201,5 @@ var result;

if (!args.length) {
if (packValue) {
result = r.cb.apply(r, _toConsumableArray(packValue));
} else if (!args.length) {
result = r.cb();

@@ -255,3 +273,3 @@ } else if (args.length === 1) {

var defineLifeData = function defineLifeData(target, options) {
var defineLifeData = function (target, options) {
var events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];

@@ -270,3 +288,3 @@ var registry = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

var addLife = function addLife(target) {
var addLife = function (target) {
var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

@@ -273,0 +291,0 @@ var options = arguments.length > 2 ? arguments[2] : undefined;

import { isFunction } from "@rpldy/shared";
var validateFunction = function validateFunction(f, name) {
var validateFunction = function (f, name) {
if (!isFunction(f)) {

@@ -9,3 +9,3 @@ throw new Error("'".concat(name, "' is not a valid function"));

var isUndefined = function isUndefined(val) {
var isUndefined = function (val) {
return typeof val === "undefined";

@@ -12,0 +12,0 @@ };

{
"version": "0.6.0",
"version": "0.7.0",
"name": "@rpldy/life-events",

@@ -21,3 +21,3 @@ "description": "events pub/sub management with return values",

"dependencies": {
"@rpldy/shared": "^0.6.0",
"@rpldy/shared": "^0.7.0",
"is-promise": "^4.0.0"

@@ -31,3 +31,3 @@ },

},
"gitHead": "43de735c426078647a9768caa733ba6cfd190d32"
"gitHead": "5bd0ebc140b45e44b168511f501b9f22628abd56"
}

@@ -33,2 +33,8 @@ export type EventCallback = (...args: any[]) => unknown | void;

export interface LifePack<T> {
resolve: () => T,
}
export const createLifePack: <T>(creator: () => T) => LifePack<T>;
export default addLife;

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