spell 0.3.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +38 -145
  2. package/package.json +24 -21
  3. package/.npmignore +0 -4
  4. package/.travis.yml +0 -6
  5. package/LICENSE +0 -14
  6. package/spell.js +0 -347
  7. package/test/css/mocha.css +0 -110
  8. package/test/index.html +0 -34
  9. package/test/lib/JSONStream/.npmignore +0 -3
  10. package/test/lib/JSONStream/bench.js +0 -35
  11. package/test/lib/JSONStream/examples/all_docs.js +0 -13
  12. package/test/lib/JSONStream/index.js +0 -118
  13. package/test/lib/JSONStream/package.json +0 -13
  14. package/test/lib/JSONStream/readme.markdown +0 -120
  15. package/test/lib/JSONStream/test/fixtures/all_docs_include.json +0 -4245
  16. package/test/lib/JSONStream/test/fixtures/all_npm.json +0 -4030
  17. package/test/lib/JSONStream/test/parsejson.js +0 -25
  18. package/test/lib/JSONStream/test/stringify.js +0 -41
  19. package/test/lib/JSONStream/test/test.js +0 -35
  20. package/test/lib/JSONStream/test/test2.js +0 -29
  21. package/test/lib/JSONStream/test/two-ways.js +0 -41
  22. package/test/lib/jquery-1.7.1.min.js +0 -4
  23. package/test/lib/json2.js +0 -487
  24. package/test/lib/mocha-0.3.6.js +0 -2672
  25. package/test/lib/request/LICENSE +0 -55
  26. package/test/lib/request/README.md +0 -285
  27. package/test/lib/request/main.js +0 -618
  28. package/test/lib/request/mimetypes.js +0 -146
  29. package/test/lib/request/oauth.js +0 -34
  30. package/test/lib/request/package.json +0 -15
  31. package/test/lib/request/tests/googledoodle.png +0 -0
  32. package/test/lib/request/tests/run.sh +0 -6
  33. package/test/lib/request/tests/server.js +0 -57
  34. package/test/lib/request/tests/test-body.js +0 -90
  35. package/test/lib/request/tests/test-cookie.js +0 -29
  36. package/test/lib/request/tests/test-cookiejar.js +0 -90
  37. package/test/lib/request/tests/test-errors.js +0 -30
  38. package/test/lib/request/tests/test-oauth.js +0 -109
  39. package/test/lib/request/tests/test-pipes.js +0 -167
  40. package/test/lib/request/tests/test-proxy.js +0 -39
  41. package/test/lib/request/tests/test-timeout.js +0 -87
  42. package/test/lib/request/uuid.js +0 -19
  43. package/test/lib/request/vendor/cookie/index.js +0 -55
  44. package/test/lib/request/vendor/cookie/jar.js +0 -72
  45. package/test/perf.js +0 -44
  46. package/test/resources/big.js +0 -9
  47. package/test/resources/big.json +0 -29159
  48. package/test/resources/big.txt +0 -128457
  49. package/test/resources/big_browser.js +0 -29159
  50. package/test/resources/npm.js +0 -26
  51. package/test/resources/npm.json +0 -84701
  52. package/test/resources/perf1.js +0 -144
  53. package/test/resources/perf2.js +0 -366
  54. package/test/spell.js +0 -295
