bower
Version:
The browser package manager
41 lines (40 loc) • 4.66 kB
JSON
{
"name": "bower-endpoint-parser",
"version": "0.2.2",
"description": "Little module that helps with endpoints parsing.",
"author": {
"name": "Twitter"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/bower/endpoint-parser/blob/master/LICENSE"
}
],
"repository": {
"type": "git",
"url": "git://github.com/bower/endpoint-parser.git"
},
"main": "index.js",
"engines": {
"node": ">=0.8.0"
},
"devDependencies": {
"expect.js": "~0.2.0",
"mocha": "~1.12.0",
"mout": "~0.9.0"
},
"scripts": {
"test": "mocha -R spec"
},
"readme": "# endpoint-parser [](http://travis-ci.org/bower/endpoint-parser)\n\nLittle module that helps with endpoints parsing.\n\n\n## API\n\n### .decompose(endpoint)\n\nDecomposes a endpoint into `name`, `source` and `target`.\n\n```js\nvar endpointParser = require('bower-endpoint-parser');\n\nendpointParser.decompose('jquery#~2.0.0');\n// { name: '', source: 'jquery', target: '~2.0.0' }\n\nendpointParser.decompose('backbone=backbone-amd#~1.0.0');\n// { name: 'backbone', source: 'backbone-amd', target: '~1.0.0' }\n\nendpointParser.decompose('http://twitter.github.io/bootstrap/assets/bootstrap.zip');\n// { name: '', source: 'http://twitter.github.io/bootstrap/assets/bootstrap', target: '*' }\n\nendpointParser.decompose('bootstrap=http://twitter.github.io/bootstrap/assets/bootstrap.zip');\n// { name: 'bootstrap', source: 'http://twitter.github.io/bootstrap/assets/bootstrap', target: '*' }\n```\n\n### .compose(decEndpoint)\n\nInverse of `decompose()`. \nTakes a decomposed endpoint and composes it back into a string.\n\n```js\nvar endpointParser = require('bower-endpoint-parser');\n\nendpointParser.compose({ name: '', source: 'jquery', target: '~2.0.0' });\n// jquery#~2.0.0\n\nendpointParser.compose({ name: 'backbone', source: 'backbone-amd', target: '~1.0.0' });\n// backbone=backbone-amd#~1.0.0\n\nendpointParser.compose({ name: '', source: 'http://twitter.github.io/bootstrap/assets/bootstrap', target: '*' });\n// http://twitter.github.io/bootstrap/assets/bootstrap.zip\n\nendpointParser.compose({ name: 'bootstrap', source: 'http://twitter.github.io/bootstrap/assets/bootstrap', target: '*' });\n// bootstrap=http://twitter.github.io/bootstrap/assets/bootstrap.zip\n```\n\n### .json2decomposed(key, value)\n\nSimilar to `decompose()` but specially designed to be used when parsing `bower.json` dependencies.\nFor instance, in a `bower.json` like this:\n\n```js\n{\n \"name\": \"foo\",\n \"version\": \"0.1.0\",\n \"dependencies\": {\n \"jquery\": \"~1.9.1\",\n \"backbone\": \"backbone-amd#~1.0.0\",\n \"bootstrap\": \"http://twitter.github.io/bootstrap/assets/bootstrap\"\n }\n}\n```\n\nYou would call `json2decomposed` like so:\n\n```js\nendpointParser.json2decomposed('jquery', '~1.9.1');\n// { name: 'jquery', source: 'jquery', target: '~1.9.1' }\n\nendpointParser.json2decomposed('backbone', 'backbone-amd#~1.0.0');\n// { name: 'backbone', source: 'backbone-amd', target: '~1.0.0' }\n\nendpointParser.json2decomposed('bootstrap', 'http://twitter.github.io/bootstrap/assets/bootstrap');\n// { name: 'bootstrap', source: 'http://twitter.github.io/bootstrap/assets/bootstrap', target: '*' }\n```\n\n### .decomposed2json(decEndpoint)\n\nInverse of `json2decomposed()`. \nTakes a decomposed endpoint and composes it to be saved to `bower.json`.\n\n```js\nvar endpointParser = require('bower-endpoint-parser');\n\nendpointParser.decomposed2json({ name: 'jquery', source: 'jquery', target: '~2.0.0' });\n// { jquery: '~2.0.0' }\n\nendpointParser.decomposed2json({ name: 'backbone', source: 'backbone-amd', target: '~1.0.0' });\n// { backbone: 'backbone-amd#~2.0.0' }\n\nendpointParser.decomposed2json({ name: 'bootstrap', source: 'http://twitter.github.io/bootstrap/assets/bootstrap', target: '*' });\n// { bootstrap: 'http://twitter.github.io/bootstrap/assets/bootstrap' }\n```\n\nThis function throws an exception if the `name` from the decomposed endpoint is empty.\n\n\n## License\n\nReleased under the [MIT License](http://www.opensource.org/licenses/mit-license.php).\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/bower/endpoint-parser/issues"
},
"homepage": "https://github.com/bower/endpoint-parser#readme",
"_id": "bower-endpoint-parser@0.2.2",
"_shasum": "00b565adbfab6f2d35addde977e97962acbcb3f6",
"_resolved": "https://registry.npmjs.org/bower-endpoint-parser/-/bower-endpoint-parser-0.2.2.tgz",
"_from": "bower-endpoint-parser@>=0.2.2 <0.3.0"
}