Skip to content

Commit 1e49402

Browse files
author
elf Pavlik
committed
[style] move away from comma first
1 parent 8050989 commit 1e49402

13 files changed

Lines changed: 257 additions & 279 deletions

README.md

Lines changed: 79 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ WORK IN PROGRESS! [#3](http://github.com/mcollina/levelgraph-jsonld/issues/3)
3030

3131
Adding support for JSON-LD to LevelGraph is easy:
3232
```javascript
33-
var levelgraph = require('levelgraph')
34-
, jsonld = require('levelgraph-jsonld')
35-
, db = jsonld(levelgraph('yourdb'));
33+
var levelgraph = require('levelgraph'),
34+
jsonld = require('levelgraph-jsonld'),
35+
db = jsonld(levelgraph('yourdb'));
3636
```
3737

3838
### Put
@@ -46,17 +46,17 @@ matching `"42"^^<http://www.w3.org/2001/XMLSchema#integer>`
4646
Storing triples from JSON-LD document is extremely easy:
4747
```javascript
4848
var manu = {
49-
"@context": {
50-
"name": "http://xmlns.com/foaf/0.1/name"
51-
, "homepage": {
52-
"@id": "http://xmlns.com/foaf/0.1/homepage"
53-
, "@type": "@id"
54-
}
49+
"@context": {
50+
"name": "http://xmlns.com/foaf/0.1/name",
51+
"homepage": {
52+
"@id": "http://xmlns.com/foaf/0.1/homepage",
53+
"@type": "@id"
5554
}
56-
, "@id": "http://manu.sporny.org#person"
57-
, "name": "Manu Sporny"
58-
, "homepage": "http://manu.sporny.org/"
59-
}
55+
},
56+
"@id": "http://manu.sporny.org#person",
57+
"name": "Manu Sporny",
58+
"homepage": "http://manu.sporny.org/"
59+
};
6060

6161
db.jsonld.put(manu, function(err, obj) {
6262
// do something after the obj is inserted
@@ -75,26 +75,26 @@ db.jsonld.put(manu, { base: 'http://this/is/an/iri' }, function(err, obj) {
7575

7676
`'base'` can also be specified when you create the db:
7777
```javascript
78-
var levelgraph = require('levelgraph')
79-
, jsonld = require('levelgraph-jsonld')
80-
, opts = { base: 'http://matteocollina.com/base' }
81-
, db = jsonld(levelgraph('yourdb'), opts);
78+
var levelgraph = require('levelgraph'),
79+
jsonld = require('levelgraph-jsonld'),
80+
opts = { base: 'http://matteocollina.com/base' },
81+
db = jsonld(levelgraph('yourdb'), opts);
8282
```
8383

8484
__LevelGraph-JSONLD__ also support nested objects, like so:
8585
```javascript
8686
var nested = {
87-
"@context": {
88-
"name": "http://xmlns.com/foaf/0.1/name"
89-
, "knows": "http://xmlns.com/foaf/0.1/knows"
90-
}
91-
, "@id": "http://matteocollina.com"
92-
, "name": "matteo"
93-
, "knows": [{
94-
"name": "daniele"
95-
}, {
96-
"name": "lucio"
97-
}]
87+
"@context": {
88+
"name": "http://xmlns.com/foaf/0.1/name",
89+
"knows": "http://xmlns.com/foaf/0.1/knows"
90+
},
91+
"@id": "http://matteocollina.com",
92+
"name": "Matteo",
93+
"knows": [{
94+
"name": "Daniele"
95+
}, {
96+
"name": "Lucio"
97+
}]
9898
};
9999

100100
db.jsonld.put(nested, function(err, obj) {
@@ -118,35 +118,35 @@ As with `'put'` it correctly support nested objects. If nested objects didn't or
118118
them as *blank node identifiers*:
119119
```javascript
120120
var nested = {
121-
"@context": {
122-
"name": "http://xmlns.com/foaf/0.1/name"
123-
, "knows": "http://xmlns.com/foaf/0.1/knows"
124-
}
125-
, "@id": "http://matteocollina.com"
126-
, "name": "matteo"
127-
, "knows": [{
128-
"name": "daniele"
129-
}, {
130-
"name": "lucio"
131-
}]
121+
"@context": {
122+
"name": "http://xmlns.com/foaf/0.1/name",
123+
"knows": "http://xmlns.com/foaf/0.1/knows"
124+
},
125+
"@id": "http://matteocollina.com",
126+
"name": "Matteo",
127+
"knows": [{
128+
"name": "Daniele"
129+
}, {
130+
"name": "Lucio"
131+
}]
132132
};
133133

134134
db.jsonld.put(nested, function(err, obj) {
135135
// obj will be
136136
// {
137-
// "@context": {
138-
// "name": "http://xmlns.com/foaf/0.1/name"
139-
// , "knows": "http://xmlns.com/foaf/0.1/knows"
140-
// }
141-
// , "@id": "http://matteocollina.com"
142-
// , "name": "matteo"
143-
// , "knows": [{
144-
// "@id": "_:7053c150-5fea-11e3-a62e-adadc4e3df79"
145-
// , "name": "daniele"
146-
// }, {
147-
// "@id": "_:9d2bb59d-3baf-42ff-ba5d-9f8eab34ada5"
148-
// "name": "lucio"
149-
// }]
137+
// "@context": {
138+
// "name": "http://xmlns.com/foaf/0.1/name",
139+
// "knows": "http://xmlns.com/foaf/0.1/knows"
140+
// },
141+
// "@id": "http://matteocollina.com",
142+
// "name": "Matteo",
143+
// "knows": [{
144+
// "@id": "_:7053c150-5fea-11e3-a62e-adadc4e3df79",
145+
// "name": "Daniele"
146+
// }, {
147+
// "@id": "_:9d2bb59d-3baf-42ff-ba5d-9f8eab34ada5",
148+
// "name": "Lucio"
149+
// }]
150150
// }
151151
});
152152
```
@@ -168,35 +168,33 @@ that problem is already solved by __LevelGraph__ itself. This example
168168
search finds friends living near Paris:
169169
```javascript
170170
var manu = {
171-
"@context": {
172-
"@vocab": "http://xmlns.com/foaf/0.1/"
173-
, "homepage": { "@type": "@id" }
174-
, "knows": { "@type": "@id" }
175-
, "based_near": { "@type": "@id" }
176-
}
177-
, "@id": "http://manu.sporny.org#person"
178-
, "name": "Manu Sporny"
179-
, "homepage": "http://manu.sporny.org/"
180-
, "knows": [
181-
{
182-
"@id": "https://my-profile.eu/people/deiu/card#me",
183-
"name": "Andrei Vlad Sambra",
184-
"based_near": "http://dbpedia.org/resource/Paris"
185-
}, {
186-
"@id": "http://melvincarvalho.com/#me",
187-
"name": "Melvin Carvalho",
188-
"based_near": "http://dbpedia.org/resource/Honolulu"
189-
}, {
190-
"@id": "http://bblfish.net/people/henry/card#me",
191-
"name": "Henry Story",
192-
"based_near": "http://dbpedia.org/resource/Paris"
193-
}, {
194-
"@id": "http://presbrey.mit.edu/foaf#presbrey",
195-
"name": "Joe Presbrey",
196-
"based_near": "http://dbpedia.org/resource/Cambridge"
197-
}
198-
]
199-
}
171+
"@context": {
172+
"@vocab": "http://xmlns.com/foaf/0.1/",
173+
"homepage": { "@type": "@id" },
174+
"knows": { "@type": "@id" },
175+
"based_near": { "@type": "@id" }
176+
},
177+
"@id": "http://manu.sporny.org#person",
178+
"name": "Manu Sporny",
179+
"homepage": "http://manu.sporny.org/",
180+
"knows": [{
181+
"@id": "https://my-profile.eu/people/deiu/card#me",
182+
"name": "Andrei Vlad Sambra",
183+
"based_near": "http://dbpedia.org/resource/Paris"
184+
}, {
185+
"@id": "http://melvincarvalho.com/#me",
186+
"name": "Melvin Carvalho",
187+
"based_near": "http://dbpedia.org/resource/Honolulu"
188+
}, {
189+
"@id": "http://bblfish.net/people/henry/card#me",
190+
"name": "Henry Story",
191+
"based_near": "http://dbpedia.org/resource/Paris"
192+
}, {
193+
"@id": "http://presbrey.mit.edu/foaf#presbrey",
194+
"name": "Joe Presbrey",
195+
"based_near": "http://dbpedia.org/resource/Cambridge"
196+
}]
197+
};
200198

201199
var paris = 'http://dbpedia.org/resource/Paris';
202200

index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
2-
var jsonld = require('jsonld')
3-
, uuid = require('uuid')
4-
, RDFTYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
5-
, RDFLANGSTRING = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString'
6-
, XSDTYPE = 'http://www.w3.org/2001/XMLSchema#'
7-
, async = require('async')
8-
, N3Util = require('n3/lib/N3Util'); // with browserify require('n3').Util would bundle more then needed!
1+
var jsonld = require('jsonld'),
2+
uuid = require('uuid'),
3+
RDFTYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
4+
RDFLANGSTRING = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString',
5+
XSDTYPE = 'http://www.w3.org/2001/XMLSchema#',
6+
async = require('async'),
7+
N3Util = require('n3/lib/N3Util'); // with browserify require('n3').Util would bundle more then needed!
98

109
function levelgraphJSONLD(db, jsonldOpts) {
1110

test/datatype_spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// http://json-ld.org/spec/latest/json-ld-api/#data-round-tripping
2-
3-
var level = require('level-test')()
4-
, graph = require('levelgraph')
5-
, jsonld = require('../');
2+
var level = require('level-test')(),
3+
graph = require('levelgraph'),
4+
jsonld = require('../');
65

76
describe('jsonld.put data type', function() {
87

test/del_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var level = require('level-test')()
2-
, graph = require('levelgraph')
3-
, jsonld = require('../');
1+
var level = require('level-test')(),
2+
graph = require('levelgraph'),
3+
jsonld = require('../');
44

55
describe('jsonld.del', function() {
66

test/fixture/manu.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"@context": {
3-
"@vocab": "http://xmlns.com/foaf/0.1/"
4-
, "homepage": { "@type": "@id" }
5-
}
6-
, "@id": "http://manu.sporny.org#person"
7-
, "name": "Manu Sporny"
8-
, "homepage": "http://manu.sporny.org/"
2+
"@context": {
3+
"@vocab": "http://xmlns.com/foaf/0.1/",
4+
"homepage": { "@type": "@id" }
5+
},
6+
"@id": "http://manu.sporny.org#person",
7+
"name": "Manu Sporny",
8+
"homepage": "http://manu.sporny.org/"
99
}

test/fixture/nested.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"@context": {
3-
"name": "http://xmlns.com/foaf/0.1/name"
4-
, "knows": "http://xmlns.com/foaf/0.1/knows"
5-
}
6-
, "@id": "http://matteocollina.com"
7-
, "name": "matteo"
8-
, "knows": [{
9-
"name": "daniele"
10-
}, {
11-
"name": "lucio"
12-
}]
2+
"@context": {
3+
"name": "http://xmlns.com/foaf/0.1/name",
4+
"knows": "http://xmlns.com/foaf/0.1/knows"
5+
},
6+
"@id": "http://matteocollina.com",
7+
"name": "matteo",
8+
"knows": [{
9+
"name": "daniele"
10+
}, {
11+
"name": "lucio"
12+
}]
1313
}

0 commit comments

Comments
 (0)