[Pkg-javascript-commits] [node-deps-sort] 01/79: working example using browserify --deps
Bastien Roucariès
rouca at moszumanska.debian.org
Wed Sep 6 09:41:50 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-deps-sort.
commit e73e5edf0d9fcc427cdef33795a78b3248efb3ab
Author: James Halliday <mail at substack.net>
Date: Mon Jul 8 22:56:55 2013 -0700
working example using browserify --deps
---
example/sort.js | 6 ++++++
index.js | 20 ++++++++++++++++++++
readme.markdown | 5 +++++
3 files changed, 31 insertions(+)
diff --git a/example/sort.js b/example/sort.js
new file mode 100644
index 0000000..cfc0075
--- /dev/null
+++ b/example/sort.js
@@ -0,0 +1,6 @@
+var sort = require('../')();
+var JSONStream = require('JSONStream');
+var parse = JSONStream.parse([ true ]);
+var stringify = JSONStream.stringify();
+
+process.stdin.pipe(parse).pipe(sort).pipe(stringify).pipe(process.stdout);
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..346f663
--- /dev/null
+++ b/index.js
@@ -0,0 +1,20 @@
+var through = require('through');
+
+module.exports = function () {
+ var rows = [];
+ return through(write, end);
+
+ function write (row) { rows.push(row) }
+
+ function end () {
+ var tr = this;
+ rows.sort(cmp).forEach(function (row) {
+ tr.queue(row);
+ });
+ tr.queue(null);
+ }
+
+ function cmp (a, b) {
+ return a.id < b.id ? -1 : 1;
+ }
+};
diff --git a/readme.markdown b/readme.markdown
new file mode 100644
index 0000000..bf673c3
--- /dev/null
+++ b/readme.markdown
@@ -0,0 +1,5 @@
+# deps-sort
+
+sort [module-deps](https://npmjs.org/package/module-deps) rows for deterministic
+output
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-deps-sort.git
More information about the Pkg-javascript-commits
mailing list