[Pkg-javascript-commits] [node-deps-sort] 18/79: expose implementation
Bastien Roucariès
rouca at moszumanska.debian.org
Wed Sep 6 09:41:53 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 e70feeaa8152753520c1a06e77e73821c041c283
Author: James Halliday <mail at substack.net>
Date: Mon Jul 21 05:04:31 2014 -0700
expose implementation
---
index.js | 19 +++++++++++++++++--
package.json | 1 +
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/index.js b/index.js
index 28e4028..a0a38c5 100644
--- a/index.js
+++ b/index.js
@@ -1,7 +1,15 @@
var through = require('through2');
+var isarray = require('isarray');
module.exports = function (opts) {
if (!opts) opts = {};
+ var expose = opts.expose || {};
+ if (isarray(expose)) {
+ expose = expose.reduce(function (acc, key) {
+ acc[key] = true;
+ return acc;
+ }, {});
+ }
var rows = [];
return through.obj(write, end);
@@ -14,9 +22,16 @@ module.exports = function (opts) {
if (opts.index) {
var index = {};
+ var offset = 0;
rows.forEach(function (row, ix) {
- row.index = ix + 1;
- index[row.id] = ix + 1;
+ if (expose[row.id]) {
+ row.index = row.id;
+ offset ++;
+ }
+ else {
+ row.index = ix + 1 - offset;
+ }
+ index[row.id] = row.index;
});
rows.forEach(function (row) {
row.indexDeps = {};
diff --git a/package.json b/package.json
index c5d55d5..7d0bfb3 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,7 @@
},
"dependencies": {
"JSONStream": "~0.8.4",
+ "isarray": "0.0.1",
"minimist": "~0.2.0",
"through2": "~0.5.1"
},
--
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