{"_id":"structr-step","_rev":"35-aa29c24395a3d90cee6dca225114f010","name":"structr-step","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.0":{"author":{"name":"Craig Condon"},"name":"structr-step","version":"0.0.0","repository":{"type":"git","url":"git://github.com/crcn/structr-step.git"},"main":"./lib/index.js","dependencies":{},"devDependencies":{},"_npmUser":{"name":"architectd","email":"craig.j.condon@gmail.com"},"_id":"structr-step@0.0.0","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"aa69a275d0e7e2b4b9dfd3ed4ba79593da1c13b2","tarball":"https://registry.npmjs.org/structr-step/-/structr-step-0.0.0.tgz","integrity":"sha512-69EnS2FxTiGQCBywpFUwGDlLQu8pdgb4mTpfwBJjT3iwo3k7L4QhAVHX8OX7nc1A9S+i1rumYLsDangwgR1Blg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGoOIaLZNsbkfHLeBVobzYZrtlz8cM5JipE6DYcCFiOtAiBDXMcpwInhchReU91lQL+GkYNCXpR/e/amJwX0Z1K+Fw=="}]},"maintainers":[{"name":"architectd","email":"craig.j.condon@gmail.com"}],"directories":{}},"0.0.1":{"author":{"name":"Craig Condon"},"name":"structr-step","version":"0.0.1","repository":{"type":"git","url":"git://github.com/crcn/structr-step.git"},"main":"./lib/index.js","dependencies":{},"devDependencies":{},"_npmUser":{"name":"architectd","email":"craig.j.condon@gmail.com"},"_id":"structr-step@0.0.1","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"49c247c340319663381b841eb09ec7ece7b45f31","tarball":"https://registry.npmjs.org/structr-step/-/structr-step-0.0.1.tgz","integrity":"sha512-EzxZ18oj9iYo/aSSjInHoHg6aJ0lckReRlp2Qdz9h/RpfNMhjd9yyBje93lF9ZBjro5W3Oq50xcpqqF9x935gg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDNwoQnnuD+XAmbsA0CIPjpJJL68xwDTKzzUzwdVQVP+AIgMkh+353fHZNsWV1dA8sUpWYUhGjH4ZKnWIT5SEZXKK4="}]},"maintainers":[{"name":"architectd","email":"craig.j.condon@gmail.com"}],"directories":{}},"0.0.2":{"author":{"name":"Craig Condon"},"name":"structr-step","version":"0.0.2","repository":{"type":"git","url":"git://github.com/crcn/structr-step.git"},"main":"./lib/index.js","dependencies":{},"devDependencies":{},"_npmUser":{"name":"architectd","email":"craig.j.condon@gmail.com"},"_id":"structr-step@0.0.2","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.6.19","_defaultsLoaded":true,"dist":{"shasum":"5e595e646818aa567f3891c32875d42e362e4c7c","tarball":"https://registry.npmjs.org/structr-step/-/structr-step-0.0.2.tgz","integrity":"sha512-Js6KMsLNEbEyaVxbMJo0T5ORP2oDRkxW6tfeooWWOLZL/DpHu0q+45mvT7SHSbgRN6Kc/6obMOPAHNh5RaRO5A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCF8HwYO/CgOxY8UL/XVI5pBxourLpTu3rwq6Tl5aiZWwIhAMNYWTZ0dDARu3ch1cAFbufyojjXdPSiU73HdgoMKzaR"}]},"maintainers":[{"name":"architectd","email":"craig.j.condon@gmail.com"}],"directories":{}},"0.0.3":{"author":{"name":"Craig Condon"},"name":"structr-step","version":"0.0.3","repository":{"type":"git","url":"git://github.com/crcn/structr-step.git"},"main":"./lib/index.js","dependencies":{"tq":"0.0.x"},"devDependencies":{},"readme":"### Structr-step makes asyncronous function chainable\n\n\n### Projects using structr-step\n\n- [mongodblite](crcn/node-mongodblite)\n\t- see [this JS files](/crcn/node-mongodblite/blob/master/lib/collection.js)\n\n### Turn code from this\n\n```javascript\n\nvar structr = require(\"structr\"),\nfs = require(\"fs\");\n\nvar Config = structr({\n\n\t/**\n\t */\n\n\t\"__construct\": function(file) {\n\t\tthis.configFile = file;\n\n\t},\n\t\n\t\n\t/**\n\t * loads the config file\n\t */\n\n\t\"load\": function(next) {\n\n\t\tvar self = this;\n\n\t\t//make sure the confg file exists\n\t\tfs.stat(this.configFile, function(err, stat) {\n\n\t\t\t//if it doesn't exist, then set the config to an object, and\n\t\t\t//skip the rest\n\t\t\tif(err) {\n\t\t\t\tself._config = {};\n\t\t\t\treturn next();\n\t\t\t}\n\n\t\t\t//otherwise load it\n\t\t\tfs.readFile(self.configFile, function(err, content) {\n\n\t\t\t\t//and set the config\n\t\t\t\tnext(null, self._config = JSON.parse(content));\n\t\t\t})\n\n\t\t});\n\t},\n\n\t/**\n\t * returns the value in a config. This is blocked until\n\t * the config has been loaded\n\t */\n\n\t\"getValue\": function(key, next) {\n\t\treturn this._config[key];\n\t},\n\n\t/**\n\t * sets the vaue in the config\n\t */\n\n\t\"setValue\": function(key, value, next) {\n\t\tthis._config[key] = value;\n\t\tthis.save();\n\t\tnext();\n\t},\n\n\t/**\n\t * saves the config\n\t */\n\n\t\"step save\": function(next) {\n\t\tfs.writeFile(this.configFile, JSON.stringify(this._config), next);\n\t}\n});\n\n\n\nvar config = new Config(__dirname + \"/cache.json\");\nconfig.load(function(err) {\n\tif(err) return;\n\tvar value = config.getValue(\"name\");\n\t//do stuff...\n});\n```\n\n### Into This\n```javascript\n\nvar structr = require(\"structr\"),\nfs = require(\"fs\");\n\n//mix into structr\nstructr.mixin(require(\"../\"));\n\n\n\nvar Config = structr({\n\n\t/**\n\t */\n\n\t\"__construct\": function(file) {\n\t\tthis.configFile = file;\n\n\t\t//load the config before any methods can be\n\t\t//called\n\t\tthis.load();\n\t},\n\t\n\t\n\t/**\n\t * loads the config file\n\t */\n\n\t\"step load\": function(nextFn) {\n\t\tthis.step(\n\n\t\t\t//make sure the confg file exists\n\t\t\tfunction(next) {\n\t\t\t\tfs.stat(this.configFile, next);\n\t\t\t},\n\n\t\t\t//if it doesn't exist, then set the config to an object, and\n\t\t\t//skip the rest. Otherwise load it.\n\t\t\tfunction(err, stats, next) {\n\n\t\t\t\tif(err) {\n\t\t\t\t\tthis._config = {};\n\t\t\t\t\treturn nextFn(err);\n\t\t\t\t}\n\n\t\t\t\tfs.readFile(this.configFile, next);\n\t\t\t},\n\n\t\t\t//set the config, and finish\n\t\t\tfunction(err, content, next) {\n\t\t\t\tnext(null, this._config = JSON.parse(content));\n\t\t\t},\n\n\t\t\t//continue onto any other function called in this config\n\t\t\tnextFn\n\t\t);\n\t},\n\n\t/**\n\t * returns the value in a config. This is blocked until\n\t * the config has been loaded\n\t */\n\n\t\"step getValue\": function(key, next) {\n\t\tnext(null, this._config[key]);\n\t},\n\n\t/**\n\t * sets the vaue in the config\n\t */\n\n\t\"step setValue\": function(key, value, next) {\n\t\tthis._config[key] = value;\n\t\tthis.save();\n\t\tnext();\n\t},\n\n\t/**\n\t * saves the config\n\t */\n\n\t\"step save\": function(next) {\n\t\tfs.writeFile(this.configFile, JSON.stringify(this._config), next);\n\t}\n});\n\n\n\nvar config = new Config(__dirname + \"/cache.json\");\nconfig.getValue(\"name\", function(err, value) {\n\tif(!value) {\n\t\tconsole.log(\"config value does not exist, saving!\");\n\t\tconfig.setValue(\"name\", \"craig\");\n\t} else {\n\t\tconsole.log(\"hello %s!\", value);\n\t}\n});\n\n```","readmeFilename":"README.md","_id":"structr-step@0.0.3","description":"","dist":{"shasum":"b0daa52033bf8954176851f564d367fc6407ffb0","tarball":"https://registry.npmjs.org/structr-step/-/structr-step-0.0.3.tgz","integrity":"sha512-uZUpqWkTWaJ8sgYiYSCxkQ8D+hnbEjy4Gd+O+qr7dxSTy29J09EkCslZFdLliE0fieCJ+F+bVn00C1eXW5flng==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFA1aeQEzwRe/1/GU+al+G24fdaFNg9WZdp6W2gopDpgIhAKm57fDsugqHQ+dGPfq76fPVU2Z0e5vZfXeJHANmy71N"}]},"_npmVersion":"1.1.65","_npmUser":{"name":"architectd","email":"craig.j.condon@gmail.com"},"maintainers":[{"name":"architectd","email":"craig.j.condon@gmail.com"}]}},"readme":"### Structr-step makes asyncronous function chainable\n\n### Example\n```javascript\n\nvar structr = require(\"structr\"),\nfs = require(\"fs\");\n\nstructr.mixin(require(\"structr-step\"));\n\n\n\nvar TestClass = structr({\n\t\n\t\n\t/**\n\t */\n\n\t\"step asyncFn\": function(path, next) {\n\t\tfs.readFile(path, next);\n\t},\n\n\t/**\n\t */\n\n\t\"step asyncFn2\": function(path, next) {\n\t\tfs.readFile(path, next);\n\t}\n});\n\n\n\nvar test = new TestClass();\ntest.asyncFn(__filename, function(err, content) {\n\t\n});\ntest.asyncFn2(__filename, function(err, stat) {\n\t\n});\n```","maintainers":[{"name":"architectd","email":"craig.j.condon@gmail.com"}],"time":{"modified":"2022-06-27T01:20:49.032Z","created":"2012-06-06T00:37:13.663Z","0.0.0":"2012-06-06T00:37:14.953Z","0.0.1":"2012-06-06T01:04:56.361Z","0.0.2":"2012-06-09T16:03:18.807Z","0.0.3":"2012-11-23T02:57:21.853Z"},"author":{"name":"Craig Condon"},"repository":{"type":"git","url":"git://github.com/crcn/structr-step.git"}}