diff --git a/bower.json b/bower.json index 7830e8b5..5031953e 100644 --- a/bower.json +++ b/bower.json @@ -40,6 +40,7 @@ "philip": "^1.3.3", "jquery": "3.1.0", "promise-polyfill": "6.0.0", - "smalltalk": "2.1.1" + "smalltalk": "2.1.1", + "jonny": "1.0.1" } } diff --git a/lib/client/cloudcmd.js b/lib/client/cloudcmd.js index 35beef5f..6a756865 100644 --- a/lib/client/cloudcmd.js +++ b/lib/client/cloudcmd.js @@ -35,7 +35,8 @@ var CloudCmd; libDir('format', 'format-io'), libDir('rendy'), libDir('emitify', '', 'dist'), - libDir('exec', 'execon') + libDir('exec', 'execon'), + libDir('jonny') ].filter(function(name) { return name; }).map(function(name) { diff --git a/lib/util.js b/lib/util.js index f9832950..be653431 100644 --- a/lib/util.js +++ b/lib/util.js @@ -3,15 +3,18 @@ var exec, rendy, + jonny, Scope = scope.window ? window : global; if (typeof module === 'object' && module.exports) { exec = require('execon'); rendy = require('rendy'); + jonny = require('jonny'); module.exports = new UtilProto(exec); } else if (!Scope.Util) { exec = window.exec; rendy = window.rendy; + jonny = window.jonny; Scope.Util = new UtilProto(exec); } @@ -148,35 +151,7 @@ return ret; }; - this.json = new JsonProto(); - - function JsonProto() { - /** - * @param str - */ - this.parse = function(str) { - var obj; - - Util.exec.try(function() { - obj = JSON.parse(str); - }); - - return obj; - }, - - /** - * @param obj - */ - this.stringify = function(obj) { - var str; - - Util.exec.try(function() { - str = JSON.stringify(obj, null, 4); - }); - - return str; - }; - } + this.json = jonny; this.escapeRegExp = function(str) { var isStr = Util.type.string(str); diff --git a/modules/jonny/.bower.json b/modules/jonny/.bower.json new file mode 100644 index 00000000..b30f0b25 --- /dev/null +++ b/modules/jonny/.bower.json @@ -0,0 +1,35 @@ +{ + "name": "jonny", + "version": "1.0.1", + "homepage": "https://github.com/coderaiser/jonny", + "authors": [ + "coderaiser " + ], + "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 +} \ No newline at end of file diff --git a/modules/jonny/LICENSE b/modules/jonny/LICENSE new file mode 100644 index 00000000..a103b669 --- /dev/null +++ b/modules/jonny/LICENSE @@ -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. diff --git a/modules/jonny/README.md b/modules/jonny/README.md new file mode 100644 index 00000000..a6eb21e5 --- /dev/null +++ b/modules/jonny/README.md @@ -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 diff --git a/modules/jonny/bower.json b/modules/jonny/bower.json new file mode 100644 index 00000000..de3db23a --- /dev/null +++ b/modules/jonny/bower.json @@ -0,0 +1,26 @@ +{ + "name": "jonny", + "version": "1.0.0", + "homepage": "https://github.com/coderaiser/jonny", + "authors": [ + "coderaiser " + ], + "description": "work with json without exaptions", + "main": "lib/jonny.js", + "moduleType": [ + "globals", + "node" + ], + "keywords": [ + "json", + "try" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "modules" + ], + "dependencies": { + } +} diff --git a/modules/jonny/lib/jonny.js b/modules/jonny/lib/jonny.js new file mode 100644 index 00000000..74d9e3db --- /dev/null +++ b/modules/jonny/lib/jonny.js @@ -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); diff --git a/modules/jonny/package.json b/modules/jonny/package.json new file mode 100644 index 00000000..7b9af053 --- /dev/null +++ b/modules/jonny/package.json @@ -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 (http://coderaiser.github.io/)", + "license": "MIT", + "bugs": { + "url": "https://github.com/coderaiser/jonny/issues" + }, + "homepage": "https://github.com/coderaiser/jonny" +} diff --git a/modules/smalltalk/.bower.json b/modules/smalltalk/.bower.json index f55bc074..00bd6e08 100644 --- a/modules/smalltalk/.bower.json +++ b/modules/smalltalk/.bower.json @@ -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" } \ No newline at end of file