@@ -47,29 +47,17 @@ embedded code.
4747
4848``` js
4949var couchdbBuilder = require (' couchdb-builder' );
50- var fs = require (' fs' );
51- var jsonStringify = require (' json-stable-stringify' );
5250
5351couchdbBuilder .build (sourcePath).then (
5452 function (result ) {
55- fs .writeFile (
56- targetPath,
57- jsonStringify (result) + " \n " ,
58- function (e ) {
59- console .error (' Error writing file: ' + e);
60- }
61- );
53+ // handle result
6254 },
63- function (e ) {
64- console . error ( ' Error building document: ' + e);
55+ function (error ) {
56+ // handle error
6557 }
6658);
6759```
6860
69- Note that [ json-stable-stringify] is used instead of [ JSON.stringify] to ensure
70- idempotent output, which helps reduce diff churn when the build product is
71- committed to a version control repository.
72-
7361[ promise ] : https://promisesaplus.com/
7462
7563## Differences to [ couchdb-compile]
@@ -150,6 +138,8 @@ meaningful way).
150138* CouchDB builder* utilizes [ json-stable-stringify] instead of [ JSON.stringify] ,
151139to ensure that its output is idempotent (always the same, given the same input).
152140
141+ [ json-stable-stringify ] : https://github.com/substack/json-stable-stringify
142+
153143### Unsupported features
154144
155145The following features of [ couchdb-compile] are not currently supported. Please
@@ -164,5 +154,4 @@ open an issue if further discussion is warranted:
164154<!-- References -->
165155
166156[ couchdb-compile ] : https://github.com/jo/couchdb-compile
167- [ json-stable-stringify ] : https://github.com/substack/json-stable-stringify
168157[ json.stringify ] : https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
0 commit comments