Comparing version 1.1.2 to 1.1.3
@@ -13,3 +13,3 @@ @module {function} can-param can-param | ||
```js | ||
import param from "can-param"; | ||
import { param } from "can"; | ||
@@ -31,5 +31,13 @@ param( { foo: "bar" } ); //-> "foo=bar" | ||
Use this JS Bin to play around with this package: | ||
Run the following example on CodePen to play around with this package: | ||
<a class="jsbin-embed" href="https://jsbin.com/zezamig/embed?js,console">can-param on jsbin.com</a> | ||
<script src="https://static.jsbin.com/js/embed.min.js?4.0.4"></script> | ||
```html | ||
<script type="module"> | ||
import { param } from "can"; | ||
var parameters = {canjs: 'awesome'}; | ||
var queryString = param(parameters); | ||
console.log(queryString); | ||
</script> | ||
``` | ||
@codepen |
@@ -1,3 +0,3 @@ | ||
/*can-param@1.1.1#can-param*/ | ||
define('can-param', [ | ||
/*can-param@1.1.2#can-param*/ | ||
define([ | ||
'require', | ||
@@ -4,0 +4,0 @@ 'exports', |
@@ -1,35 +0,28 @@ | ||
/*can-param@1.1.1#can-param*/ | ||
define('can-param', [ | ||
'require', | ||
'exports', | ||
'module', | ||
'can-namespace' | ||
], function (require, exports, module) { | ||
'use strict'; | ||
var namespace = require('can-namespace'); | ||
function buildParam(prefix, obj, add) { | ||
if (Array.isArray(obj)) { | ||
for (var i = 0, l = obj.length; i < l; ++i) { | ||
var inner = obj[i]; | ||
var shouldIncludeIndex = typeof inner === 'object'; | ||
var arrayIndex = shouldIncludeIndex ? '[' + i + ']' : '[]'; | ||
buildParam(prefix + arrayIndex, inner, add); | ||
} | ||
} else if (obj && typeof obj === 'object') { | ||
for (var name in obj) { | ||
buildParam(prefix + '[' + name + ']', obj[name], add); | ||
} | ||
} else { | ||
add(prefix, obj); | ||
/*can-param@1.1.2#can-param*/ | ||
'use strict'; | ||
var namespace = require('can-namespace'); | ||
function buildParam(prefix, obj, add) { | ||
if (Array.isArray(obj)) { | ||
for (var i = 0, l = obj.length; i < l; ++i) { | ||
var inner = obj[i]; | ||
var shouldIncludeIndex = typeof inner === 'object'; | ||
var arrayIndex = shouldIncludeIndex ? '[' + i + ']' : '[]'; | ||
buildParam(prefix + arrayIndex, inner, add); | ||
} | ||
} else if (obj && typeof obj === 'object') { | ||
for (var name in obj) { | ||
buildParam(prefix + '[' + name + ']', obj[name], add); | ||
} | ||
} else { | ||
add(prefix, obj); | ||
} | ||
module.exports = namespace.param = function param(object) { | ||
var pairs = [], add = function (key, value) { | ||
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); | ||
}; | ||
for (var name in object) { | ||
buildParam(name, object[name], add); | ||
} | ||
return pairs.join('&').replace(/%20/g, '+'); | ||
}; | ||
}); | ||
} | ||
module.exports = namespace.param = function param(object) { | ||
var pairs = [], add = function (key, value) { | ||
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); | ||
}; | ||
for (var name in object) { | ||
buildParam(name, object[name], add); | ||
} | ||
return pairs.join('&').replace(/%20/g, '+'); | ||
}; |
@@ -168,3 +168,3 @@ /*[process-shim]*/ | ||
/*can-param@1.1.1#can-param*/ | ||
/*can-param@1.1.2#can-param*/ | ||
define('can-param', [ | ||
@@ -171,0 +171,0 @@ 'require', |
{ | ||
"name": "can-param", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"main": "can-param", | ||
@@ -5,0 +5,0 @@ "description": "Serialize an array or object into a query string.", |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1
20078
344