vivisector
Advanced tools
Comparing version 1.1.3 to 1.2.0
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _isNativeReflectConstruct$1() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct$1()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return _wrapNativeSuper(Class); | ||
} | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
(function (_Error) { | ||
_inherits(ContractViolation, _Error); | ||
var _super = _createSuper(ContractViolation); | ||
function ContractViolation(message) { | ||
var _this; | ||
_classCallCheck(this, ContractViolation); | ||
_this = _super.call(this, message); | ||
_this.name = _this.constructor.name; | ||
return _this; | ||
} | ||
return ContractViolation; | ||
})(_wrapNativeSuper(Error)); | ||
function isString(prospect) { | ||
return toString.call(prospect) == '[object String]'; | ||
} | ||
function isObject(prospect) { | ||
return toString.call(prospect) == '[object Object]'; | ||
} | ||
function isArray(prospect) { | ||
return Array.isArray(prospect); | ||
} | ||
function not(prospect) { | ||
return !!!prospect; | ||
} | ||
/** | ||
@@ -671,3 +848,3 @@ * @param {Function} fn The callback to be executed after the timeout is lifted. | ||
/** | ||
* @param {Object} obj Object whose value will be copied and proxied. | ||
* @param {Object} obj Object whose value will be copied and proxied. | ||
* @summary Factory for instantiating proxied, observable Objects. | ||
@@ -691,3 +868,3 @@ * @description Copies Object and proxifies; configures necessary traps and broadcasts events upon the access thereof. | ||
// non-enumerable prop store - mitigate get|set events from being called thereon | ||
_internals = ['addEventListener', 'removeEventListener', 'identifier', 'type']; | ||
_internals = ['addEventListener', 'removeEventListener']; | ||
/** | ||
@@ -719,3 +896,3 @@ * @param {String} prop The property presently being accessed. | ||
return target; | ||
} // we use `Reflect` here as a simple mitigative effort to avoid violating Proxy invariants, as described in the specification here: | ||
} // we use `Reflect` here as a simple mitigative effort to avoid violating Proxy invariants, as described in the specification here: | ||
// https://www.ecma-international.org/ecma-262/8.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver | ||
@@ -776,3 +953,3 @@ | ||
return; | ||
} // make a deep clone here so as to break the chain of reference to the provided argument `obj` | ||
} // make a deep clone here so as to break the chain of reference to the provided argument `obj` | ||
// if we pass `obj` directly, the Proxy will modify the original target | ||
@@ -807,147 +984,22 @@ | ||
/* eslint-disable no-unused-vars */ | ||
function vivisect(subject) { | ||
if (not(isObject(subject)) && not(isArray(subject)) && not(isString(subject))) { | ||
throw new Error('The provided type must be an object, array, or string'); | ||
} | ||
/** | ||
* @summary A factory / wrapper for exporting the Vivisector.js `Observables` and their associated properties. | ||
* @description Exposes various JavaScript datatypes and primitives and extends them with both event-driven | ||
* properties (qua the `Observable`'s execution context), and ubiquitous Vivisector-contingent properties (qua the macro execution context). | ||
*/ | ||
// wrap in IIFE to align execution context in prospective 'non-Node' environments | ||
// we do this in the case we want to expose on global explicitly | ||
switch (true) { | ||
case isObject(subject): | ||
return new ObservableObject(subject); | ||
var index = (function (global) { | ||
// mitigate need to use `new` keyword by returning a discrete function constructor | ||
// to generate the object | ||
const Vx = function (datatype, data, options) { | ||
return new Vx.init(datatype, data, options); | ||
}; | ||
/* Private/Unexposed Props */ | ||
// global aggregation object - used to store and index all `Observables` | ||
case isArray(subject): | ||
return new ObservableArray(subject); | ||
case isString(subject): | ||
return new ObservableString(subject); | ||
const _observables = {}; | ||
/* Method Injection Library */ | ||
// meta-prototype for storing methods accessible to all `Observable` instances | ||
// place methods which you wish to expose on Vx instances here and uncomment reassignments below (`global` wrapper util) | ||
default: | ||
return subject; | ||
} | ||
} | ||
Vx.prototype = {// any methods added here will be exposed to *all* `Observables` | ||
// we can actually import other modules or libs here; in doing so, we need to further tighten the security | ||
// on global denominations so as to mitigate nasty dependency collisions (assuming we are using `global` - currently, no) | ||
// typecast: function(inboundType) { | ||
// do stuff | ||
// return new Vx.init(datatype, data, options); | ||
// } | ||
}; | ||
/* Datatype Factory */ | ||
// the actual method which is executed | ||
// this is mostly config for prospective macro-object use and ubiquitous methods | ||
Vx.init = function (datatype, data, options) { | ||
// this assignment will point to the execution context of the newly generated `Observable` | ||
// remaining vars are hoisted | ||
const _observableKeys = Object.keys(_observables); // transient Object for assembling prototype and defaults injection | ||
let _intermediateObject; | ||
if (datatype === 'Array') { | ||
_intermediateObject = new ObservableArray(data); | ||
} else if (datatype === 'String') { | ||
_intermediateObject = new ObservableString(data); | ||
} else if (datatype === 'Object') { | ||
_intermediateObject = new ObservableObject(data); | ||
} // unsupported / unprovided type | ||
else { | ||
throw new Error(`Error: datatype ${datatype} is not a supported option.`); | ||
} | ||
/* set defaults here */ | ||
// the type of a given `Observable` instance e.g. 'Array' | ||
const _type = datatype; // the unique identifier for a given `Observable` instance | ||
let _identifier; // if options passed, configure accordingly | ||
if (options) { | ||
/* | ||
Destructure id and enforce unique filter | ||
Here, we are evaluating a ternary expression wrapped inside of an IIFE. | ||
This IIFE accepts as input the `options` object and destructures the id inline. We are explicitly | ||
mapping the prop `uniqueIdentifier` and destructuring it away from the resolved IIFE. | ||
*/ | ||
const { | ||
uniqueIdentifier | ||
} = (({ | ||
id | ||
}) => ({ | ||
uniqueIdentifier: _observableKeys.includes(id.toString()) ? undefined : id | ||
/* prop2, prop3... */ | ||
}))(options); // if id is found in keys array of `_observables`, the instantiation should be terminated as the id is a duplicate | ||
if (!uniqueIdentifier) { | ||
throw new Error(`Error: Identifier ${options.id} is currently in use.`); | ||
} | ||
_identifier = uniqueIdentifier; | ||
} // no options object param provided | ||
else { | ||
// destructure length from keys Array | ||
const { | ||
length | ||
} = _observableKeys; | ||
_identifier = length; | ||
} // we can do this later at any point within this scope; leave until we need to do something with the type | ||
// _type = datatype; | ||
// Create a new Object of all ubiquitous props for which `defineProperty` will be called. Then, | ||
// destructure the key/value pairs from the Array produced by `Object.entries` and call `forEach` thereon | ||
// Ea. key will be collated as a computed property with its accompanying value | ||
Object.entries({ | ||
identifier: _identifier, | ||
type: _type | ||
}).forEach(([key, value]) => // use `defineProperty` for greater control granularity; set prop to non-enumerable | ||
Object.defineProperty(_intermediateObject, key, { | ||
configurable: false, | ||
enumerable: false, | ||
value: value | ||
})); // persist new `Observable` inside `_observables` at index `_identifier` | ||
_observables[_identifier] = _intermediateObject; | ||
return _intermediateObject; | ||
}; | ||
/* | ||
~ For use with currently inactive `global` execution context wrapper ~ | ||
point prototype of each `Observable` instance to the aforementioned meta prototype to expose ubiquitous methods | ||
ObservableArray.prototype = Vx.prototype; | ||
ObservableString.prototype = Vx.prototype; | ||
ObservableObject.prototype = Vx.prototype; | ||
point proto to same execution context so as to provide an optional caller alias, `Vx` | ||
global.Observable = global.Vx = Observable; | ||
*/ | ||
return Vx; | ||
})(); | ||
/* | ||
Passing `global` in lieu of `this`. | ||
Currently inactive, but applicable if we ever decide to go back to the `global` diad context approach. | ||
We pass the global object in lieu of `this` for a couple of very specific performance reasons: | ||
1. JavaScript always performs scope 'lookups' from the current function's scope *upward* until it finds an identifier; | ||
if we pass `this` as `global` into an IIFE, the IIFE's execution is the only time our code will need to process a scope lookup beyond | ||
the local scope for `this`. Subsequent references to `global` inside the IIFE will therefore never require a lookup beyond the local scope of the IIFE. | ||
2. JS minifiers won't minify direct references to anything without the context of the IIFE; | ||
we may need this param as a point-of-reference. | ||
*/ | ||
module.exports = index; | ||
exports.vivisect = vivisect; |
@@ -1,10 +0,40 @@ | ||
function _typeof(obj) { | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _typeof$1(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
_typeof$1 = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
_typeof$1 = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
@@ -14,61 +44,134 @@ }; | ||
return _typeof(obj); | ||
return _typeof$1(obj); | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof$1(call) === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _isNativeReflectConstruct$1() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct$1()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _arr; | ||
return _construct.apply(null, arguments); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return _wrapNativeSuper(Class); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
return arr2; | ||
(function (_Error) { | ||
_inherits(ContractViolation, _Error); | ||
var _super = _createSuper(ContractViolation); | ||
function ContractViolation(message) { | ||
var _this; | ||
_classCallCheck(this, ContractViolation); | ||
_this = _super.call(this, message); | ||
_this.name = _this.constructor.name; | ||
return _this; | ||
} | ||
return ContractViolation; | ||
})(_wrapNativeSuper(Error)); | ||
function isString(prospect) { | ||
return toString.call(prospect) == '[object String]'; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
function isObject(prospect) { | ||
return toString.call(prospect) == '[object Object]'; | ||
} | ||
function isArray(prospect) { | ||
return Array.isArray(prospect); | ||
} | ||
function not(prospect) { | ||
return !!!prospect; | ||
} | ||
function debounce(fn, ms) { | ||
@@ -514,2 +617,18 @@ var timeout; | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function ObservableObject(obj) { | ||
@@ -525,3 +644,3 @@ var _symbols = { | ||
}, | ||
_internals = ['addEventListener', 'removeEventListener', 'identifier', 'type']; | ||
_internals = ['addEventListener', 'removeEventListener']; | ||
@@ -606,69 +725,22 @@ var enforceConfigurableProps = function enforceConfigurableProps(prop) { | ||
var index = (function (global) { | ||
var Vx = function Vx(datatype, data, options) { | ||
return new Vx.init(datatype, data, options); | ||
}; | ||
function vivisect(subject) { | ||
if (not(isObject(subject)) && not(isArray(subject)) && not(isString(subject))) { | ||
throw new Error('The provided type must be an object, array, or string'); | ||
} | ||
var _observables = {}; | ||
Vx.prototype = {}; | ||
switch (true) { | ||
case isObject(subject): | ||
return new ObservableObject(subject); | ||
Vx.init = function (datatype, data, options) { | ||
var _observableKeys = Object.keys(_observables); | ||
case isArray(subject): | ||
return new ObservableArray(subject); | ||
var _intermediateObject; | ||
case isString(subject): | ||
return new ObservableString(subject); | ||
if (datatype === 'Array') { | ||
_intermediateObject = new ObservableArray(data); | ||
} else if (datatype === 'String') { | ||
_intermediateObject = new ObservableString(data); | ||
} else if (datatype === 'Object') { | ||
_intermediateObject = new ObservableObject(data); | ||
} else { | ||
throw new Error("Error: datatype ".concat(datatype, " is not a supported option.")); | ||
} | ||
default: | ||
return subject; | ||
} | ||
} | ||
var _type = datatype; | ||
var _identifier; | ||
if (options) { | ||
var _ref = function (_ref2) { | ||
var id = _ref2.id; | ||
return { | ||
uniqueIdentifier: _observableKeys.includes(id.toString()) ? undefined : id | ||
}; | ||
}(options), | ||
uniqueIdentifier = _ref.uniqueIdentifier; | ||
if (!uniqueIdentifier) { | ||
throw new Error("Error: Identifier ".concat(options.id, " is currently in use.")); | ||
} | ||
_identifier = uniqueIdentifier; | ||
} else { | ||
var length = _observableKeys.length; | ||
_identifier = length; | ||
} | ||
Object.entries({ | ||
identifier: _identifier, | ||
type: _type | ||
}).forEach(function (_ref3) { | ||
var _ref4 = _slicedToArray(_ref3, 2), | ||
key = _ref4[0], | ||
value = _ref4[1]; | ||
return Object.defineProperty(_intermediateObject, key, { | ||
configurable: false, | ||
enumerable: false, | ||
value: value | ||
}); | ||
}); | ||
_observables[_identifier] = _intermediateObject; | ||
return _intermediateObject; | ||
}; | ||
return Vx; | ||
})(); | ||
export default index; | ||
export { vivisect }; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Vx = factory()); | ||
}(this, (function () { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vivisector = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
function _typeof(obj) { | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _typeof$1(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
_typeof$1 = function _typeof(obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
_typeof$1 = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
@@ -20,61 +50,134 @@ }; | ||
return _typeof(obj); | ||
return _typeof$1(obj); | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof$1(call) === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _isNativeReflectConstruct$1() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
function _construct(Parent, args, Class) { | ||
if (_isNativeReflectConstruct$1()) { | ||
_construct = Reflect.construct; | ||
} else { | ||
_construct = function _construct(Parent, args, Class) { | ||
var a = [null]; | ||
a.push.apply(a, args); | ||
var Constructor = Function.bind.apply(Parent, a); | ||
var instance = new Constructor(); | ||
if (Class) _setPrototypeOf(instance, Class.prototype); | ||
return instance; | ||
}; | ||
} | ||
return _arr; | ||
return _construct.apply(null, arguments); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
constructor: { | ||
value: Wrapper, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
return _setPrototypeOf(Wrapper, Class); | ||
}; | ||
return _wrapNativeSuper(Class); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
return arr2; | ||
(function (_Error) { | ||
_inherits(ContractViolation, _Error); | ||
var _super = _createSuper(ContractViolation); | ||
function ContractViolation(message) { | ||
var _this; | ||
_classCallCheck(this, ContractViolation); | ||
_this = _super.call(this, message); | ||
_this.name = _this.constructor.name; | ||
return _this; | ||
} | ||
return ContractViolation; | ||
})(_wrapNativeSuper(Error)); | ||
function isString(prospect) { | ||
return toString.call(prospect) == '[object String]'; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
function isObject(prospect) { | ||
return toString.call(prospect) == '[object Object]'; | ||
} | ||
function isArray(prospect) { | ||
return Array.isArray(prospect); | ||
} | ||
function not(prospect) { | ||
return !!!prospect; | ||
} | ||
function debounce(fn, ms) { | ||
@@ -520,2 +623,18 @@ var timeout; | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function ObservableObject(obj) { | ||
@@ -531,3 +650,3 @@ var _symbols = { | ||
}, | ||
_internals = ['addEventListener', 'removeEventListener', 'identifier', 'type']; | ||
_internals = ['addEventListener', 'removeEventListener']; | ||
@@ -612,71 +731,26 @@ var enforceConfigurableProps = function enforceConfigurableProps(prop) { | ||
var index = (function (global) { | ||
var Vx = function Vx(datatype, data, options) { | ||
return new Vx.init(datatype, data, options); | ||
}; | ||
function vivisect(subject) { | ||
if (not(isObject(subject)) && not(isArray(subject)) && not(isString(subject))) { | ||
throw new Error('The provided type must be an object, array, or string'); | ||
} | ||
var _observables = {}; | ||
Vx.prototype = {}; | ||
switch (true) { | ||
case isObject(subject): | ||
return new ObservableObject(subject); | ||
Vx.init = function (datatype, data, options) { | ||
var _observableKeys = Object.keys(_observables); | ||
case isArray(subject): | ||
return new ObservableArray(subject); | ||
var _intermediateObject; | ||
case isString(subject): | ||
return new ObservableString(subject); | ||
if (datatype === 'Array') { | ||
_intermediateObject = new ObservableArray(data); | ||
} else if (datatype === 'String') { | ||
_intermediateObject = new ObservableString(data); | ||
} else if (datatype === 'Object') { | ||
_intermediateObject = new ObservableObject(data); | ||
} else { | ||
throw new Error("Error: datatype ".concat(datatype, " is not a supported option.")); | ||
} | ||
default: | ||
return subject; | ||
} | ||
} | ||
var _type = datatype; | ||
exports.vivisect = vivisect; | ||
var _identifier; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
if (options) { | ||
var _ref = function (_ref2) { | ||
var id = _ref2.id; | ||
return { | ||
uniqueIdentifier: _observableKeys.includes(id.toString()) ? undefined : id | ||
}; | ||
}(options), | ||
uniqueIdentifier = _ref.uniqueIdentifier; | ||
if (!uniqueIdentifier) { | ||
throw new Error("Error: Identifier ".concat(options.id, " is currently in use.")); | ||
} | ||
_identifier = uniqueIdentifier; | ||
} else { | ||
var length = _observableKeys.length; | ||
_identifier = length; | ||
} | ||
Object.entries({ | ||
identifier: _identifier, | ||
type: _type | ||
}).forEach(function (_ref3) { | ||
var _ref4 = _slicedToArray(_ref3, 2), | ||
key = _ref4[0], | ||
value = _ref4[1]; | ||
return Object.defineProperty(_intermediateObject, key, { | ||
configurable: false, | ||
enumerable: false, | ||
value: value | ||
}); | ||
}); | ||
_observables[_identifier] = _intermediateObject; | ||
return _intermediateObject; | ||
}; | ||
return Vx; | ||
})(); | ||
return index; | ||
}))); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Vx=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var u,a=e[Symbol.iterator]();!(n=(u=a.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function n(e,t){Object.defineProperty(e,"addEventListener",{configurable:!1,enumerable:!1,writable:!1,value:function(r,n,i){if(!((r=(""+r).toLowerCase())in t))throw new Error("Error: Invalid event name.");if("function"!=typeof n)throw new Error("Error: Invalid handler.");if(i){var o=n.name;n=function(e,t){var r;return function(n){clearTimeout(r),r=setTimeout((function(){return e(n)}),t)}}(n,i),u=n,a=o,Object.defineProperty(u,"name",{value:a,configurable:!0}),n=u}var u,a;return t[r].push(n),e}})}function i(e,t){Object.defineProperty(e,"removeEventListener",{configurable:!1,enumerable:!1,writable:!1,value:function(r,n){if(!((r=(""+r).toLowerCase())in t))throw new Error("Error: Invalid event name.");if("function"!=typeof n)throw new Error("Error: Invalid handler.");for(var i=t[r],o=i.length;--o>=0;)i[o]!==n&&i[o].name!==n.name||i.splice(o,1);return e}})}function o(e,t,r){r[e.type].forEach((function(r){r.call(t,e)}))}function u(e){var t=this,r=this,u={itemadded:[],itemremoved:[],itemset:[],mutated:[]},a=[],f=function(e){e in r||Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){return a[e]},set:function(t){a[e]=t,o({type:"itemset",index:e,item:t},r,u)}})};Object.defineProperty(r,"value",{configurable:!1,enumerable:!1,get:function(){return a},set:function(e){e instanceof Array&&(a=e,o({type:"mutated",index:"all",item:e},r,u))}}),Object.defineProperty(r,"findIndexAll",{configurable:!1,enumerable:!1,writable:!1,value:function(e){var t=[];return a.forEach((function(r,n){r===e&&t.push(n)})),t}}),Object.defineProperty(r,"findIndexAllDeep",{configurable:!1,enumerable:!1,writable:!1,value:function(e){var r=[];return t.some(function t(n){return function(i,o){return i===e&&r.push(n.concat(o)),Array.isArray(i)&&i.some(t(n.concat(o)))}}([])),r}}),n(r,u),i(r,u),Object.defineProperty(r,"push",{configurable:!1,enumerable:!1,writable:!1,value:function(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return n.forEach((function(t){e=a.length,a.push(t),f(e),o({type:"itemadded",index:e,item:t},r,u)})),a.length}}),Object.defineProperty(r,"pop",{configurable:!1,enumerable:!1,writable:!1,value:function(){if(a.length>0){var e=a.length-1,t=a.pop();return delete r[e],o({type:"itemremoved",index:e,item:t},r,u),t}}}),Object.defineProperty(r,"unshift",{configurable:!1,enumerable:!1,writable:!1,value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.forEach((function(e,t){a.splice(t,0,e),f(a.length-1),o({type:"itemadded",index:t,item:e},r,u)})),a.forEach((function(e,n){n>=t.length&&o({type:"itemset",index:n,item:e},r,u)})),a.length}}),Object.defineProperty(r,"shift",{configurable:!1,enumerable:!1,writable:!1,value:function(){if(a.length>0){var e=a.shift();return delete r[a.length],o({type:"itemremoved",index:0,item:e},r,u),e}}}),Object.defineProperty(r,"splice",{configurable:!1,enumerable:!1,writable:!1,value:function(){for(var e=[],t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];var l,c=n[0],p=n[1],y=n.slice(2);for(c=null==c?0:c<0?a.length+c:c,p=null==p?a.length-c:p>0?p:0;p--;)l=a.splice(c,1)[0],e.push(l),delete r[a.length],o({type:"itemremoved",index:c+e.length-1,item:l},r,u);return y.forEach((function(e){a.splice(c,0,e),f(a.length-1),o({type:"itemadded",index:c,item:e},r,u),c++})),e}}),Object.defineProperty(r,"length",{configurable:!1,enumerable:!1,get:function(){return a.length},set:function(e){var t=Number(e),n=a.length;if(!(t%1==0&&t>=0))throw new RangeError("Error: Invalid array length.");t<n?r.splice(t):t>n&&Reflect.apply(r.push,r,new Array(t-n)),a.length=t}}),Object.getOwnPropertyNames(Array.prototype).forEach((function(e){e in r||Object.defineProperty(r,e,{configurable:!1,enumerable:!1,writable:!1,value:Array.prototype[e]})})),e instanceof Array&&Reflect.apply(r.push,r,e)}function a(e){var t=this,r={mutated:[]};"string"==typeof e&&(t[0]=String(e));var u=function(e,t){var r=e[0].valueOf();return e[0]=String(t),{value:r,mutant:e[0].valueOf()}};Object.defineProperty(t,"value",{configurable:!1,enumerable:!1,get:function(){if(t[0])return t[0].valueOf()},set:function(e){"string"==typeof e&&o(Object.assign({type:"mutated"},u(t,e)),t,r)}}),Object.defineProperty(t,"reassign",{configurable:!1,enumerable:!1,writable:!1,value:function(e){if("string"!=typeof e)throw new Error("Error: Invalid type.");return o(Object.assign({type:"mutated"},u(t,e)),t,r),t}}),n(t,r),i(t,r),Object.defineProperty(t,"split",{configurable:!1,enumerable:!1,writable:!1,value:function(e){return t[0].valueOf().split(e)}}),Object.defineProperty(t,"length",{configurable:!1,enumerable:!1,get:function(){return t[0].length},set:function(){Function.prototype()}}),Object.getOwnPropertyNames(String.prototype).forEach((function(e){e in t||Object.defineProperty(t,e,{configurable:!1,enumerable:!1,writable:!1,value:function(){var r;return(r=t[0])[e].apply(r,arguments)}})}))}function f(t){var r=Symbol.for("_internal"),u=Symbol.for("_isProxy"),a={itemget:[],itemdeleted:[],itemset:[]},f=["addEventListener","removeEventListener","identifier","type"],l=function(e){if(f.includes(e))throw new Error("Error: Property '".concat(e,"' is non-configurable."))},c={get:function(t,n,i){if(n===u)return!0;if(n===r)return t;var l=Reflect.get(t,n,i);return"object"===e(l)?new Proxy(l,c):(l&&!f.includes(n)&&o({type:"itemget",prop:n,target:t,value:l},this,a),l)},set:function(e,t,r,n){return l(t),o({type:"itemset",prop:t,target:e,value:r},this,a),Reflect.set(e,t,r)},deleteProperty:function(e,t){l(t);var r=JSON.stringify(e,null,0),n=Reflect.deleteProperty(e,t);return o({type:"itemdeleted",prop:t,target:r,value:n},this,a),n}};if(t instanceof Object){var p=new Proxy(JSON.parse(JSON.stringify(t)),c);return Object.defineProperty(p,"value",{configurable:!1,enumerable:!1,get:function(){return Object.assign({},p[r])},set:function(e){}}),n(p,a),i(p,a),p}}var l,c;return c={},(l=function e(t,r,n){return new e.init(t,r,n)}).prototype={},l.init=function(e,r,n){var i,o=Object.keys(c);if("Array"===e)i=new u(r);else if("String"===e)i=new a(r);else{if("Object"!==e)throw new Error("Error: datatype ".concat(e," is not a supported option."));i=new f(r)}var l,p,y=e;if(n){var b=(p=n.id,{uniqueIdentifier:o.includes(p.toString())?void 0:p}).uniqueIdentifier;if(!b)throw new Error("Error: Identifier ".concat(n.id," is currently in use."));l=b}else l=o.length;return Object.entries({identifier:l,type:y}).forEach((function(e){var r=t(e,2),n=r[0],o=r[1];return Object.defineProperty(i,n,{configurable:!1,enumerable:!1,value:o})})),c[l]=i,i},l})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vivisector={})}(this,(function(e){"use strict";function t(e,n){return(t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,n)}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function u(e,n,r){return(u=i()?Reflect.construct:function(e,n,r){var o=[null];o.push.apply(o,n);var i=new(Function.bind.apply(e,o));return r&&t(i,r.prototype),i}).apply(null,arguments)}function c(e){var n="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,i)}function i(){return u(e,arguments,o(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),t(i,e)})(e)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=o(e);if(t){var u=o(this).constructor;n=Reflect.construct(i,arguments,u)}else n=i.apply(this,arguments);return r(this,n)}}function a(e){return"[object String]"==toString.call(e)}function l(e){return"[object Object]"==toString.call(e)}function p(e){return Array.isArray(e)}function s(e){return!e}function y(e,t){Object.defineProperty(e,"addEventListener",{configurable:!1,enumerable:!1,writable:!1,value:function(n,r,o){if(!((n=(""+n).toLowerCase())in t))throw new Error("Error: Invalid event name.");if("function"!=typeof r)throw new Error("Error: Invalid handler.");if(o){var i=r.name;r=function(e,t){var n;return function(r){clearTimeout(n),n=setTimeout((function(){return e(r)}),t)}}(r,o),u=r,c=i,Object.defineProperty(u,"name",{value:c,configurable:!0}),r=u}var u,c;return t[n].push(r),e}})}function b(e,t){Object.defineProperty(e,"removeEventListener",{configurable:!1,enumerable:!1,writable:!1,value:function(n,r){if(!((n=(""+n).toLowerCase())in t))throw new Error("Error: Invalid event name.");if("function"!=typeof r)throw new Error("Error: Invalid handler.");for(var o=t[n],i=o.length;--i>=0;)o[i]!==r&&o[i].name!==r.name||o.splice(i,1);return e}})}function d(e,t,n){n[e.type].forEach((function(n){n.call(t,e)}))}function m(e){var t=this,n=this,r={itemadded:[],itemremoved:[],itemset:[],mutated:[]},o=[],i=function(e){e in n||Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){return o[e]},set:function(t){o[e]=t,d({type:"itemset",index:e,item:t},n,r)}})};Object.defineProperty(n,"value",{configurable:!1,enumerable:!1,get:function(){return o},set:function(e){e instanceof Array&&(o=e,d({type:"mutated",index:"all",item:e},n,r))}}),Object.defineProperty(n,"findIndexAll",{configurable:!1,enumerable:!1,writable:!1,value:function(e){var t=[];return o.forEach((function(n,r){n===e&&t.push(r)})),t}}),Object.defineProperty(n,"findIndexAllDeep",{configurable:!1,enumerable:!1,writable:!1,value:function(e){var n=[];return t.some(function t(r){return function(o,i){return o===e&&n.push(r.concat(i)),Array.isArray(o)&&o.some(t(r.concat(i)))}}([])),n}}),y(n,r),b(n,r),Object.defineProperty(n,"push",{configurable:!1,enumerable:!1,writable:!1,value:function(){for(var e,t=arguments.length,u=new Array(t),c=0;c<t;c++)u[c]=arguments[c];return u.forEach((function(t){e=o.length,o.push(t),i(e),d({type:"itemadded",index:e,item:t},n,r)})),o.length}}),Object.defineProperty(n,"pop",{configurable:!1,enumerable:!1,writable:!1,value:function(){if(o.length>0){var e=o.length-1,t=o.pop();return delete n[e],d({type:"itemremoved",index:e,item:t},n,r),t}}}),Object.defineProperty(n,"unshift",{configurable:!1,enumerable:!1,writable:!1,value:function(){for(var e=arguments.length,t=new Array(e),u=0;u<e;u++)t[u]=arguments[u];return t.forEach((function(e,t){o.splice(t,0,e),i(o.length-1),d({type:"itemadded",index:t,item:e},n,r)})),o.forEach((function(e,o){o>=t.length&&d({type:"itemset",index:o,item:e},n,r)})),o.length}}),Object.defineProperty(n,"shift",{configurable:!1,enumerable:!1,writable:!1,value:function(){if(o.length>0){var e=o.shift();return delete n[o.length],d({type:"itemremoved",index:0,item:e},n,r),e}}}),Object.defineProperty(n,"splice",{configurable:!1,enumerable:!1,writable:!1,value:function(){for(var e=[],t=arguments.length,u=new Array(t),c=0;c<t;c++)u[c]=arguments[c];var f,a=u[0],l=u[1],p=u.slice(2);for(a=null==a?0:a<0?o.length+a:a,l=null==l?o.length-a:l>0?l:0;l--;)f=o.splice(a,1)[0],e.push(f),delete n[o.length],d({type:"itemremoved",index:a+e.length-1,item:f},n,r);return p.forEach((function(e){o.splice(a,0,e),i(o.length-1),d({type:"itemadded",index:a,item:e},n,r),a++})),e}}),Object.defineProperty(n,"length",{configurable:!1,enumerable:!1,get:function(){return o.length},set:function(e){var t=Number(e),r=o.length;if(!(t%1==0&&t>=0))throw new RangeError("Error: Invalid array length.");t<r?n.splice(t):t>r&&Reflect.apply(n.push,n,new Array(t-r)),o.length=t}}),Object.getOwnPropertyNames(Array.prototype).forEach((function(e){e in n||Object.defineProperty(n,e,{configurable:!1,enumerable:!1,writable:!1,value:Array.prototype[e]})})),e instanceof Array&&Reflect.apply(n.push,n,e)}function v(e){var t=this,n={mutated:[]};"string"==typeof e&&(t[0]=String(e));var r=function(e,t){var n=e[0].valueOf();return e[0]=String(t),{value:n,mutant:e[0].valueOf()}};Object.defineProperty(t,"value",{configurable:!1,enumerable:!1,get:function(){if(t[0])return t[0].valueOf()},set:function(e){"string"==typeof e&&d(Object.assign({type:"mutated"},r(t,e)),t,n)}}),Object.defineProperty(t,"reassign",{configurable:!1,enumerable:!1,writable:!1,value:function(e){if("string"!=typeof e)throw new Error("Error: Invalid type.");return d(Object.assign({type:"mutated"},r(t,e)),t,n),t}}),y(t,n),b(t,n),Object.defineProperty(t,"split",{configurable:!1,enumerable:!1,writable:!1,value:function(e){return t[0].valueOf().split(e)}}),Object.defineProperty(t,"length",{configurable:!1,enumerable:!1,get:function(){return t[0].length},set:function(){Function.prototype()}}),Object.getOwnPropertyNames(String.prototype).forEach((function(e){e in t||Object.defineProperty(t,e,{configurable:!1,enumerable:!1,writable:!1,value:function(){var n;return(n=t[0])[e].apply(n,arguments)}})}))}function g(e){return(g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function h(e){var t=Symbol.for("_internal"),n=Symbol.for("_isProxy"),r={itemget:[],itemdeleted:[],itemset:[]},o=["addEventListener","removeEventListener"],i=function(e){if(o.includes(e))throw new Error("Error: Property '".concat(e,"' is non-configurable."))},u={get:function(e,i,c){if(i===n)return!0;if(i===t)return e;var f=Reflect.get(e,i,c);return"object"===g(f)?new Proxy(f,u):(f&&!o.includes(i)&&d({type:"itemget",prop:i,target:e,value:f},this,r),f)},set:function(e,t,n,o){return i(t),d({type:"itemset",prop:t,target:e,value:n},this,r),Reflect.set(e,t,n)},deleteProperty:function(e,t){i(t);var n=JSON.stringify(e,null,0),o=Reflect.deleteProperty(e,t);return d({type:"itemdeleted",prop:t,target:n,value:o},this,r),o}};if(e instanceof Object){var c=new Proxy(JSON.parse(JSON.stringify(e)),u);return Object.defineProperty(c,"value",{configurable:!1,enumerable:!1,get:function(){return Object.assign({},c[t])},set:function(e){}}),y(c,r),b(c,r),c}}!function(e){!function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&t(e,n)}(r,e);var n=f(r);function r(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),(t=n.call(this,e)).name=t.constructor.name,t}}(c(Error)),e.vivisect=function(e){if(s(l(e))&&s(p(e))&&s(a(e)))throw new Error("The provided type must be an object, array, or string");switch(!0){case l(e):return new h(e);case p(e):return new m(e);case a(e):return new v(e);default:return e}},Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "vivisector", | ||
"version": "1.1.3", | ||
"description": "node.js library for creating observable datatypes", | ||
"version": "1.2.0", | ||
"description": "reactive JavaScript programming in a box", | ||
"main": "./dist/vivisector.cjs.js", | ||
@@ -22,2 +22,6 @@ "browser": "./dist/vivisector.umd.js", | ||
}, | ||
"setupFilesAfterEnv": [ | ||
"<rootDir>/__tests__/setup.js" | ||
], | ||
"testRegex": ".test.js$", | ||
"coverageDirectory": "./coverage", | ||
@@ -30,13 +34,15 @@ "collectCoverage": true, | ||
"global": { | ||
"branches": 95, | ||
"functions": 100, | ||
"lines": 100, | ||
"statements": 100 | ||
"branches": 90, | ||
"functions": 90, | ||
"lines": 90, | ||
"statements": 90 | ||
} | ||
} | ||
}, | ||
"errorOnDeprecated": true, | ||
"verbose": true | ||
}, | ||
"lint-staged": { | ||
"lib/**/*.js": [ | ||
"npm run lint", | ||
"npm run test" | ||
"yarn run lint", | ||
"yarn run test" | ||
] | ||
@@ -78,3 +84,4 @@ }, | ||
"event-bound objects", | ||
"micro-library" | ||
"micro-library", | ||
"reactive programming" | ||
], | ||
@@ -93,3 +100,4 @@ "author": "Matthew T Zito", | ||
"@rollup/plugin-babel": "5.3.0", | ||
"@rollup/plugin-node-resolve": "11.2.0", | ||
"@rollup/plugin-commonjs": "18.0.0", | ||
"@rollup/plugin-node-resolve": "11.2.1", | ||
"babel-eslint": "^10.1.0", | ||
@@ -100,4 +108,5 @@ "babel-jest": "26.6.3", | ||
"eslint": "^7.21.0", | ||
"husky": "^4.3.8", | ||
"husky": "4.3.8", | ||
"jest": "^26.6.3", | ||
"js-heuristics": "1.1.0", | ||
"lint-staged": "10.5.4", | ||
@@ -104,0 +113,0 @@ "rimraf": "^3.0.2", |
219
README.md
@@ -1,2 +0,2 @@ | ||
![Vivisector Logo](https://github.com/MatthewZito/vivisector-js/blob/master/documentation/vx.png) | ||
![Vivisector Logo](https://github.com/MatthewZito/vivisector-js/blob/master/documentation/`vivisect`.png) | ||
@@ -10,36 +10,41 @@ # Vivisector.js | Create event-driven datatypes | ||
- [Introduction](#intro) | ||
- [Features](#feat) | ||
- [Installation + Usage](#usage) | ||
- [Documentation](#docs) | ||
- [Introduction](#intro) | ||
- [Features](#feat) | ||
- [Installation + Usage](#usage) | ||
- [Documentation](#docs) | ||
## <a name="intro"></a> Introduction | ||
*Vivisector.js* is a light-weight JavaScript library that exposes custom event-driven datatypes. *Vivisector's* *Observable* types broadcast unique events correlated to specific types of mutations and accessors. As such, one can bind methods to variables and render them event-bound. | ||
*Vivisector* is a light-weight JavaScript library for reactive programming. *Vivisector's* *Observable* types broadcast unique events correlated to specific types of mutations and accessors. As such, one can bind methods to variables and render them event-bound. | ||
*Vivisector* is flexible, compact, and straightforward; it affords you fine-grained control by allowing you to decide when and what happens when a variable changes. | ||
### <a name="feat"></a> Features | ||
- custom *Observable* datatypes for Array, Object/Array, and String data | ||
- all datatypes are pure functions | ||
- instantly link/unlink actions to a variable's state | ||
- bind unlimited callbacks to specific types of state-mutation events *e.g. `itemadded`, `itemremoved`* | ||
- custom, chainable methods maintain stable execution context *i.e. method-chaining without the need to explicitly pipe `this`* | ||
- helper accessors on all *Observables* to simplify evaluation | ||
- no need to use `new` keyword, no configuration; `Vivisector` types work out-of-the-box | ||
- absolutely zero dependencies | ||
- lightweight, reactive programming with no setup or boilerplate | ||
- Observe prototype methods on Arrays, Objects, Strings | ||
- instantly link/unlink actions to a variable's state | ||
- bind unlimited callbacks to specific types of state-mutation events *e.g. `itemadded`, `itemremoved`* | ||
- custom, chainable methods maintain stable execution context *i.e. method-chaining without the need to explicitly pipe `this`* | ||
- helper accessors on all *Observables* to simplify evaluation | ||
- no need to use `new` keyword, no configuration; `Vivisector` types work out-of-the-box | ||
- absolutely zero dependencies | ||
## <a name="usage"></a> Installation and Usage | ||
[Install via NPM](https://www.npmjs.com/package/vivisector) with `npm i vivisector`. | ||
Import *Vivisector's* caller alias `Vx`: | ||
Import *Vivisector's* caller alias `vivisect`: | ||
```js | ||
const { vivisect } = require("vivisector"); // assuming cjs - Vivisector supports esm, too | ||
``` | ||
const Vx = require("vivisector"); // assuming cjs - Vivisector supports esm, too | ||
``` | ||
Create a new *Observable* - in this example, of type `Array` - and register a handler to fire when any *new elements* are added: | ||
``` | ||
```js | ||
const logAdditions = ({item, index}) => console.log(`Added ${item} at index ${index}.`); | ||
const users = Vx("Array", ["Alice","Bob"]); | ||
const users = vivisect(["Alice", "Bob"]); | ||
users.addEventListener("itemadded", logAdditions); | ||
@@ -54,34 +59,33 @@ // every time an item is added to the array, fire `logAdditions` | ||
- [See Usage Guide for `ObservableArray`](https://github.com/MatthewZito/vivisector-js/blob/master/documentation/usage-observable-array.md) | ||
- [See Usage Guide for `ObservableString`](https://github.com/MatthewZito/vivisector-js/blob/master/documentation/usage-observable-string.md) | ||
- [See Usage Guide for arrays](https://github.com/MatthewZito/vivisector-js/blob/master/documentation/usage-observable-array.md) | ||
- [See Usage Guide for strings](https://github.com/MatthewZito/vivisector-js/blob/master/documentation/usage-observable-string.md) | ||
Because Arrays *are* Objects, you certainly can instantiate an `ObservableObject` with Array data. However, you might find some of the Array-specific properties of the decoupled `ObservableArray` useful in certain instances. | ||
## <a name="docs"></a> Documentation | ||
- [Types](#types) | ||
- [Arrays](#arr) | ||
- [Objects](#obj) | ||
- [Strings](#str) | ||
- [Ubiquitous Properties](#all) | ||
- [Type-specific APIs](#types) | ||
- [Arrays](#arr) | ||
- [Objects](#obj) | ||
- [Strings](#str) | ||
- [Ubiquitous Properties](#all) | ||
### <a name="types"></a> Vivisector Types | ||
<hr> | ||
#### <a name="arr"></a> <u>ObservableArray (*extends Array*)</u> | ||
*an Array-like Object* | ||
#### <a name="arr"></a> Arrays | ||
**Example:** | ||
```js | ||
const albums = vivisect(["Tago Mago", "Monster Movie", "Ege Bamyasi"]); | ||
``` | ||
const albums = Vx("Array", ["Tago Mago", "Monster Movie", "Ege Bamyasi"]); | ||
``` | ||
#### Unique Methods and Props | ||
#### findIndexAll | ||
#### findIndexAll | ||
Returns an Array of all indices that contain a match to given argument. Does not evaluate nested items. | ||
**Example:** | ||
``` | ||
const users = Vx("Array", ["hello", "world", "world", "hello", "world"]); | ||
```js | ||
const users = vivisect(["hello", "world", "world", "hello", "world"]); | ||
console.log(users.findIndexAll("hello")); | ||
@@ -91,8 +95,9 @@ // [0, 3] | ||
#### findIndexAllDeep | ||
#### findIndexAllDeep | ||
Returns an Array of all indices that contain a match to given argument. Walks entire Array tree and evaluates nested items. | ||
**Example:** | ||
``` | ||
const users = Vx("Array", ["hello",["hello"], "world", ["world", "hello"], ["world", ["world",["hello"]]]]); | ||
```js | ||
const users = vivisect(["hello",["hello"], "world", ["world", "hello"], ["world", ["world",["hello"]]]]); | ||
console.log(users.findIndexAllDeep("hello")); | ||
@@ -105,3 +110,4 @@ // [ [ 0 ], [ 1, 0 ], [ 3, 1 ], [ 4, 1, 1, 0 ] ] | ||
#### itemadded | ||
A new item has been added to the Array. Callbacks will receive an Object consisting of: | ||
A new item has been added to the Array. Callbacks will receive an Object consisting of: | ||
| Property | Value | | ||
@@ -116,2 +122,3 @@ | --- | --- | | ||
#### itemset | ||
An item in the Array has moved. Callbacks will receive an Object consisting of: | ||
@@ -125,6 +132,7 @@ | Property | Value | | ||
**Fires on:** *unshift, using index accessors to set Array items* | ||
<br> | ||
**Note:** Shuffling the Array or using methods like `unshift` will fire `itemset` for *each* index change | ||
#### itemremoved | ||
An item has been removed from the Array. Callbacks will receive an Object consisting of: | ||
@@ -139,3 +147,4 @@ | Property | Value | | ||
#### mutated | ||
#### mutated | ||
The Array value has been reassigned. Callbacks will receive an Object consisting of : | ||
@@ -149,9 +158,8 @@ | Property | Value | | ||
**Fires on:** *Using the value accessor to mutate the Array value* | ||
<hr> | ||
#### <a name="obj"></a> <u>ObservableObject (*extends Proxy*)</u> | ||
*an extended Object Proxy* | ||
#### <a name="obj"></a> Objects | ||
**Example:** | ||
``` | ||
```js | ||
const target = { | ||
@@ -162,3 +170,3 @@ name: "La Monte Young", | ||
const music = Vx("Object", target); | ||
const music = vivisect(target); | ||
``` | ||
@@ -169,2 +177,3 @@ | ||
#### itemget | ||
An Object property value has been accessed. Callbacks will receive an Object consisting of: | ||
@@ -179,2 +188,3 @@ | Property | Value | | ||
#### itemset | ||
An Object property value has been set. Callbacks will receive an Object consisting of: | ||
@@ -188,3 +198,4 @@ | Property | Value | | ||
#### itemdeleted | ||
#### itemdeleted | ||
An Object property value has been deleted. Callbacks will receive an Object consisting of: | ||
@@ -197,20 +208,22 @@ | Property | Value | | ||
| **value** | A Boolean value indicating deletion success | | ||
<hr> | ||
#### <a name="str"></a> <u>ObservableString (*extends String*)</u> | ||
*a mutable, String-like Object* | ||
#### <a name="str"></a> Strings | ||
**Example:** | ||
```js | ||
const hash = vivisect("UmVhZE1vcmVZdWtpb01pc2hpbWEK"); | ||
``` | ||
const hash = Vx("String", "UmVhZE1vcmVZdWtpb01pc2hpbWEK"); | ||
``` | ||
#### Unique Methods and Props | ||
#### reassign | ||
#### reassign | ||
Mutates String value, chainable (returns `this`). | ||
**Example:** | ||
``` | ||
const str = Vx("String", "Hello, world"); | ||
```js | ||
const str = vivisect("Hello, world"); | ||
str.reassign("Hello, moon").addEventListener(... | ||
@@ -223,8 +236,10 @@ | ||
#### length | ||
Returns String value length; non-configurable. | ||
Returns String value length; non-configurable. | ||
#### Event Types | ||
#### mutated | ||
The String value has been reassigned. Callbacks will receive an Object consisting of: | ||
#### mutated | ||
The String value has been reassigned. Callbacks will receive an Object consisting of: | ||
| Property | Value | | ||
@@ -236,46 +251,43 @@ | --- | --- | | ||
<hr> | ||
#### <a name="all"></a> <u>Ubiquitous Methods and Props</u> | ||
#### Functional Purity | ||
The `Vx` handler copies by value, not by reference. Observables do not modify the original Objects passed to them upon instantiation. | ||
#### Purity | ||
The ``vivisect`` handler copies by value, not by reference. Observables do not modify the original Objects passed to them upon instantiation. | ||
#### value | ||
A non-enumerable accessor for getting and/or setting the core value of a given *Observable* | ||
**Example:** | ||
``` | ||
const users = Vx("Array", ["Alice", "Bob"]); | ||
console.log(users.value); | ||
// ["Alice", "Bob"] | ||
```js | ||
const users = vivisect(["Alice", "Bob"]); | ||
users.value = ["Alexei", "Quinn"]; | ||
console.log(users.value); | ||
// ["Alice", "Bob"] | ||
console.log(users.value); | ||
// ["Alexei", "Quinn"] | ||
``` | ||
users.value = ["Alexei", "Quinn"]; | ||
**Note**: *Get/Set on types `String`, `Array`*; *Get on types `Object`* | ||
#### identifier | ||
A unique identifier assigned to all *Observables*. Namespace confined to the Nodejs (or your target runtime) runtime's `global`, or 'module context'. Currently a paused feature. | ||
console.log(users.value); | ||
// ["Alexei", "Quinn"] | ||
``` | ||
#### type | ||
The type identifier of a given *Observable*, *e.g. "Array", "Object", "String"* | ||
**Note**: *Get/Set on types `String`, `Array`*; *Get on types `Object`* | ||
#### addEventListener | ||
Bind a callback to fire whenever a given event-type has been triggered. | ||
<br> | ||
#### addEventListener | ||
Bind a callback to fire whenever a given event-type has been triggered. | ||
See also: [debounce](#debounce) option. | ||
**Example:** | ||
``` | ||
const logMsg = function(event) { | ||
// every time an item is added to the array, fire this callback | ||
console.log(`Added ${event.item} at index ${event.index}.`); | ||
```js | ||
const logMsg = function (event) { | ||
// every time an item is added to the array, fire this callback | ||
console.log(`Added ${event.item} at index ${event.index}.`); | ||
}); | ||
const users = Vx("Array", ["Alice","Bob"]).addEventListener("itemadded", logMsg); | ||
const users = vivisect(["Alice","Bob"]).addEventListener("itemadded", logMsg); | ||
@@ -286,16 +298,18 @@ users.push("Charlie"); | ||
#### removeEventListener | ||
Remove an existing callback from the respective event-type to which it has been registered. | ||
<br> | ||
#### removeEventListener | ||
Remove an existing callback from the respective event-type to which it has been registered. | ||
See also: [debounce](#debounce) option. | ||
**Example:** | ||
``` | ||
const logMsg = function(event) { | ||
console.log(`Added ${event.item} at index ${event.index}.`); | ||
```js | ||
const logMsg = function (event) { | ||
console.log(`Added ${event.item} at index ${event.index}.`); | ||
}); | ||
const users = Vx("Array", ["Alice","Bob"]) | ||
.addEventListener("itemadded", logMsg) | ||
.removeEventListener("itemadded", logMsg); | ||
const users = vivisect(["Alice","Bob"]) | ||
.addEventListener("itemadded", logMsg) | ||
.removeEventListener("itemadded", logMsg); | ||
@@ -307,5 +321,6 @@ users.push("Charlie"); | ||
#### <a name="debounce"></a> debounce (option) | ||
Optionally enforce a debounce on a given event-listener; handler calls will be throttled for a duration of *n* milliseconds. | ||
To provide the Vx constructor a debounce directive, one need only specify a third and optional argument when calling `addEventListener` - a Number denoting milliseconds to which the debounce timeout will be set. | ||
To `vivisect` with a debounce directive, one need only specify a third and optional argument when calling `addEventListener` - a Number denoting milliseconds to which the debounce timeout will be set. | ||
@@ -315,8 +330,9 @@ To unregister a debounced handler via `removeEventListener`, simply pass the handler name as usual. | ||
**Example:** | ||
``` | ||
const logMsg = function(event) { | ||
console.log(`Added ${event.item} at index ${event.index}.`); | ||
```js | ||
const logMsg = function (event) { | ||
console.log(`Added ${event.item} at index ${event.index}.`); | ||
}); | ||
const users = Vx("Array", ["Alice","Bob"]).addEventListener("itemadded", logMsg, 2000); | ||
const users = vivisect(["Alice","Bob"]).addEventListener("itemadded", logMsg, 2000); | ||
@@ -326,3 +342,3 @@ users.push("Charlie"); | ||
// Vx will find and remove the debounced `logMsg`; no debounce directive needed here | ||
// `vivisect` will find and remove the debounced `logMsg`; no debounce directive needed here | ||
users.removeEventListener("itemadded", logMsg); | ||
@@ -333,2 +349,1 @@ | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94456
2146
330
20