@@ -1,110 +0,0 @@
1
-
2
- body {
3
- font: 20px/1.5 "Helvetica Neue", Helvetica, Aria;, sans-serif;
4
- padding: 60px 50px;
5
- }
6
-
7
- #mocha h1, h2 {
8
- margin: 0;
9
- }
10
-
11
- #mocha h1 {
12
- font-size: 1em;
13
- font-weight: 200;
14
- }
15
-
16
- #mocha .suite .suite h1 {
17
- font-size: .8em;
18
- }
19
-
20
- #mocha h2 {
21
- font-size: 12px;
22
- font-weight: normal;
23
- cursor: pointer;
24
- }
25
-
26
- #mocha .suite {
27
- margin-left: 15px;
28
- }
29
-
30
- #mocha .test {
31
- margin-left: 15px;
32
- }
33
-
34
- #mocha .test.pass::before {
35
- content: '✓';
36
- font-size: 12px;
37
- display: block;
38
- float: left;
39
- margin-right: 5px;
40
- color: #00c41c;
41
- }
42
-
43
- #mocha .test.pending {
44
- color: #0b97c4;
45
- }
46
-
47
- #mocha .test.pending::before {
48
- content: '◦';
49
- color: #0b97c4;
50
- }
51
-
52
- #mocha .test.fail {
53
- color: #c00;
54
- }
55
-
56
- #mocha .test.fail pre {
57
- color: black;
58
- }
59
-
60
- #mocha .test.fail::before {
61
- content: '✖';
62
- font-size: 12px;
63
- display: block;
64
- float: left;
65
- margin-right: 5px;
66
- color: #c00;
67
- }
68
-
69
- #mocha .test pre.error {
70
- color: #c00;
71
- }
72
-
73
- #mocha .test pre {
74
- display: inline-block;
75
- font: 12px/1.5 monaco, monospace;
76
- margin: 5px;
77
- padding: 15px;
78
- border: 1px solid #eee;
79
- border-bottom-color: #ddd;
80
- -webkit-border-radius: 3px;
81
- -webkit-box-shadow: 0 1px 3px #eee;
82
- }
83
-
84
- #error {
85
- color: #c00;
86
- font-size: 1.5 em;
87
- font-weight: 100;
88
- letter-spacing: 1px;
89
- }
90
-
91
- #stats {
92
- position: fixed;
93
- top: 30px;
94
- right: 30px;
95
- font-size: 12px;
96
- margin: 0;
97
- color: #888;
98
- }
99
-
100
- #stats .progress {
101
- margin-bottom: 10px;
102
- }
103
-
104
- #stats em {
105
- color: black;
106
- }
107
-
108
- #stats li {
109
- list-style: none;
110
- }
package/test/index.html DELETED
@@ -1,34 +0,0 @@
1
- <html>
2
- <head>
3
- <title>spell.js</title>
4
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
- <link rel="stylesheet" href="css/mocha.css" />
6
- <script src="lib/jquery-1.7.1.min.js" type="text/javascript"></script>
7
- <script src="lib/mocha-0.3.6.js"></script>
8
- <script src="lib/json2.js"></script>
9
- <script src="../spell.js"></script>
10
- <script src="resources/big_browser.js"></script>
11
- <script src="resources/perf1.js"></script>
12
- <script src="resources/perf2.js"></script>
13
- <script>mocha.setup('bdd')</script>
14
- <script>
15
- function assert(expr, msg) {
16
- if (!expr) throw new Error(msg || 'failed');
17
- }
18
- </script>
19
- <script src="spell.js"></script>
20
- <script>
21
- onload = function(){
22
- var runner = mocha.run();
23
- runner.globals(['_test_spell']);
24
-
25
- runner.on('test end', function(test){
26
- console.log(test.fullTitle());
27
- });
28
- };
29
- </script>
30
- </head>
31
- <body>
32
- <div id="mocha"></div>
33
- </body>
34
- </html>
@@ -1,3 +0,0 @@
1
- node_modules
2
- node_modules/*
3
- npm_debug.log
@@ -1,35 +0,0 @@
1
-
2
-
3
- var fs = require('fs')
4
- , join = require('path').join
5
- , JSONStream = require('./')
6
- , es = require('event-stream')
7
- , request = require('request')
8
- , floby = require('json-streams').createParseStream()
9
- var file = join(__dirname, 'test/fixtures/all_docs_include.json')
10
- , stat = fs.statSync(file)
11
- , parser = JSONStream.parse(['rows',/./])
12
-
13
-
14
- function checkStream() {
15
- var start = Date.now()
16
- fs.createReadStream(file).pipe(floby)
17
- floby.on('end', function (err, array) {
18
- var time = Date.now() - start
19
-
20
- console.error({type: 'JSONStream.parse', size: stat.size, time: time})
21
- })
22
- }
23
-
24
- function checkParse() {
25
- var start = Date.now()
26
- fs.readFile(file, function (err, json) {
27
- var obj = JSON.parse(json)
28
- var time = Date.now() - start
29
-
30
- console.error({type: 'JSON.parse', size: stat.size, time: time})
31
- checkStream()
32
- })
33
- }
34
-
35
- checkParse()
@@ -1,13 +0,0 @@
1
- var request = require('request')
2
- , JSONStream = require('JSONStream')
3
- , es = require('event-stream')
4
-
5
- var parser = JSONStream.parse(['rows', /./]) //emit parts that match this path (any element of the rows array)
6
- , req = request({url: 'http://isaacs.couchone.com/registry/_all_docs'})
7
- , logger = es.mapSync(function (data) { //create a stream that logs to stderr,
8
- console.error(data)
9
- return data
10
- })
11
-
12
- req.pipe(parser)
13
- parser.pipe(logger)
@@ -1,118 +0,0 @@
1
-
2
- var Parser = require('jsonparse')
3
- , Stream = require('stream').Stream
4
-
5
- /*
6
-
7
- the value of this.stack that creationix's jsonparse has is weird.
8
-
9
- it makes this code ugly, but his problem is way harder that mine,
10
- so i'll forgive him.
11
-
12
- */
13
-
14
- exports.parse = function (path) {
15
-
16
- var stream = new Stream()
17
- var parser = new Parser()
18
- var count = 0
19
- if(!path.length)
20
- path = null
21
- parser.onValue = function () {
22
- if(!this.root && this.stack.length == 1){
23
- stream.root = this.value
24
- }
25
- if(!path || this.stack.length !== path.length)
26
- return
27
- var _path = []
28
- for( var i = 0; i < (path.length - 1); i++) {
29
- var key = path[i]
30
- var c = this.stack[1 + (+i)]
31
-
32
- if(!c) {
33
- return
34
- }
35
- var m =
36
- ( 'string' === typeof key
37
- ? c.key == key
38
- : key.exec(c.key))
39
- _path.push(c.key)
40
-
41
- if(!m)
42
- return
43
-
44
- }
45
- var c = this
46
-
47
- var key = path[path.length - 1]
48
- var m =
49
- ( 'string' === typeof key
50
- ? c.key == key
51
- : key.exec(c.key))
52
- if(!m)
53
- return
54
- _path.push(c.key)
55
-
56
- count ++
57
- stream.emit('data', this.value[this.key])
58
- }
59
-
60
-
61
- parser.onError = function (err) {
62
- stream.emit('error', err)
63
- }
64
- stream.readable = true
65
- stream.writable = true
66
- stream.write = function (chunk) {
67
- if('string' === typeof chunk)
68
- chunk = new Buffer(chunk)
69
- parser.write(chunk)
70
- }
71
- stream.end = function (data) {
72
- if(data)
73
- stream.write(data)
74
- if(!count)
75
- stream.emit('data', stream.root)
76
- stream.emit('end')
77
- }
78
- return stream
79
- }
80
-
81
- exports.stringify = function (op, sep, cl) {
82
- if (op === false){
83
- op = ''
84
- sep = '\n'
85
- cl = ''
86
- } else if (op == null) {
87
-
88
- op = '[\n'
89
- sep = '\n,\n'
90
- cl = '\n]\n'
91
-
92
- }
93
-
94
- //else, what ever you like
95
-
96
- var stream = new Stream ()
97
- , first = true
98
- , ended = false
99
- stream.write = function (data) {
100
- var json = JSON.stringify(data)
101
- if(first) { first = false ; stream.emit('data', op + json)}
102
- else stream.emit('data', sep + json)
103
- }
104
- stream.end = function (data) {
105
- if(ended)
106
- return
107
- ended = true
108
- if(data)
109
- stream.write(data)
110
- stream.emit('data', cl)
111
-
112
- stream.emit('end')
113
- }
114
- stream.writable = true
115
- stream.readable = true
116
-
117
- return stream
118
- }
@@ -1,13 +0,0 @@
1
- { "name": "JSONStream"
2
- , "version": "0.1.2"
3
- , "description": "rawStream.pipe(JSONStream.parse()).pipe(streamOfObjects)"
4
- , "homepage": "http://github.com/dominictarr/JSONStream"
5
- , "repository":
6
- { "type": "git"
7
- , "url": "https://github.com/dominictarr/JSONStream.git" }
8
- , "dependencies": {
9
- "jsonparse": "0.0.1"
10
- }
11
- , "devDependencies": {}
12
- , "author": "Dominic Tarr <dominic.tarr@gmail.com> (http://bit.ly/dominictarr)"
13
- , "scripts": { "test": "meta-test test/*.js" } }
@@ -1,120 +0,0 @@
1
- # JSONStream
2
-
3
- streaming JSON.parse and stringify
4
-
5
- ## example
6
-
7
- ```javascript
8
-
9
- var request = require('request')
10
- , JSONStream = require('JSONStream')
11
- , es = require('event-stream')
12
-
13
- var parser = JSONStream.parse(['rows', /./])
14
- , req = request({url: 'http://isaacs.couchone.com/registry/_all_docs'})
15
- , logger = es.mapSync(function (data) {
16
- console.error(data)
17
- return data
18
- })
19
- ```
20
-
21
- in node 0.4.x
22
-
23
- ``` javascript
24
-
25
- req.pipe(parser)
26
- parser.pipe(logger)
27
-
28
- ```
29
-
30
- in node v0.5.x
31
-
32
- ``` javascript
33
- req.pipe(parser).pipe(logger)
34
-
35
- ```
36
-
37
- ## JSONStream.parse(path)
38
-
39
- usally, a json API will return a list of objects.
40
-
41
- `path` should be an array of property names and/or `RedExp`s.
42
- any object that matches the path will be emitted as 'data' (and `pipe`d down stream)
43
-
44
- if `path` is empty or null, or if no matches are made:
45
- JSONStream.parse will only one 'data': the root object.
46
-
47
- (this is useful when there is an error, because the error will probably not match your path)
48
-
49
- ### example
50
-
51
- query a couchdb view:
52
-
53
- ``` bash
54
- curl -sS localhost:5984/tests/_all_docs&include_docs=true
55
- ```
56
- you will get something like this:
57
-
58
- ``` js
59
- {"total_rows":129,"offset":0,"rows":[
60
- { "id":"change1_0.6995461115147918"
61
- , "key":"change1_0.6995461115147918"
62
- , "value":{"rev":"1-e240bae28c7bb3667f02760f6398d508"}
63
- , "doc":{
64
- "_id": "change1_0.6995461115147918"
65
- , "_rev": "1-e240bae28c7bb3667f02760f6398d508","hello":1}
66
- },
67
- { "id":"change2_0.6995461115147918"
68
- , "key":"change2_0.6995461115147918"
69
- , "value":{"rev":"1-13677d36b98c0c075145bb8975105153"}
70
- , "doc":{
71
- "_id":"change2_0.6995461115147918"
72
- , "_rev":"1-13677d36b98c0c075145bb8975105153"
73
- , "hello":2
74
- }
75
- },
76
- ]}
77
-
78
- ```
79
-
80
- we are probably most interested in the `rows.*.docs`
81
-
82
- create a `Stream` that parses the documents from the feed like this:
83
-
84
- ``` js
85
- JSONStream.parse(['rows', /./, 'doc']) //rows, ANYTHING, doc
86
- ```
87
- awesome!
88
-
89
- ## JSONStream.stringify(open, sep, close)
90
-
91
- Create a writable stream.
92
-
93
- you may pass in custom `open`, `close`, and `seperator` strings.
94
- But, by default, `JSONStream.stringify()` will create an array,
95
- (with default options `open='[\n', sep='\n,\n', cl='\n]\n'`)
96
-
97
- If you call `JSONStream.stringify(false)`
98
- the elements will only be seperated by a newline.
99
-
100
- If you only write one item this will be valid JSON.
101
-
102
- If you write many items,
103
- you can use a `RegExp` to split it into valid chunks.
104
-
105
- ## numbers
106
-
107
- There are occasional problems parsing and unparsing very precise numbers.
108
-
109
- I have opened an issue here:
110
-
111
- https://github.com/creationix/jsonparse/issues/2
112
-
113
- +1
114
-
115
- ## Acknowlegements
116
-
117
- this module depends on https://github.com/creationix/jsonparse
118
- by Tim Caswell
119
- and also thanks to Florent Jaby for teaching me about parsing with:
120
- https://github.com/Floby/node-json-streams