Skip to content

Commit

Permalink
updated alias
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeer264 committed Dec 2, 2016
1 parent d4453e1 commit 49f4eaf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
18 changes: 13 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@ var jsonExtra = module.exports = {
}

function doRequire(name, alias) {
if (alias){
jsonExtra[name] = require('./lib/' + name);

if (alias) {
if (Object.prototype.toString.call(alias) === '[object Array]') {
for (var aka in alias) {
jsonExtra[aka] = require('./lib/' + name);
}

return
}

return jsonExtra[alias] = require('./lib/' + name);
}

return jsonExtra[name] = require('./lib/' + name);
}

doRequire('check');
doRequire('toPath');
doRequire('check', ['isJson', 'isValid']);
doRequire('toPath', 'chain');
doRequire('readToObj');
doRequire('readToObjSync');
doRequire('create');
Expand Down
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ var json = require('json-extra');

Check if it is a valid string or object. Just do a `JSON.parse` but with `try - catch`. Returns a boolean. The `type` is optional it its default is `string`. If you want to check if you have a object you can type in `object` as `type`.

`type` valid values: `string` or `object`
`type` valid values: `string` or `object`. Default: `string`

Alias: `isJson()`
Alias: `isValid()`

Example:

Expand All @@ -68,6 +69,8 @@ If you want to change your json string into a path just hit this method.
`base` in an object is always the name of the folder.
`subfolders` create new subfolders

Alias: `chain()`

Example:

```js
Expand Down

0 comments on commit 49f4eaf

Please sign in to comment.