# add dist

This commit is contained in:
Mario Romano
2016-04-21 11:56:31 +01:00
parent 5914688467
commit 07807e7bc3
13499 changed files with 1808930 additions and 5 deletions

View File

@@ -0,0 +1,3 @@
test:
@./node_modules/.bin/mocha test.js

View File

@@ -0,0 +1,37 @@
/**
* Compiles a querystring
* Returns string representation of the object
*
* @param {Object}
* @api private
*/
exports.encode = function (obj) {
var str = '';
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
if (str.length) str += '&';
str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
}
}
return str;
};
/**
* Parses a simple querystring into an object
*
* @param {String} qs
* @api private
*/
exports.decode = function(qs){
var qry = {};
var pairs = qs.split('&');
for (var i = 0, l = pairs.length; i < l; i++) {
var pair = pairs[i].split('=');
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
return qry;
};

View File

@@ -0,0 +1,62 @@
{
"_args": [
[
"parseqs@0.0.2",
"/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/browser-sync/node_modules/engine.io-client"
]
],
"_from": "parseqs@0.0.2",
"_id": "parseqs@0.0.2",
"_inCache": true,
"_installable": true,
"_location": "/parseqs",
"_npmUser": {
"email": "koren@mit.edu",
"name": "gal"
},
"_npmVersion": "1.3.15",
"_phantomChildren": {},
"_requested": {
"name": "parseqs",
"raw": "parseqs@0.0.2",
"rawSpec": "0.0.2",
"scope": null,
"spec": "0.0.2",
"type": "version"
},
"_requiredBy": [
"/browser-sync/engine.io-client"
],
"_resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.2.tgz",
"_shasum": "9dfe70b2cddac388bde4f35b1f240fa58adbe6c7",
"_shrinkwrap": null,
"_spec": "parseqs@0.0.2",
"_where": "/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/browser-sync/node_modules/engine.io-client",
"author": "",
"dependencies": {
"better-assert": "~1.0.0"
},
"description": "Provides methods for parsing a query string into an object, and vice versa.",
"devDependencies": {
"mocha": "1.17.1"
},
"directories": {},
"dist": {
"shasum": "9dfe70b2cddac388bde4f35b1f240fa58adbe6c7",
"tarball": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.2.tgz"
},
"license": "MIT",
"maintainers": [
{
"email": "koren@mit.edu",
"name": "gal"
}
],
"name": "parseqs",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"scripts": {
"test": "make test"
},
"version": "0.0.2"
}

View File

@@ -0,0 +1,27 @@
var assert = require('better-assert');
var expect = require('expect.js');
var util = require('./index.js');
describe('querystring test suite', function(){
it('should parse a querystring and return an object', function () {
// Single assignment
var queryObj = util.decode("foo=bar");
expect(queryObj.foo).to.be("bar");
// Multiple assignments
queryObj = util.decode("france=paris&germany=berlin");
expect(queryObj.france).to.be("paris");
expect(queryObj.germany).to.be("berlin");
// Assignments containing non-alphanumeric characters
queryObj = util.decode("india=new%20delhi");
expect(queryObj.india).to.be("new delhi");
});
it('should construct a query string from an object', function () {
expect(util.encode({ a: 'b' })).to.be('a=b');
expect(util.encode({ a: 'b', c: 'd' })).to.be('a=b&c=d');
expect(util.encode({ a: 'b', c: 'tobi rocks' })).to.be('a=b&c=tobi%20rocks');
});
});