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

flatulence

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatulence - npm Package Compare versions

Comparing version 0.2.2 to 0.2.4

13

lib/inflate.js

@@ -7,3 +7,9 @@

inflate(map, prefix = '', result = {}) {
inflate(map, prefix = '', result) {
if(!result) {
if(pointsAtArray(map, prefix)) result = []
else result = {}
}
const subMap = buildMatchingMap(map, prefix)

@@ -21,3 +27,8 @@

const pointsAtArray = (map, prefix) => {
const key = Object.keys(map).find(key => key.startsWith(prefix))
return key && key.charAt(prefix.length) === '['
}
// Returns an object with all key-value pairs

@@ -24,0 +35,0 @@ // matching the given prefix

2

package.json
{
"name": "flatulence",
"version": "0.2.2",
"version": "0.2.4",
"description": "Flatten objects and arrays so that each key is the full path to a primitive value. Paths are lodash-compatible. Inflate flattened objects and make them regular JS objects again.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,5 +8,5 @@ const assert = require('assert')

describe('#deflate()', () => {
describe('#flatten()', () => {
it('should flatten object', () => {
const flattened = fl.deflate(data)
const flattened = fl.flatten(data)

@@ -20,3 +20,3 @@ console.log(flattened)

const prefix = 'this.is.my.custom.prefix'
const flattened = fl.deflate(
const flattened = fl.flatten(
{

@@ -36,19 +36,29 @@ id: 'anid',

describe('#inflate()', () => {
it('should reverse flattened object to an inflated one', () => {
describe('#unflatten()', () => {
it('should reverse flattened object to an unflattened one', () => {
const flattened = fl.flatten(data)
const inflated = fl.unflatten(flattened)
const unflattened = fl.unflatten(flattened)
assert.deepEqual(data, inflated)
assert.deepEqual(data, unflattened)
})
it('should reverse flattened object to an inflated one at a prefix', () => {
const flattened = fl.deflate(data)
const inflated = fl.inflate(flattened, 'cc')
it('should reverse flattened object to an unflattened one at a prefix', () => {
const flattened = fl.flatten(data)
const unflattened = fl.unflatten(flattened, 'cc')
assert.deepEqual(data.cc, inflated)
assert.deepEqual(data.cc, unflattened)
})
it('should produce an unflat array when prefix points at array', () => {
const flattened = fl.flatten(data)
const unflattened = fl.unflatten(flattened, 'cc.contract.multiContractSetup')
console.log('unflattened', unflattened)
assert.ok(Array.isArray(unflattened))
})
})
})
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