form-urlencoded
Advanced tools
Comparing version 1.1.4 to 1.1.5
// Filename: formurlencoded.js | ||
// Timestamp: 2016.01.10-10:46:11 (last modified) | ||
// Timestamp: 2016.01.17-14:31:12 (last modified) | ||
// Author(s): Bumblehead (www.bumblehead.com), JBlashill (james@blashill.com) | ||
@@ -20,3 +20,3 @@ // | ||
function getKeys (obj) { | ||
function keys (obj) { | ||
var keys = Object.keys(obj); | ||
@@ -27,21 +27,19 @@ | ||
function joinFilter (arr) { | ||
return arr.filter(function (e) { | ||
return typeof e === 'string' && e.length; | ||
}).join('&'); | ||
function filterjoin (arr) { | ||
return arr.filter(function (e) { return e; }).join('&'); | ||
} | ||
function getObjNestVals (name, obj) { | ||
return joinFilter(getKeys(obj).map(function (key) { | ||
return getNestVals(name + '[' + key + ']', obj[key]); | ||
function objnest (name, obj) { | ||
return filterjoin(keys(obj).map(function (key) { | ||
return nest(name + '[' + key + ']', obj[key]); | ||
})); | ||
} | ||
function getArrNestVals (name, arr) { | ||
return joinFilter(arr.map(function (elem) { | ||
return getNestVals(name + '[]', elem); | ||
function arrnest (name, arr) { | ||
return filterjoin(arr.map(function (elem) { | ||
return nest(name + '[]', elem); | ||
})); | ||
} | ||
function getNestVals (name, value) { | ||
function nest (name, value) { | ||
var type = typeof value, | ||
@@ -55,5 +53,5 @@ f = null; | ||
} else if (Array.isArray(value)) { | ||
f = getArrNestVals(name, value); | ||
f = arrnest(name, value); | ||
} else if (type === 'object') { | ||
f = getObjNestVals(name, value); | ||
f = objnest(name, value); | ||
} | ||
@@ -64,5 +62,5 @@ | ||
return joinFilter(getKeys(data).map(function (key) { | ||
return getNestVals(encode(key), data[key]); | ||
return filterjoin(keys(data).map(function (key) { | ||
return nest(encode(key), data[key]); | ||
})); | ||
}; |
{ | ||
"name": "form-urlencoded", | ||
"main": "form-urlencoded", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Return an object as an `x-www-form-urlencoded` string", | ||
@@ -6,0 +6,0 @@ "author": "Chris <chris@bumblehead.com>", |
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
12360
194