mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-08-01 12:13:18 +00:00
feature(util) json -> jonny
This commit is contained in:
parent
ee1c264aac
commit
40f1eb46cc
10 changed files with 190 additions and 34 deletions
35
modules/jonny/.bower.json
Normal file
35
modules/jonny/.bower.json
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "jonny",
|
||||
"version": "1.0.1",
|
||||
"homepage": "https://github.com/coderaiser/jonny",
|
||||
"authors": [
|
||||
"coderaiser <mnemonic.enemy@gmail.com>"
|
||||
],
|
||||
"description": "work with json without exaptions",
|
||||
"main": "lib/jonny.js",
|
||||
"moduleType": [
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"json",
|
||||
"try"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"modules"
|
||||
],
|
||||
"dependencies": {},
|
||||
"_release": "1.0.1",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.1",
|
||||
"commit": "b8909d33db868af9797c95881891c5d432209f1a"
|
||||
},
|
||||
"_source": "https://github.com/coderaiser/jonny.git",
|
||||
"_target": "^1.0.1",
|
||||
"_originalSource": "jonny",
|
||||
"_direct": true
|
||||
}
|
||||
21
modules/jonny/LICENSE
Normal file
21
modules/jonny/LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 coderaiser
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
26
modules/jonny/README.md
Normal file
26
modules/jonny/README.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Jonny
|
||||
|
||||
Work with json without exeptions.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm i jonny --save
|
||||
```
|
||||
|
||||
## How to use?
|
||||
|
||||
```js
|
||||
var jonny = require('jonny'),
|
||||
obj = jonny.parse('{ "hello": "world" }');
|
||||
|
||||
console.log(jonny.stringify(obj, 0, 4));
|
||||
// results
|
||||
// "{
|
||||
// "hello": "world"
|
||||
// }"
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
26
modules/jonny/bower.json
Normal file
26
modules/jonny/bower.json
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "jonny",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://github.com/coderaiser/jonny",
|
||||
"authors": [
|
||||
"coderaiser <mnemonic.enemy@gmail.com>"
|
||||
],
|
||||
"description": "work with json without exaptions",
|
||||
"main": "lib/jonny.js",
|
||||
"moduleType": [
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"json",
|
||||
"try"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"modules"
|
||||
],
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
||||
45
modules/jonny/lib/jonny.js
Normal file
45
modules/jonny/lib/jonny.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
(function(global) {
|
||||
'use strict';
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports)
|
||||
module.exports = new Jonny();
|
||||
else
|
||||
global.jonny = new Jonny();
|
||||
|
||||
function Jonny() {
|
||||
this.parse = function() {
|
||||
var ret,
|
||||
args = arguments;
|
||||
|
||||
tryCatch(function() {
|
||||
ret = JSON.parse.apply(JSON, args);
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
this.stringify = function() {
|
||||
var ret,
|
||||
args = arguments;
|
||||
|
||||
tryCatch(function() {
|
||||
ret = JSON.stringify.apply(JSON, args);
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
function tryCatch(fn) {
|
||||
var error;
|
||||
|
||||
try {
|
||||
fn();
|
||||
} catch(e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
})(this);
|
||||
27
modules/jonny/package.json
Normal file
27
modules/jonny/package.json
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "jonny",
|
||||
"version": "1.0.0",
|
||||
"description": "work with json without exaptions",
|
||||
"main": "lib/jonny.js",
|
||||
"dependencies": {
|
||||
"diff-match-patch": "~1.0.0"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/coderaiser/jonny.git"
|
||||
},
|
||||
"keywords": [
|
||||
"json",
|
||||
"try"
|
||||
],
|
||||
"author": "coderaiser <mnemonic.enemy@gmail.com> (http://coderaiser.github.io/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/coderaiser/jonny/issues"
|
||||
},
|
||||
"homepage": "https://github.com/coderaiser/jonny"
|
||||
}
|
||||
|
|
@ -32,7 +32,6 @@
|
|||
"commit": "d5fbf701270e46919e63d287be0834c6b718ae51"
|
||||
},
|
||||
"_source": "https://github.com/coderaiser/smalltalk.git",
|
||||
"_target": "^2.1.1",
|
||||
"_originalSource": "smalltalk",
|
||||
"_direct": true
|
||||
"_target": "2.1.1",
|
||||
"_originalSource": "smalltalk"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue