Socket
Socket
Sign inDemoInstall

aws-dynamodb-axios

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-dynamodb-axios - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

19

__tests__/marshall.js

@@ -10,2 +10,3 @@ const { marshall } = require('../index')

expect(marshall(false)).toEqual({ BOOL: false })
expect(marshall({ foo: 'bar' })).toEqual({ foo: { S: 'bar' } })
expect(marshall(undefined)).toEqual(undefined)

@@ -20,3 +21,4 @@ })

boolTruthy: true,
boolFalsy: false
boolFalsy: false,
map: { foo: 'bar', moof: 'doof' }
})).toEqual({

@@ -27,3 +29,4 @@ string: { S: 'foo' },

boolTruthy: { BOOL: true },
boolFalsy: { BOOL: false }
boolFalsy: { BOOL: false },
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }
})

@@ -39,3 +42,4 @@ })

boolTruthy: true,
boolFalsy: false
boolFalsy: false,
map: { foo: 'bar', moof: 'doof' }
},

@@ -47,3 +51,4 @@ {

boolTruthy: true,
boolFalsy: false
boolFalsy: false,
map: { foo: 'bar', moof: 'doof' }
}

@@ -56,3 +61,4 @@ ])).toEqual([

boolTruthy: { BOOL: true },
boolFalsy: { BOOL: false }
boolFalsy: { BOOL: false },
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }
},

@@ -64,3 +70,4 @@ {

boolTruthy: { BOOL: true },
boolFalsy: { BOOL: false }
boolFalsy: { BOOL: false },
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }
}

@@ -67,0 +74,0 @@ ])

@@ -10,2 +10,4 @@ const { unmarshall } = require('../index')

expect(unmarshall({ BOOL: false })).toEqual(false)
expect(unmarshall({ M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }))
.toEqual({ foo: 'bar', moof: 'doof' })
})

@@ -19,3 +21,4 @@

boolTruthy: { BOOL: true },
boolFalsy: { BOOL: false }
boolFalsy: { BOOL: false },
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }
})).toEqual({

@@ -26,3 +29,4 @@ string: 'foo',

boolTruthy: true,
boolFalsy: false
boolFalsy: false,
map: { foo: 'bar', moof: 'doof' }
})

@@ -38,3 +42,4 @@ })

boolTruthy: { BOOL: true },
boolFalsy: { BOOL: false }
boolFalsy: { BOOL: false },
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }
},

@@ -46,3 +51,4 @@ {

boolTruthy: { BOOL: true },
boolFalsy: { BOOL: false }
boolFalsy: { BOOL: false },
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }
}

@@ -55,3 +61,4 @@ ])).toEqual([

boolTruthy: true,
boolFalsy: false
boolFalsy: false,
map: { foo: 'bar', moof: 'doof' }
},

@@ -63,3 +70,4 @@ {

boolTruthy: true,
boolFalsy: false
boolFalsy: false,
map: { foo: 'bar', moof: 'doof' }
}

@@ -66,0 +74,0 @@ ])

@@ -7,2 +7,11 @@ const mapValues = require('./modules/mapValues')

const handleObject = obj => {
return mapValues(obj, (val, key) => {
if (val !== null && typeof val === 'object') {
return { M: marshall(val) }
}
return marshall(val)
})
}
const marshall = val => {

@@ -16,3 +25,3 @@ if (val === null) return { NULL: true }

if (Array.isArray(val)) return val.map(marshall)
if (typeof val === 'object') return mapValues(val, marshall)
if (typeof val === 'object') return handleObject(val)
throw new Error(false, `Marshalling type \`${typeof val}\` is not yet supported`)

@@ -19,0 +28,0 @@ }

const mapValues = (obj, fn) => {
let mapped = {}
Object.keys(obj).forEach(key => {
mapped[key] = fn(obj[key])
mapped[key] = fn(obj[key], key)
})

@@ -6,0 +6,0 @@ return mapped

{
"name": "aws-dynamodb-axios",
"license": "MIT",
"version": "0.0.2",
"version": "0.0.3",
"scripts": {

@@ -6,0 +6,0 @@ "test": "./test-local.sh",

@@ -7,2 +7,10 @@ const mapValues = require('./modules/mapValues')

const types = {
S: true,
N: true,
NULL: true,
BOOL: true,
M: true
}
const unmarshall = attributeValue => {

@@ -12,3 +20,3 @@ if (attributeValue === null || attributeValue === undefined) return null

const val = Object.values(attributeValue).pop()
if (!['S', 'N', 'NULL', 'BOOL'].includes(key)) {
if (!types[key]) {
if (Array.isArray(attributeValue)) {

@@ -20,6 +28,16 @@ return attributeValue.map(unmarshall)

}
if (key === 'S') return val
if (key === 'N') return parseInt(val, 10)
if (key === 'NULL' && val === true) return null
if (key === 'BOOL') return val
switch (key) {
case 'S':
return val
case 'N':
return parseInt(val, 10)
case 'NULL':
if (val === true) return null
break
case 'BOOL':
return val
case 'M':
return unmarshall(val)
}
throw new Error(`Unmarshalling type \`${key}\` is not yet supported`)

@@ -26,0 +44,0 @@ }

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