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

tfk-360-unwrap-contact

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tfk-360-unwrap-contact - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

test/data/GetPrivatePersonNew.json

31

index.js
'use strict'
function unwrapContact (contact) {
const resolve = (path, obj) => {
return path.split('.').reduce((prev, curr) => {
return prev ? prev[curr] : undefined
}, obj)
}
module.exports = (contact) => {
if (!contact) {
throw new Error('Missing required input: contact object')
} else if (!contact.GetPrivatePersonsResult) {
throw new Error('Malformed contact object')
}
var person = false
if (contact.GetPrivatePersonsResult) {
if (contact.GetPrivatePersonsResult.PrivatePersons && contact.GetPrivatePersonsResult.PrivatePersons.PrivatePersonBase) {
if (contact.GetPrivatePersonsResult.PrivatePersons.PrivatePersonBase.length === 1) {
person = contact.GetPrivatePersonsResult.PrivatePersons.PrivatePersonBase[0]
} else {
throw new Error('More than 1 person in contact object')
}
}
const person = resolve('GetPrivatePersonsResult.PrivatePersons.PrivatePersonBase', contact) || resolve('GetPrivatePersonsResult.PrivatePersons.PrivatePersonResult', contact)
if (!person) {
return false
} else if (person.length === 1) {
return person[0]
} else if (person.length >= 1) {
throw new Error('More than 1 person in contact object')
} else {
throw new Error('Malformed contact object')
}
return person
}
module.exports = unwrapContact
{
"name": "tfk-360-unwrap-contact",
"version": "2.0.1",
"version": "2.0.2",
"description": "Unwraps GetPrivatePersonsResult from Public 360",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -55,1 +55,9 @@ 'use strict'

})
tap.test('It returns expected result', function (test) {
var contact = require('./data/GetPrivatePersonNew.json')
var expected = require('./data/unwrappedContactNew.json')
var result = unwrapContact(contact)
tap.equal(JSON.stringify(result), JSON.stringify(expected), 'Contact unwrapped OK')
test.done()
})
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