ancient-refs
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,10 +0,6 @@ | ||
#### 0.0.2 (2016-9-29) | ||
#### 0.0.2 (2016-11-12) | ||
##### New Features | ||
* **class:** Add id and collection. ([9fc229dc](https://github.com/AncientSouls/Refs/commit/9fc229dcc698276c2a6dd487287e68027159a6ac)) | ||
##### Bug Fixes | ||
* **package:** main file ([a2cebf78](https://github.com/AncientSouls/Refs/commit/a2cebf784a241c0dea59819e15b9174b3adfd4b7)) | ||
* **types:** Only string or undefined return ([caeb54cb](https://github.com/AncientSouls/Refs/commit/caeb54cb6fc2da4ddc4f47ac453bad5cfc64e0e7)) | ||
* **package:** main file ([a2cebf78](https://github.com/AncientSouls/Refs/commit/a2cebf784a241c0dea59819e15b9174b3adfd4b7)) |
{ | ||
"name": "ancient-refs", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Multi-storage ids syntax, parse and get methods.", | ||
@@ -38,4 +38,4 @@ "keywords": [ | ||
"scripts": { | ||
"jsdoc": "git submodule update --init --recursive --force && cd ./doc && git checkout -f gh-pages && cd ../ && npm i && rm -r ./doc/*/ && find ./doc ! -name '.git' -type f -exec rm -rf {} + && jsdoc ./*.js ./README.md -r -d ./doc -t ./node_modules/minami -c ./jsdoc.conf.json" | ||
"jsdoc": "git submodule update --init --recursive && cd ./doc && git checkout gh-pages && cd ../ && npm i && rm -r ./doc/*/ && find ./doc ! -name '.git' -type f -exec rm -rf {} + && jsdoc ./*.js ./README.md -r -d ./doc -t ./node_modules/minami -c ./jsdoc.conf.json" | ||
} | ||
} |
30
refs.js
@@ -20,4 +20,12 @@ /** | ||
* @description `refs.generate('items', 'abc'); // 'items/abc'` | ||
* @throws StorageName must be a string! | ||
* @throws Id must be a string! | ||
*/ | ||
Refs.prototype.generate = function(storageName, id) { | ||
if (typeof(storageName) != 'string') { | ||
throw new Error('StorageName must be a string!'); | ||
} | ||
if (typeof(id) != 'string') { | ||
throw new Error('Id must be a string!'); | ||
} | ||
return storageName+'/'+id; | ||
@@ -29,6 +37,9 @@ }; | ||
* @param {String} ref | ||
* @return {String[]} _ref | ||
* @return {String[]|undefined} [_ref] | ||
* @description `refs.parse('items/abc'); // ['items','abc']` | ||
*/ | ||
Refs.prototype.parse = function(id) { | ||
if (typeof(id) != 'string') { | ||
return undefined; | ||
} | ||
return id.split('/'); | ||
@@ -41,2 +52,3 @@ }; | ||
* @param {Refs~callback} [callback] | ||
* @return {Object|undefined} [document] | ||
* @description `refs.get('items/abc'); // 123` | ||
@@ -46,2 +58,3 @@ */ | ||
var _ref = this.parse(ref); | ||
if (!_ref) return undefined; | ||
return this.getters[_ref[0]](_ref[1], callback); | ||
@@ -53,22 +66,11 @@ }; | ||
* @param {String} ref | ||
* @return {*} storage | ||
* @return {*} [storage] | ||
*/ | ||
Refs.prototype.storage = function(ref) { | ||
var _ref = this.parse(ref); | ||
if (!_ref) return undefined; | ||
return this.storages[_ref[0]]; | ||
}; | ||
Refs.prototype.collection = Refs.prototype.storage; | ||
/** | ||
* @memberof Refs | ||
* @param {String} ref | ||
* @return {String} id | ||
*/ | ||
Refs.prototype.id = function(ref) { | ||
var _ref = this.parse(ref); | ||
return _ref&&_ref[1]?_ref[1]:undefined; | ||
}; | ||
/** | ||
* Callback from get method. | ||
@@ -75,0 +77,0 @@ * |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
861
14
1455563