Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
vivisector
Advanced tools
Vivisector.js is a light-weight Nodejs 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 flexible, compact, and straightforward; it affords you fine-grained control by allowing you to decide when and what happens when a variable changes.
itemadded
, itemremoved
this
new
keyword, no configuration; Vivisector
types work out-of-the-boxInstall via NPM with npm i vivisector
.
Import Vivisector's caller alias Vx
:
const Vx = require("vivisector");
Create a new Observable - in this example, of type Array
- and register a handler to fire when any new elements are added:
const logAdditions = ({item, index}) => console.log(`Added ${item} at index ${index}.`);
const users = Vx("Array", ["Alice","Bob"]);
users.addEventListener("itemadded", logAdditions);
// every time an item is added to the array, fire `logAdditions`
users.push("Charlie");
// "Added Charlie at index 2."
Have a look at these usage guides for a full overview:
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.
an Array-like Object
Unique Methods and Props
const users = Vx("Array", ["hello", "world", "world", "hello", "world"]);
console.log(users.findIndexAll("hello"));
// [0, 3]
Event Types
itemadded A new item has been added to the Array. Callbacks will receive an Object consisting of
Fires on: push, unshift, splice
itemset An item in the Array has moved. Callbacks will receive an Object consisting of
Fires on: unshift, using index accessors to set Array items
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
Fires on: pop, shift, splice
mutated The Array value has been reassigned. Callbacks will receive an Object consisting of
Fires on: Using the value accessor to mutate the Array value
a mutable, String-like Object
Unique Methods and Props
this
).let str = Vx("String", "Hello, world");
str.reassign("Hello, moon").addEventListener(...
console.log(str);
// Hello, moon
Event Types
an extended Object Proxy
Event Types
prop
const users = Vx("Array", ["Alice", "Bob"]);
console.log(users.value);
// ["Alice", "Bob"]
users.value = ["Alexei", "Quinn"]
console.log(users.value);
// ["Alexei", "Quinn"]
Get/Set on types String
, Array
Get on types Object
global
, or 'module context'. Currently a paused feature.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}.`);
});
let users = Vx("Array", ["Alice","Bob"]).addEventListener("itemadded", logMsg);
users.push("Charlie");
// "Added Charlie at index 2."
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}.`);
});
let users = Vx("Array", ["Alice","Bob"]).addEventListener("itemadded", logMsg).removeEventListener("itemadded", logMsg);
users.push("Charlie");
// no log - handler was removed ^
FAQs
subscribe to any object and commit or revert state mutations
The npm package vivisector receives a total of 0 weekly downloads. As such, vivisector popularity was classified as not popular.
We found that vivisector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.