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

json-shaper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-shaper - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

56

lib/json-shaper.spec.js
import {
isObject,
forEach,
} from './json-shaper'
import sinon from 'sinon';
describe('isObject helper', () => {

@@ -31,1 +35,53 @@

describe('forEach helper', () => {
it('should iterate over object keys and call a function', () => {
const iteratee = sinon.spy()
const obj1 = {
a: 123,
b: 456,
z: 789
}
const obj2 = [
'just',
'some',
'array'
]
forEach(obj1, iteratee)
forEach(obj2, iteratee)
expect(iteratee.withArgs(123, 'a').calledOnce).to.be.true
expect(iteratee.withArgs(456, 'b').calledOnce).to.be.true
expect(iteratee.withArgs(789, 'z').calledOnce).to.be.true
expect(iteratee.withArgs('just', '0').calledOnce).to.be.true
expect(iteratee.withArgs('some', '1').calledOnce).to.be.true
expect(iteratee.withArgs('array', '2').calledOnce).to.be.true
})
it('should skip on non-objects', () => {
const iteratee = sinon.spy()
const obj1 = 'test'
const obj2 = 123
const obj3 = null
const obj4 = undefined
forEach(obj1, iteratee)
forEach(obj2, iteratee)
forEach(obj3, iteratee)
forEach(obj4, iteratee)
expect(iteratee.callCount).to.equal(0)
})
})

5

package.json
{
"name": "json-shaper",
"version": "0.1.0",
"version": "0.2.0",
"description": "Shape a flat array into a molded json shape with deep nesting",

@@ -41,4 +41,5 @@ "author": "Chris Kalmar <christian.kalmar@gmail.com>",

"mocha": "^3.3.0",
"nyc": "^10.3.0"
"nyc": "^10.3.0",
"sinon": "^2.1.0"
}
}
yarn.lock

Sorry, the diff of this file is not supported yet

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