can-deparam
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,3 +5,6 @@ var namespace = require("can-namespace"); | ||
* @module {function} can-deparam can-deparam | ||
* @parent can-infrastructure | ||
* @parent can-routing | ||
* @collection can-infrastructure | ||
* @package ./package.json | ||
* @description Deserialize a query string into an array or object. | ||
* @signature `deparam(params)` | ||
@@ -21,2 +24,10 @@ * | ||
* ``` | ||
* @body | ||
* | ||
* ## Try it | ||
* | ||
* Use this JS Bin to play around with this package: | ||
* | ||
* <a class="jsbin-embed" href="https://jsbin.com/mobimok/3/embed?js,console">can-deparam on jsbin.com</a> | ||
* <script src="https://static.jsbin.com/js/embed.min.js?4.0.4"></script> | ||
*/ | ||
@@ -23,0 +34,0 @@ var digitTest = /^\d+$/, |
# Contributing to can-deparam | ||
Check out the [contribution guide on CanJS.com](https://canjs.com/doc/guides/contribute.html) for information on: | ||
- [Code of Conduct](https://canjs.com/doc/guides/contribute.html#CodeofConduct) | ||
- [Getting Help](https://canjs.com/doc/guides/contribute.html#GettingHelp) | ||
- [Project Organization](https://canjs.com/doc/guides/contributing/project-organization.html) | ||
- [Reporting Bugs](https://canjs.com/doc/guides/contributing/bug-report.html) | ||
- [Suggesting Features](https://canjs.com/doc/guides/contributing/feature-suggestion.html) | ||
- [Finding Ways to Contribute](https://canjs.com/doc/guides/contributing/finding-ways-to-contribute.html) | ||
The rest of this guide has information that’s specific to this repository. | ||
## Developing Locally | ||
@@ -74,13 +85,1 @@ | ||
This will create a `dist/` folder that contains the AMD, CommonJS, and global module versions of the project. | ||
### Building the documentation | ||
To generate the docs: | ||
```shell | ||
npm run document | ||
``` | ||
This will create a `docs/` folder that contains a browsable site with all of your documentation. | ||
With the dev server running, you can view the docs at http://localhost:8080/docs/ |
@@ -1,3 +0,8 @@ | ||
/*can-deparam@1.0.0#can-deparam*/ | ||
define(function (require, exports, module) { | ||
/*can-deparam@1.0.1#can-deparam*/ | ||
define([ | ||
'require', | ||
'exports', | ||
'module', | ||
'can-namespace' | ||
], function (require, exports, module) { | ||
var namespace = require('can-namespace'); | ||
@@ -4,0 +9,0 @@ var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, entityRegex = /%([^0-9a-f][0-9a-f]|[0-9a-f][^0-9a-f]|[^0-9a-f][^0-9a-f])/i, prep = function (str) { |
@@ -1,2 +0,2 @@ | ||
/*can-deparam@1.0.0#can-deparam*/ | ||
/*can-deparam@1.0.1#can-deparam*/ | ||
var namespace = require('can-namespace'); | ||
@@ -3,0 +3,0 @@ var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, entityRegex = /%([^0-9a-f][0-9a-f]|[0-9a-f][^0-9a-f]|[^0-9a-f][^0-9a-f])/i, prep = function (str) { |
/*[global-shim-start]*/ | ||
(function(exports, global, doEval){ // jshint ignore:line | ||
(function(exports, global, doEval) { | ||
// jshint ignore:line | ||
var origDefine = global.define; | ||
var get = function(name){ | ||
var get = function(name) { | ||
var parts = name.split("."), | ||
cur = global, | ||
i; | ||
for(i = 0 ; i < parts.length; i++){ | ||
if(!cur) { | ||
for (i = 0; i < parts.length; i++) { | ||
if (!cur) { | ||
break; | ||
@@ -17,10 +18,12 @@ } | ||
}; | ||
var set = function(name, val){ | ||
var set = function(name, val) { | ||
var parts = name.split("."), | ||
cur = global, | ||
i, part, next; | ||
for(i = 0; i < parts.length - 1; i++) { | ||
i, | ||
part, | ||
next; | ||
for (i = 0; i < parts.length - 1; i++) { | ||
part = parts[i]; | ||
next = cur[part]; | ||
if(!next) { | ||
if (!next) { | ||
next = cur[part] = {}; | ||
@@ -33,15 +36,24 @@ } | ||
}; | ||
var useDefault = function(mod){ | ||
if(!mod || !mod.__esModule) return false; | ||
var esProps = { __esModule: true, "default": true }; | ||
for(var p in mod) { | ||
if(!esProps[p]) return false; | ||
var useDefault = function(mod) { | ||
if (!mod || !mod.__esModule) return false; | ||
var esProps = { __esModule: true, default: true }; | ||
for (var p in mod) { | ||
if (!esProps[p]) return false; | ||
} | ||
return true; | ||
}; | ||
var modules = (global.define && global.define.modules) || | ||
(global._define && global._define.modules) || {}; | ||
var ourDefine = global.define = function(moduleName, deps, callback){ | ||
var hasCjsDependencies = function(deps) { | ||
return ( | ||
deps[0] === "require" && deps[1] === "exports" && deps[2] === "module" | ||
); | ||
}; | ||
var modules = | ||
(global.define && global.define.modules) || | ||
(global._define && global._define.modules) || | ||
{}; | ||
var ourDefine = (global.define = function(moduleName, deps, callback) { | ||
var module; | ||
if(typeof deps === "function") { | ||
if (typeof deps === "function") { | ||
callback = deps; | ||
@@ -52,21 +64,25 @@ deps = []; | ||
i; | ||
for(i =0; i < deps.length; i++) { | ||
args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); | ||
for (i = 0; i < deps.length; i++) { | ||
args.push( | ||
exports[deps[i]] | ||
? get(exports[deps[i]]) | ||
: modules[deps[i]] || get(deps[i]) | ||
); | ||
} | ||
// CJS has no dependencies but 3 callback arguments | ||
if(!deps.length && callback.length) { | ||
if (hasCjsDependencies(deps) || (!deps.length && callback.length)) { | ||
module = { exports: {} }; | ||
var require = function(name) { | ||
args[0] = function(name) { | ||
return exports[name] ? get(exports[name]) : modules[name]; | ||
}; | ||
args.push(require, module.exports, module); | ||
} | ||
// Babel uses the exports and module object. | ||
else if(!args[0] && deps[0] === "exports") { | ||
args[1] = module.exports; | ||
args[2] = module; | ||
} else if (!args[0] && deps[0] === "exports") { | ||
// Babel uses the exports and module object. | ||
module = { exports: {} }; | ||
args[0] = module.exports; | ||
if(deps[1] === "module") { | ||
if (deps[1] === "module") { | ||
args[1] = module; | ||
} | ||
} else if(!args[0] && deps[0] === "module") { | ||
} else if (!args[0] && deps[0] === "module") { | ||
args[0] = { id: moduleName }; | ||
@@ -85,4 +101,4 @@ } | ||
var globalExport = exports[moduleName]; | ||
if(globalExport && !get(globalExport)) { | ||
if(useDefault(result)) { | ||
if (globalExport && !get(globalExport)) { | ||
if (useDefault(result)) { | ||
result = result["default"]; | ||
@@ -92,15 +108,15 @@ } | ||
} | ||
}; | ||
}); | ||
global.define.orig = origDefine; | ||
global.define.modules = modules; | ||
global.define.amd = true; | ||
ourDefine("@loader", [], function(){ | ||
ourDefine("@loader", [], function() { | ||
// shim for @@global-helpers | ||
var noop = function(){}; | ||
var noop = function() {}; | ||
return { | ||
get: function(){ | ||
get: function() { | ||
return { prepareGlobal: noop, retrieveGlobal: noop }; | ||
}, | ||
global: global, | ||
__exec: function(__load){ | ||
__exec: function(__load) { | ||
doEval(__load.source, global); | ||
@@ -110,9 +126,18 @@ } | ||
}); | ||
} | ||
)({},window,function(__$source__, __$global__) { // jshint ignore:line | ||
eval("(function() { " + __$source__ + " \n }).call(__$global__);"); | ||
} | ||
) | ||
/*can-deparam@1.0.0#can-deparam*/ | ||
define('can-deparam', function (require, exports, module) { | ||
})( | ||
{}, | ||
typeof self == "object" && self.Object == Object ? self : window, | ||
function(__$source__, __$global__) { | ||
// jshint ignore:line | ||
eval("(function() { " + __$source__ + " \n }).call(__$global__);"); | ||
} | ||
); | ||
/*can-deparam@1.0.1#can-deparam*/ | ||
define('can-deparam', [ | ||
'require', | ||
'exports', | ||
'module', | ||
'can-namespace' | ||
], function (require, exports, module) { | ||
var namespace = require('can-namespace'); | ||
@@ -156,6 +181,6 @@ var digitTest = /^\d+$/, keyBreaker = /([^\[\]]+)|(\[\])/g, paramTest = /([^?#]*)(#.*)?$/, entityRegex = /%([^0-9a-f][0-9a-f]|[0-9a-f][^0-9a-f]|[^0-9a-f][^0-9a-f])/i, prep = function (str) { | ||
/*[global-shim-end]*/ | ||
(function(){ // jshint ignore:line | ||
window._define = window.define; | ||
window.define = window.define.orig; | ||
(function(global) { // jshint ignore:line | ||
global._define = global.define; | ||
global.define = global.define.orig; | ||
} | ||
)(); | ||
)(typeof self == "object" && self.Object == Object ? self : window); |
{ | ||
"name": "can-deparam", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Deserialize a query string into an array or object.", | ||
@@ -20,3 +20,3 @@ "homepage": "https://canjs.com/", | ||
"testee": "testee test.html --browsers firefox", | ||
"test": "npm run jshint && npm run testee", | ||
"test": "npm run detect-cycle && npm run jshint && npm run testee", | ||
"jshint": "jshint ./*.js --config", | ||
@@ -27,3 +27,4 @@ "release:patch": "npm version patch && npm publish", | ||
"build": "node build.js", | ||
"develop": "done-serve --static --develop --port 8080" | ||
"develop": "done-serve --static --develop --port 8080", | ||
"detect-cycle": "detect-cyclic-packages --ignore done-serve" | ||
}, | ||
@@ -51,2 +52,6 @@ "main": "dist/cjs/can-deparam", | ||
"devDependencies": { | ||
"detect-cyclic-packages": "^1.1.0", | ||
"done-serve": "^1.0.0", | ||
"donejs-cli": "^1.0.0", | ||
"generator-donejs": "^1.0.0", | ||
"jshint": "^2.9.1", | ||
@@ -56,7 +61,4 @@ "steal": "^1.3.1", | ||
"steal-tools": "^1.2.0", | ||
"testee": "^0.3.0", | ||
"generator-donejs": "^1.0.0", | ||
"donejs-cli": "^1.0.0", | ||
"done-serve": "^1.0.0" | ||
"testee": "^0.3.0" | ||
} | ||
} |
# can-deparam | ||
[![Build Status](https://travis-ci.org/canjs/can-deparam.png?branch=master)](https://travis-ci.org/canjs/can-deparam) | ||
[![Join the chat at https://gitter.im/canjs/canjs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/canjs/canjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/canjs/can-deparam/blob/master/LICENSE.md) | ||
[![npm version](https://badge.fury.io/js/can-deparam.svg)](https://www.npmjs.com/package/can-deparam) | ||
[![Travis build status](https://travis-ci.org/canjs/can-deparam.svg?branch=master)](https://travis-ci.org/canjs/can-deparam) | ||
Deserialize a query string into an array or object. | ||
## Usage | ||
## Documentation | ||
### ES6 use | ||
Read the [API docs on CanJS.com](https://canjs.com/doc/can-deparam.html). | ||
With StealJS, you can import this module directly in a template that is autorendered: | ||
## Changelog | ||
```js | ||
import plugin from 'can-deparam'; | ||
``` | ||
See the [latest releases on GitHub](https://github.com/canjs/can-deparam/releases). | ||
### CommonJS use | ||
## Contributing | ||
Use `require` to load `can-deparam` and everything else | ||
needed to create a template that uses `can-deparam`: | ||
The [contribution guide](https://github.com/canjs/can-deparam/blob/master/CONTRIBUTING.md) has information on getting help, reporting bugs, developing locally, and more. | ||
```js | ||
var plugin = require("can-deparam"); | ||
``` | ||
## License | ||
## AMD use | ||
Configure the `can` and `jquery` paths and the `can-deparam` package: | ||
```html | ||
<script src="require.js"></script> | ||
<script> | ||
require.config({ | ||
paths: { | ||
"jquery": "node_modules/jquery/dist/jquery", | ||
"can": "node_modules/canjs/dist/amd/can" | ||
}, | ||
packages: [{ | ||
name: 'can-deparam', | ||
location: 'node_modules/can-deparam/dist/amd', | ||
main: 'lib/can-deparam' | ||
}] | ||
}); | ||
require(["main-amd"], function(){}); | ||
</script> | ||
``` | ||
### Standalone use | ||
Load the `global` version of the plugin: | ||
```html | ||
<script src='./node_modules/can-deparam/dist/global/can-deparam.js'></script> | ||
``` | ||
[MIT](https://github.com/canjs/can-deparam/blob/master/LICENSE.md) |
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
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
21082
401
9
25