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

observ-array

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

observ-array - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

put.js

5

index.js

@@ -7,2 +7,3 @@ var Observ = require("observ")

var splice = require("./splice.js")
var put = require('./put.js')
var ArrayMethods = require("./array-methods.js")

@@ -72,8 +73,4 @@ var addListener = require("./add-listener.js")

function put(index, value) {
this.splice(index, 1, value)
}
function getLength() {
return this._list.length
}

2

package.json
{
"name": "observ-array",
"version": "1.2.0",
"version": "1.3.0",
"description": "An array containing observable values",

@@ -5,0 +5,0 @@ "keywords": [],

@@ -245,1 +245,43 @@ var test = require("tape")

})
test("can use put to override existing value", function (assert) {
var arr = ObservArray([ Observ("foo"), Observ("bar") ])
var changes = []
arr(function (state) {
changes.push(state)
})
arr.put(0, Observ('baz'))
arr.put(1, Observ('foobar'))
assert.equal(changes.length, 2)
assert.deepEqual(changes[0].slice(), ["baz", "bar"])
assert.deepEqual(changes[0]._diff, [0, 1, 'baz'])
assert.deepEqual(changes[1].slice(), ["baz", "foobar"])
assert.deepEqual(changes[1]._diff, [1, 1, 'foobar'])
assert.end()
})
test("can put values into array beyond length", function (assert) {
var arr = ObservArray([ Observ("foo"), Observ("bar") ])
var changes = []
arr(function (state) {
changes.push(state)
})
var baz = Observ("baz")
arr.put(4, baz)
baz.set("foobaz")
assert.equal(changes.length, 2)
assert.deepEqual(changes[0].slice(), ["foo", "bar", , , "baz"])
assert.deepEqual(changes[0]._diff, [4, 0, 'baz'])
assert.deepEqual(changes[1].slice(), ["foo", "bar", , , "foobaz"])
assert.deepEqual(changes[1]._diff, [4, 1, 'foobaz'])
assert.end()
})
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