Skip to content

Commit 49f4eaf

Browse files
committed
updated alias
1 parent d4453e1 commit 49f4eaf

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,23 @@ var jsonExtra = module.exports = {
88
}
99

1010
function doRequire(name, alias) {
11-
if (alias){
11+
jsonExtra[name] = require('./lib/' + name);
12+
13+
if (alias) {
14+
if (Object.prototype.toString.call(alias) === '[object Array]') {
15+
for (var aka in alias) {
16+
jsonExtra[aka] = require('./lib/' + name);
17+
}
18+
19+
return
20+
}
21+
1222
return jsonExtra[alias] = require('./lib/' + name);
1323
}
14-
15-
return jsonExtra[name] = require('./lib/' + name);
1624
}
1725

18-
doRequire('check');
19-
doRequire('toPath');
26+
doRequire('check', ['isJson', 'isValid']);
27+
doRequire('toPath', 'chain');
2028
doRequire('readToObj');
2129
doRequire('readToObjSync');
2230
doRequire('create');

readme.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ var json = require('json-extra');
4747

4848
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`.
4949

50-
`type` valid values: `string` or `object`
50+
`type` valid values: `string` or `object`. Default: `string`
5151

5252
Alias: `isJson()`
53+
Alias: `isValid()`
5354

5455
Example:
5556

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

72+
Alias: `chain()`
73+
7174
Example:
7275

7376
```js

0 commit comments

Comments
 (0)