fix
This commit is contained in:
15
book/node_modules/safe-json-parse/.npmignore
generated
vendored
Normal file
15
book/node_modules/safe-json-parse/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
.DS_Store
|
||||
.monitor
|
||||
.*.swp
|
||||
.nodemonignore
|
||||
releases
|
||||
*.log
|
||||
*.err
|
||||
fleet.json
|
||||
public/browserify
|
||||
bin/*.json
|
||||
.bin
|
||||
build
|
||||
compile
|
||||
.lock-wscript
|
||||
node_modules
|
14
book/node_modules/safe-json-parse/.testem.json
generated
vendored
Normal file
14
book/node_modules/safe-json-parse/.testem.json
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"launchers": {
|
||||
"node": {
|
||||
"command": "node ./test"
|
||||
}
|
||||
},
|
||||
"src_files": [
|
||||
"./**/*.js"
|
||||
],
|
||||
"before_tests": "npm run build-test",
|
||||
"on_exit": "rm test/static/bundle.js",
|
||||
"test_page": "test/static/index.html",
|
||||
"launch_in_dev": ["node", "phantomjs"]
|
||||
}
|
6
book/node_modules/safe-json-parse/.travis.yml
generated
vendored
Normal file
6
book/node_modules/safe-json-parse/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
- 0.9
|
||||
- 0.10
|
||||
script: node ./test/index.js
|
19
book/node_modules/safe-json-parse/LICENCE
generated
vendored
Normal file
19
book/node_modules/safe-json-parse/LICENCE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2013 Raynos.
|
||||
|
||||
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.
|
39
book/node_modules/safe-json-parse/README.md
generated
vendored
Normal file
39
book/node_modules/safe-json-parse/README.md
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# safe-json-parse
|
||||
|
||||
[![build status][1]][2] [![dependency status][3]][4]
|
||||
|
||||
<!-- [![browser support][5]][6] -->
|
||||
|
||||
Parse JSON safely without throwing
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var safeParse = require("safe-json-parse")
|
||||
|
||||
safeParse("{}", function (err, json) {
|
||||
/* we have json */
|
||||
})
|
||||
|
||||
safeparse("WRONG", function (err) {
|
||||
/* we have err! */
|
||||
})
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
`npm install safe-json-parse`
|
||||
|
||||
## Contributors
|
||||
|
||||
- Raynos
|
||||
|
||||
## MIT Licenced
|
||||
|
||||
|
||||
[1]: https://secure.travis-ci.org/Raynos/safe-json-parse.png
|
||||
[2]: https://travis-ci.org/Raynos/safe-json-parse
|
||||
[3]: https://david-dm.org/Raynos/safe-json-parse.png
|
||||
[4]: https://david-dm.org/Raynos/safe-json-parse
|
||||
[5]: https://ci.testling.com/Raynos/safe-json-parse.png
|
||||
[6]: https://ci.testling.com/Raynos/safe-json-parse
|
0
book/node_modules/safe-json-parse/examples/simple.js
generated
vendored
Normal file
0
book/node_modules/safe-json-parse/examples/simple.js
generated
vendored
Normal file
18
book/node_modules/safe-json-parse/index.js
generated
vendored
Normal file
18
book/node_modules/safe-json-parse/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
module.exports = SafeParse
|
||||
|
||||
function SafeParse(obj, reviver, callback) {
|
||||
if (arguments.length === 2) {
|
||||
callback = reviver
|
||||
reviver = null
|
||||
}
|
||||
|
||||
var json
|
||||
|
||||
try {
|
||||
json = JSON.parse(obj, reviver)
|
||||
} catch (err) {
|
||||
return callback(err)
|
||||
}
|
||||
|
||||
callback(null, json)
|
||||
}
|
48
book/node_modules/safe-json-parse/package.json
generated
vendored
Normal file
48
book/node_modules/safe-json-parse/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "safe-json-parse",
|
||||
"version": "1.0.1",
|
||||
"description": "Parse JSON safely without throwing",
|
||||
"keywords": [],
|
||||
"author": "Raynos <raynos2@gmail.com>",
|
||||
"repository": "git://github.com/Raynos/safe-json-parse.git",
|
||||
"main": "index",
|
||||
"homepage": "https://github.com/Raynos/safe-json-parse",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Raynos"
|
||||
}
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/Raynos/safe-json-parse/issues",
|
||||
"email": "raynos2@gmail.com"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tape": "~1.0.2"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://github.com/Raynos/safe-json-parse/raw/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"scripts": {
|
||||
"test": "node ./test/index.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/index.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/16..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/22..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
}
|
||||
}
|
26
book/node_modules/safe-json-parse/test/index.js
generated
vendored
Normal file
26
book/node_modules/safe-json-parse/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
var test = require("tape")
|
||||
|
||||
var safeParse = require("../index")
|
||||
|
||||
test("safeParse is a function", function (assert) {
|
||||
assert.equal(typeof safeParse, "function")
|
||||
assert.end()
|
||||
})
|
||||
|
||||
test("safeParse valid json", function (assert) {
|
||||
safeParse("{ \"foo\": true }", function (err, json) {
|
||||
assert.ifError(err)
|
||||
assert.equal(json.foo, true)
|
||||
|
||||
assert.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("safeParse faulty", function (assert) {
|
||||
safeParse("WRONG", function (err) {
|
||||
assert.ok(err)
|
||||
assert.equal(err.message, "Unexpected token W")
|
||||
|
||||
assert.end()
|
||||
})
|
||||
})
|
11
book/node_modules/safe-json-parse/test/static/index.html
generated
vendored
Normal file
11
book/node_modules/safe-json-parse/test/static/index.html
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>TAPE Example</title>
|
||||
<script src="/testem.js"></script>
|
||||
<script src="test-adapter.js"></script>
|
||||
<script src="bundle.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
49
book/node_modules/safe-json-parse/test/static/test-adapter.js
generated
vendored
Normal file
49
book/node_modules/safe-json-parse/test/static/test-adapter.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
(function () {
|
||||
var Testem = window.Testem
|
||||
var regex = /^((?:not )?ok) (\d+) (.+)$/
|
||||
|
||||
Testem.useCustomAdapter(tapAdapter)
|
||||
|
||||
function tapAdapter(socket){
|
||||
var results = {
|
||||
failed: 0
|
||||
, passed: 0
|
||||
, total: 0
|
||||
, tests: []
|
||||
}
|
||||
|
||||
socket.emit('tests-start')
|
||||
|
||||
Testem.handleConsoleMessage = function(msg){
|
||||
var m = msg.match(regex)
|
||||
if (m) {
|
||||
var passed = m[1] === 'ok'
|
||||
var test = {
|
||||
passed: passed ? 1 : 0,
|
||||
failed: passed ? 0 : 1,
|
||||
total: 1,
|
||||
id: m[2],
|
||||
name: m[3],
|
||||
items: []
|
||||
}
|
||||
|
||||
if (passed) {
|
||||
results.passed++
|
||||
} else {
|
||||
results.failed++
|
||||
}
|
||||
|
||||
results.total++
|
||||
|
||||
socket.emit('test-result', test)
|
||||
results.tests.push(test)
|
||||
} else if (msg === '# ok' || msg.match(/^# tests \d+/)){
|
||||
socket.emit('all-test-results', results)
|
||||
}
|
||||
|
||||
// return false if you want to prevent the console message from
|
||||
// going to the console
|
||||
// return false
|
||||
}
|
||||
}
|
||||
}())
|
Reference in New Issue
Block a user