aws-dynamodb-axios
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -11,2 +11,3 @@ const { marshall } = require('../index') | ||
expect(marshall({ foo: 'bar' })).toEqual({ foo: { S: 'bar' } }) | ||
expect(marshall(['foo', 'bar'])).toEqual({ SS: ['foo', 'bar'] }) | ||
expect(marshall(undefined)).toEqual(undefined) | ||
@@ -22,3 +23,4 @@ }) | ||
boolFalsy: false, | ||
map: { foo: 'bar', moof: 'doof' } | ||
map: { foo: 'bar', moof: 'doof' }, | ||
stringset: ['foo', 'bar'] | ||
})).toEqual({ | ||
@@ -30,3 +32,4 @@ string: { S: 'foo' }, | ||
boolFalsy: { BOOL: false }, | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } } | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }, | ||
stringset: { SS: ['foo', 'bar'] } | ||
}) | ||
@@ -43,3 +46,4 @@ }) | ||
boolFalsy: false, | ||
map: { foo: 'bar', moof: 'doof' } | ||
map: { foo: 'bar', moof: 'doof' }, | ||
stringset: ['foo', 'bar'] | ||
}, | ||
@@ -52,3 +56,4 @@ { | ||
boolFalsy: false, | ||
map: { foo: 'bar', moof: 'doof' } | ||
map: { foo: 'bar', moof: 'doof' }, | ||
stringset: ['foo', 'bar'] | ||
} | ||
@@ -62,3 +67,4 @@ ])).toEqual([ | ||
boolFalsy: { BOOL: false }, | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } } | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }, | ||
stringset: { SS: ['foo', 'bar'] } | ||
}, | ||
@@ -71,3 +77,4 @@ { | ||
boolFalsy: { BOOL: false }, | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } } | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }, | ||
stringset: { SS: ['foo', 'bar'] } | ||
} | ||
@@ -74,0 +81,0 @@ ]) |
@@ -12,2 +12,4 @@ const { unmarshall } = require('../index') | ||
.toEqual({ foo: 'bar', moof: 'doof' }) | ||
expect(unmarshall({ SS: ['foo', 'bar'] })) | ||
.toEqual(['foo', 'bar']) | ||
}) | ||
@@ -22,3 +24,4 @@ | ||
boolFalsy: { BOOL: false }, | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } } | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }, | ||
stringset: { SS: ['foo', 'bar'] } | ||
})).toEqual({ | ||
@@ -30,3 +33,4 @@ string: 'foo', | ||
boolFalsy: false, | ||
map: { foo: 'bar', moof: 'doof' } | ||
map: { foo: 'bar', moof: 'doof' }, | ||
stringset: ['foo', 'bar'] | ||
}) | ||
@@ -43,3 +47,4 @@ }) | ||
boolFalsy: { BOOL: false }, | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } } | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }, | ||
stringset: { SS: ['foo', 'bar'] } | ||
}, | ||
@@ -52,3 +57,4 @@ { | ||
boolFalsy: { BOOL: false }, | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } } | ||
map: { M: { foo: { S: 'bar' }, moof: { S: 'doof' } } }, | ||
stringset: { SS: ['foo', 'bar'] } | ||
} | ||
@@ -62,3 +68,4 @@ ])).toEqual([ | ||
boolFalsy: false, | ||
map: { foo: 'bar', moof: 'doof' } | ||
map: { foo: 'bar', moof: 'doof' }, | ||
stringset: ['foo', 'bar'] | ||
}, | ||
@@ -71,3 +78,4 @@ { | ||
boolFalsy: false, | ||
map: { foo: 'bar', moof: 'doof' } | ||
map: { foo: 'bar', moof: 'doof' }, | ||
stringset: ['foo', 'bar'] | ||
} | ||
@@ -74,0 +82,0 @@ ]) |
@@ -9,3 +9,3 @@ const mapValues = require('./modules/mapValues') | ||
return mapValues(obj, (val, key) => { | ||
if (val !== null && typeof val === 'object') { | ||
if (val !== null && !Array.isArray(val) && typeof val === 'object') { | ||
return { M: marshall(val) } | ||
@@ -17,2 +17,9 @@ } | ||
const handleArray = arr => { | ||
if (typeof arr[0] === 'string') { | ||
return { SS: arr } | ||
} | ||
return arr.map(marshall) | ||
} | ||
const marshall = val => { | ||
@@ -25,3 +32,3 @@ if (val === null) return { NULL: true } | ||
if (typeof val === 'number') return { N: val.toString() } | ||
if (Array.isArray(val)) return val.map(marshall) | ||
if (Array.isArray(val)) return handleArray(val) | ||
if (typeof val === 'object') return handleObject(val) | ||
@@ -28,0 +35,0 @@ throw new Error(false, `Marshalling type \`${typeof val}\` is not yet supported`) |
{ | ||
"name": "aws-dynamodb-axios", | ||
"license": "MIT", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "test": "./test-local.sh", |
@@ -12,3 +12,4 @@ const mapValues = require('./modules/mapValues') | ||
BOOL: true, | ||
M: true | ||
M: true, | ||
SS: true | ||
} | ||
@@ -40,2 +41,4 @@ | ||
return unmarshall(val) | ||
case 'SS': | ||
return val | ||
} | ||
@@ -42,0 +45,0 @@ throw new Error(`Unmarshalling type \`${key}\` is not yet supported`) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196472
592