mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-21 13:27:15 +08:00
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
|
|
import oboe = require('oboe');
|
|
|
|
oboe('friends.json')
|
|
.node('name', function (name) {
|
|
console.log('You have a friend called', name);
|
|
}).on('node', '{name dob address}', function (personJson) {
|
|
console.log('Name is: %s', personJson.name);
|
|
}).on('node', 'person.address', function (address) {
|
|
return oboe.drop;
|
|
})
|
|
|
|
var friendCount = 0;
|
|
oboe('friends.json')
|
|
.path('friend', function (name) {
|
|
friendCount++;
|
|
});
|
|
|
|
oboe('resource.json')
|
|
.on('done', function (parsedJson) {
|
|
console.log('Request complete', parsedJson);
|
|
});
|
|
|
|
oboe('resource.json')
|
|
.on('start', function (status, headers) {
|
|
console.log('Resource cached for', headers.Age, 'secs');
|
|
});
|
|
|
|
oboe('/content')
|
|
.fail(function (errorReport) {
|
|
if (404 == errorReport.statusCode) {
|
|
console.error('no such content');
|
|
}
|
|
});
|
|
|
|
oboe('friends.json')
|
|
.node('friend', function (parsedJson) {
|
|
console.log('friend parsed', parsedJson);
|
|
});
|
|
|
|
oboe('friends.json')
|
|
.node({
|
|
'friend': function (parsedJson) {
|
|
console.log('friend parsed', parsedJson);
|
|
},
|
|
'!': function (parsedJson) {
|
|
console.log('root parsed', parsedJson);
|
|
}
|
|
});
|