Skip to content
Browse files

buffer .into() now works

  • Loading branch information...
1 parent 5d3c87e commit e80d3c2a008b2e88e534a713785cfdfa14fd7591 @substack committed
Showing with 20 additions and 2 deletions.
  1. +18 −0 index.js
  2. +2 −2 lib/vars.js
View
18 index.js
@@ -77,6 +77,13 @@ exports.stream = function (em, eventName) {
saw.nest(cb, vars.store);
};
+ self.into = function (key, cb) {
+ if (!vars.get(key)) {
+ vars.set(key, {});
+ }
+ saw.nest(cb, vars.get(key));
+ };
+
self.flush = function () {
vars.store = {};
next();
@@ -182,6 +189,17 @@ exports.parse = function parse (buffer) {
return self;
};
+ self.into = function (key, cb) {
+ if (!vars.get(key)) {
+ vars.set(key, {});
+ }
+ var parent = vars;
+ vars = Vars(parent.get(key));
+ cb.call(self, vars.store);
+ vars = parent;
+ return self;
+ };
+
self.loop = function (cb) {
var end = false;
var ender = function () { end = true };
View
4 lib/vars.js
@@ -1,4 +1,4 @@
-module.exports = function () {
+module.exports = function (store) {
function getset (name, value) {
var node = vars.store;
var keys = name.split('.');
@@ -22,7 +22,7 @@ module.exports = function () {
set : function (name, value) {
return getset(name, value);
},
- store : {},
+ store : store || {},
};
return vars;
};

0 comments on commit e80d3c2

Please sign in to comment.
Something went wrong with that request. Please try again.