New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

object-deep-from-entries

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-deep-from-entries - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

isNumber.js

15

package.json
{
"name": "object-deep-from-entries",
"version": "0.2.0",
"version": "0.3.0",
"description": "Make an object or collection from entries deeply.",
"main": "object-deep-from-entries.js",
"main": "objectDeepFromEntries.js",
"repository": "octet-stream/object-deep-from-entries",
"author": "Nick K. <nick.kruchinin@gmail.com>",
"license": "MIT",
"types": "object-deep-from-entries.d.ts",
"types": "objectDeepFromEntries.d.ts",
"keywords": [
"object",
"deep",
"entries",
"from-entries",
"object-from-entries",
"convert",
"collection"
],
"scripts": {

@@ -11,0 +20,0 @@ "test": "node_modules/.bin/ava test.js",

73

test.js

@@ -181,3 +181,3 @@ const test = require("ava")

test("Should return a flat collection", t => {
test("Should return a collection", t => {
t.plan(1)

@@ -274,1 +274,72 @@

})
test("Should create flat array from entries", t => {
t.plan(1)
const expected = ["Zero", "One", "Two", "Three"]
const actual = objectDeepFromEntries([
[0, "Zero"],
[1, "One"],
[2, "Two"],
[3, "Three"]
])
t.deepEqual(actual, expected)
})
test("Should create flat array with mixed values", t => {
t.plan(1)
const expected = [42, {number: 42}, "Some string"]
const actual = objectDeepFromEntries([
[0, 42],
["number", 42],
[2, "Some string"]
])
t.deepEqual(actual, expected)
})
test("Should create deep array with mixed values", t => {
t.plan(1)
const expected = [42, {person: {name: "John Doe"}}, "Some string"]
const actual = objectDeepFromEntries([
[
0, 42
],
[
["person", "name"], "John Doe"
],
[
2, "Some string"
]
])
t.deepEqual(actual, expected)
})
test("Should throw a TypeError when invoked without any arguments", t => {
t.plan(3)
const trap = () => objectDeepFromEntries()
const err = t.throws(trap)
t.true(err instanceof TypeError)
t.is(err.message, "Expected an array of entries. Received undefined")
})
test("Should throw an error when entries are not an array", t => {
t.plan(3)
const trap = () => objectDeepFromEntries({})
const err = t.throws(trap)
t.true(err instanceof TypeError)
t.is(err.message, "Expected an array of entries. Received object")
})
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