{"_id":"monocle-js","_rev":"49-eb08f557612e8a2e55b0ae46b2be78ab","name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","dist-tags":{"latest":"1.0.2"},"versions":{"0.1.4":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.1.4","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3"},"scripts":{"test":"grunt test"},"devDependencies":{"mocha":"~1.8.1","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.1.4","dist":{"shasum":"4d27f6f63d5cdf947ab557ad13bac05906fa6c7d","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.1.4.tgz","integrity":"sha512-/9jONRyN+EKr56sf5D62YOXrajk+KOAJaOaijLfOCQKVVkJuha9csuCcyQzty2YXq7E6RBareW6h99gQplLNOw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxF457d6ZonGMDnt3MTaP4YgJYxzvxrhCX1erIi580hwIgcNsIA5ouA1ByQSLQECwnuORQ0na6zfPpgp5x9B6NlVw="}]},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.1.5":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.1.5","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3"},"scripts":{"test":"grunt test"},"devDependencies":{"mocha":"~1.8.1","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.1.5","dist":{"shasum":"89fae1774a67f5e27e7fe822eceb0f85e1b35b55","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.1.5.tgz","integrity":"sha512-aEsttoaVDXHYaFfSUdhnuMjMBgOdQZngPBRetGcJi0cOZfURt/jBwpG3Qg3WS1dF9GtXqQyZgRvqBj7sPmP9/Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDypISPZneyZ6sUJqehxvAQn/It5rKPGsMfDFNU1SaPCwIhAMASk1MoqxKQRHSJ0U184HfvjujjwjHc/ottv1KIW89L"}]},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.1.6":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.1.6","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3"},"scripts":{"test":"grunt test"},"devDependencies":{"mocha":"~1.8.1","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.1.6","dist":{"shasum":"31816851be837c0e91d05cfb2b8ae56e13983402","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.1.6.tgz","integrity":"sha512-ggu8y2CwgsoI1dmgFzJovyjRW5tZyqD7tbXy+vftZiPydFuP/x4aq1ThQ8V1TiAzphl1hlaW3RaeD8DRPGpftg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFOvNBaMMLMMBAQfQT9zUSKHthBws8Ou37t+Xo0d5zweAiAOPWpxGGtimuqcexyll9G88jkLmvWRGWixbrU+jpvp4Q=="}]},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.1.7":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.1.7","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3"},"scripts":{"test":"grunt test"},"devDependencies":{"mocha":"~1.8.1","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.1.7","dist":{"shasum":"2d220e181ba52a8647cc6feecacb1689e57f2d92","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.1.7.tgz","integrity":"sha512-FCI5skm5SzTiofv7J3OHf2hZ8eCKrdCeaTXEaewEMQPyxQfWWwuZK/mAfs6Dlvw8EwWHo1EFRgjStTpK5LFX7w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC/+AgMWOrquO4sUjJjPf8/JTOR1KlKBO6jiOGJOMfmuAIgfS3+sLJdsESzw3zOg1KCOQp9bHdgz9qYLY9SqApKCn0="}]},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.1.8":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.1.8","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3"},"scripts":{"test":"grunt test"},"devDependencies":{"mocha":"~1.8.1","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.1.8","dist":{"shasum":"60b5077a13c7bd9a41bf0926cb8c152698cf1611","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.1.8.tgz","integrity":"sha512-eU5jKsNfZb3JPReGvedSQRev/kK8tpbMCF26VOK1b5JCLXIzWyd2orZGZ/gEfw4Pz/1wKvxLYJjCGRpYY7t/gg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCGebyo59AXrMyxFz7qRQGmIFGAnTzEeQIH1meNSx61AQIhAIvx8ONjPaciHlrspqRzwIRyhZ/J81rs5BWV3kKV4eG/"}]},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.1.9":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.1.9","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3"},"scripts":{"test":"grunt test"},"devDependencies":{"mocha":"~1.8.1","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.1.9","dist":{"shasum":"53c31dc22c6081b7facd7efeff91f4b8b2ee859d","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.1.9.tgz","integrity":"sha512-79TklcR7YJGE0KxRo8C0XRrkrVEXe+PxKH61l5MgMIj5h/NT7re6Zg4TTyllpAR7iRkMpW9pRl7kxUGMNEjiyQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE2IXx9Cutmzzk4nv9Yplkx7slz3fcTsp1z7Vo8H6f9fAiA2W5m/cFLAdSo66zQJpEUZ2fhHPW2rvozd36F2pY/qwg=="}]},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.2.0":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.2.0","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3"},"scripts":{"test":"grunt test"},"devDependencies":{"mocha":"~1.8.1","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.2.0","dist":{"shasum":"4ca0a71e4428122d6b4632ed69361c79e2f27edb","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.2.0.tgz","integrity":"sha512-la9ovMgjpQOnkApbJVr0XtA8aJ6aXmw+sqfEpdiMmEsJhLd9ZuSfNb9MhOjOdB6l869gwO3B8YlBLIaL7yTSUw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDi4St3L8HT+r8cPopkccutIGWGj8aNx6ZhZV+LaoDy5AiEAwSUNhxhQOir+5Fu2Q1iUP/tlVT/sj14bqV490GObP5Y="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.3.0":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.3.0","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3","harmony-reflect":"~0.0.11"},"scripts":{"test":"mocha --harmony -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.3.0","dist":{"shasum":"0131bab12d03fc63be66fcec20e54430a26d038e","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.3.0.tgz","integrity":"sha512-DgQzwuM0cB4idIqsI0gLAhk6NKzwPclV6YuBJBwUZb0jRNEwRx45Ump05K7ZB2uVBDjBUQeBj/2F5gzsuYR1SQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDCeunSuU9yaYUOxeJvkabTA3BfNtXROQ0qIehoIqGMRQIhAPd3K12L+q/KVTUrSA7sMpk6R/vMBRMGqDZ2ZupcI7p3"}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.4.0":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.4.0","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3","harmony-reflect":"~0.0.11"},"scripts":{"test":"mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.4.0","dist":{"shasum":"385926913b8cfb893ae54896dd84c1bd31935313","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.4.0.tgz","integrity":"sha512-AHKoUgn9aAmLyIqrqRHg+OXj6wxJrcRy16wRFKnuOv1f0R0NWpJoo0jzyHKw15OqInD3FAdWIacN6K35gljcFw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICr4sE1LmytJM6ZA/mPhrvlN9QcNRdGY1IqWUlu3yl0aAiEAzwTcLc1HFDixlUzpkhtEBO4xtmYxre4QehrqUbfjHKs="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.5.0":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.5.0","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3","harmony-reflect":"~0.0.11"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.5.0","dist":{"shasum":"d918ce523db0574c6a7268c0e711a3c5ad40bd6b","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.5.0.tgz","integrity":"sha512-sPKR8sa2oPKxDDT9z+YMTrnh6H4+GI9rAxdrOX0SfRPMGmMtNfj/PQnBSE13PzhFYAJkwXMWzjeRJGIMMsCq0w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDZHSHXrTXS8yTfPvfCVhjZi10RW3WErHQfbGmveay18QIhAMscBw8pDZzCl+hT6qj5pClyZYP/q/oy4SjhNL7LAvur"}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.5.1":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.5.1","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3","harmony-reflect":"~0.0.11"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.5.1","dist":{"shasum":"afbcd79f93dd3db4eee14a1c8f6fd2179e17f6f7","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.5.1.tgz","integrity":"sha512-DxtZv+WTJOrIXouJSJ1LDW+Rp/GkUStaaJ/GyWax1ARzTP6jzB2ttRZf9hccZ3IHvu5lyJMwvfCfiTrGAcj4IA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGohnPSba4k7FuZD6AKujeIdznGuYJ81IClLFEmFw7gVAiBnYj8Kifqbvj2916IKtuh6rzMZbAbeCyiDZh7xwyVibw=="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.5.2":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.5.2","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3","harmony-reflect":"~0.0.11"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"_id":"monocle-js@0.5.2","dist":{"shasum":"fc66efce944e38efc372bdb1a1512d89140a8cfc","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.5.2.tgz","integrity":"sha512-LS3MF/sQlHOUyxJDHorIF0/lG6hUUAIb9bMntUJ5pFMvgTSuMTy551DyxCWAvj8zojCwt8B0L5EX8OellrEMsA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCH6HuYH0aFHUBjSQah7wbYhNUhWTXkusKfgxbxRr5T7AIhAPViPMLakGp/9fcKW8tj15VCxJHNTcV7VX7+iuN/2Ouj"}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.6.0":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.6.0","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3","harmony-reflect":"~0.0.11"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"homepage":"https://github.com/jlipps/monocle-js","_id":"monocle-js@0.6.0","dist":{"shasum":"d11dffe7415b9a1cf773756dfb3d24faac55a714","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.6.0.tgz","integrity":"sha512-rvT31YIP540bIzSKd3AjdqkTYiFYsgaftDFSbDDU93dK/7M7+Hg51JvmpVQG0njsVWKNHAzJ5SRo6FBWgnH95w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDcDZ61hTziUHOkGiYMs292b9DdkKlHwtF/cefwhB+P2AiAIUKECVcIzN6sKG8CyjvmcMKJnhGPNiVSF0nFd2oPX2w=="}]},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.6.1":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.6.1","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.3","harmony-reflect":"~0.0.11"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"homepage":"https://github.com/jlipps/monocle-js","_id":"monocle-js@0.6.1","dist":{"shasum":"c2713accf1c771b79ef5bf249427c8cd39b613dc","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.6.1.tgz","integrity":"sha512-mAajtbyI+Kz6h4CsPVF4ye+24SpQTC1amHLwsHZiDPyk2hvOLNC1Hmxj1Limt7zLM8PkR1XKtkGBNqY86psbKw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEBZjgYrXg/Gwk6+0vm257BYjPN5aWa3r0MOI7BwNqbPAiB1BqzYlAMX1a5yR/k/dbjawiMKWaGvIzXO7ZWuOEilVA=="}]},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.6.2":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.6.2","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.4","harmony-reflect":"~0.0.13"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"homepage":"https://github.com/jlipps/monocle-js","_id":"monocle-js@0.6.2","dist":{"shasum":"8e59d45da8da9e7e1f7134a29e2be0de93904bd5","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.6.2.tgz","integrity":"sha512-haX34qTLZ/NZoeHdF3Up1yOrCCt3eVnVWhkQYiYiG4DgFIaIfXe+L6lythzBhNgHU38a5A61hTuc7hAPby+o2w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBdtWN4jPUMh55OHM2Dxw09WiI8I0hkmmRU6UZd5h6CKAiAZNRaUPp5o8NPUgNqYZiGG2hYRaT+4oaYWHJnIq7hSAQ=="}]},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.6.3":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.6.3","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.4","harmony-reflect":"~0.0.13"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"homepage":"https://github.com/jlipps/monocle-js","_id":"monocle-js@0.6.3","dist":{"shasum":"90eb5e4215f9829909e214dcbd5a82acd86381d0","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.6.3.tgz","integrity":"sha512-j+KIHQbJtfprnrYzXNECcMnDAmAz4TehCmzh1mKCjw0PmDvpJFsDOAiwiT1/wC0UeJXsskdC1pQdRos42siwVA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCL0SrPGZYXXmZIgzlo+NebDe0PbIxIXKczRh1Nvg0ifQIhAIK4HML6z6WypwNTI+sTgykfmLG7FcpR4qPru9O6q26U"}]},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.6.4":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.6.4","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.4","harmony-reflect":"~0.0.13"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"homepage":"https://github.com/jlipps/monocle-js","_id":"monocle-js@0.6.4","dist":{"shasum":"4326c4499520453e271a091ad45c19d373b3a8a8","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.6.4.tgz","integrity":"sha512-fmAUXXVd8QBzToyqZnOM4zHHlOjiP06ZlwUQvy3THUbWAlqYt1KiSQ73zL5XrXG60CInW0IZ81TXPeWSni6NIA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBdvITwZhckxsf2tiJVhm3kIWwMWZQfuAD3Xkp04I6FkAiB+xTw2gsbrriuDzD2MJUSAKyI4xqjH2a9a+/C06t4IAQ=="}]},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.6.5":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.6.5","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.4","harmony-reflect":"~0.0.13"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"homepage":"https://github.com/jlipps/monocle-js","_id":"monocle-js@0.6.5","dist":{"shasum":"612609aa859bdf561bbbaaeb995b5b4eb48b8d1f","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.6.5.tgz","integrity":"sha512-yVIyKCdFKfWwHG3sBSASWu/yRit1nUYkF6vilx7PtuA5jetqM39liMV0vhUa5NI5F/vJbuvgnlviAhKQKyKchA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCYwdXJfmwHPyesTdTOUbcZCzqSMJWNNKerjbe7NQSf2AIgf0jTxXKe72vln5DYGbQO9MpdyRIIHgNy0a5gjRHUS+o="}]},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"0.6.6":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"0.6.6","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.4","harmony-reflect":"~0.0.13"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.8.1","regenerator":"~0.3.3","grunt":"~0.4.0","grunt-cli":"~0.1.6","should":"~1.2.1","q":"~0.9.7","grunt-mocha-test":"~0.2.0","grunt-contrib-jshint":"~0.1.1"},"homepage":"https://github.com/jlipps/monocle-js","_id":"monocle-js@0.6.6","dist":{"shasum":"aeedb56d314d0022a8dfb0da2a54b9a82ad793ef","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-0.6.6.tgz","integrity":"sha512-Plb9dzO3QaeodtV0SMYG0lErDmeBblkbBjqiBgOeXwZXM3/8th8zDxq/gVtAD6/gqLYaBmmheR82MXdUjyjZ0w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDsSast6YgGG4bF/FGUnQiPDdcWy11vMJyT31nHItbVUQIhAIkNvcu6qDsN9AJUBUqcPwlEz7k0A46MLACJry7AdvQE"}]},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"1.0.0":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"1.0.0","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.4","harmony-reflect":"~0.0.13"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.21.4","regenerator":"~0.4.12","grunt":"~0.4.5","grunt-cli":"~0.1.13","should":"~4.0.4","q":"~1.0.1","grunt-mocha-test":"~0.11.0","grunt-contrib-jshint":"~0.10.0"},"homepage":"https://github.com/jlipps/monocle-js","_id":"monocle-js@1.0.0","dist":{"shasum":"db88ba53b6662d7d98a1a20935e3cce3f06c8de2","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-1.0.0.tgz","integrity":"sha512-4RZmjeTLAo9whuLtZXzXZS/OZldb8CJ6f11oW2HXuixZklQzuqZxQLif8pQQYMQqAeMEIXJL4UlLwq7YwozQjA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDp+eHs2zNG7CcQr4Cjm/quwtXP7DBGQnhkZusTybxT0wIgBuXpwxP5aYHKA1tLarspbXyxJ6r//WTvjPcT5pZa7BM="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]},"1.0.1":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"1.0.1","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.4","harmony-reflect":"~1.1.1"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/","testio":"./build.sh && mochaio --harmony-proxies -t 3000 -R spec test/ && mochaio -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.21.4","regenerator":"~0.4.12","grunt":"~0.4.5","grunt-cli":"~0.1.13","should":"~4.0.4","q":"~1.0.1","grunt-mocha-test":"~0.11.0","grunt-contrib-jshint":"~0.10.0"},"gitHead":"6e25848756c04ac955699d3d17768ee6ca110070","homepage":"https://github.com/jlipps/monocle-js","_id":"monocle-js@1.0.1","_shasum":"959b59c7e86999ab4ee9a8da27b8d700ea82daef","_from":".","_npmVersion":"2.1.18","_nodeVersion":"1.0.2","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}],"dist":{"shasum":"959b59c7e86999ab4ee9a8da27b8d700ea82daef","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-1.0.1.tgz","integrity":"sha512-pBWt8bLm4cvkeg/hH9qjZk41mIr/jg+0huAAfiGf4i0KkOlt0NRFRcdPLHAWSHRlg1dYaDcxZdc4hLS0n18aaw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEdD0sKj6cq2cy67I0eV4pKc1G9AAariWDLI3Lrjpex2AiEA9e3o1gj22Vl6gp9YibwO4ru5iJMIqfrelMsMztQMH8Q="}]}},"1.0.2":{"name":"monocle-js","description":"Blocking-like syntax for asynchronous Javascript libraries, using generators. Port of https://github.com/saucelabs/monocle","tags":["javascript","generators","yield","async","sync"],"version":"1.0.2","author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/jlipps/monocle-js.git"},"bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"engines":["node"],"main":"./lib/main.js","directories":{"lib":"./lib"},"dependencies":{"underscore":"~1.4.4","harmony-reflect":"~1.1.1"},"scripts":{"test":"./build.sh && mocha --harmony -t 3000 -R spec test/ && mocha -t 3000 -R spec test/","testio":"./build.sh && mochaio --harmony-proxies -t 3000 -R spec test/ && mochaio -t 3000 -R spec test/"},"devDependencies":{"mocha":"~1.21.4","regenerator":"~0.4.12","grunt":"~0.4.5","grunt-cli":"~0.1.13","should":"~4.0.4","q":"~1.0.1","grunt-mocha-test":"~0.11.0","grunt-contrib-jshint":"~0.10.0"},"gitHead":"2bb1fe1892df2e5e4e43db96387ef93280c6d280","homepage":"https://github.com/jlipps/monocle-js#readme","_id":"monocle-js@1.0.2","_shasum":"2b5e43861833de4a3cf65d92449ede0795d4943e","_from":".","_npmVersion":"2.10.0","_nodeVersion":"0.12.2","_npmUser":{"name":"jlipps","email":"jlipps@gmail.com"},"dist":{"shasum":"2b5e43861833de4a3cf65d92449ede0795d4943e","tarball":"https://registry.npmjs.org/monocle-js/-/monocle-js-1.0.2.tgz","integrity":"sha512-7yS1mEXf+2ZQ/ugVFNmIKOAIX84OmR8shUkwNRRrw+pEuxXIpTOjxgtWHdS0jOgVn09NEekbTPuWbv6vJudRYw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCtYYp5hT85d2NwJnhf560xfVyuWFI/OI4FzZbTnRqRWgIgWipSKt6Uo/QRceJdhVq5bKhSa86MfLqk6+sgu5gae60="}]},"maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}]}},"readme":"monocle-js\n==========\n\n[![Build Status](https://travis-ci.org/jlipps/monocle-js.png)](https://travis-ci.org/jlipps/monocle-js)\n\nmonocle-js is a Node library for using a blocking-like syntax when writing\nasynchronous code. In other words, it's one way to avoid the 'callback hell' so\nmany Javascript developers love to hate. It's a port of the\n[Monocle](https://github.com/saucelabs/monocle) library for event-driven\nPython, made possible by ES6's new generators and the `yield` keyword. (For\npresent-day javascript, we use Facebook's\n[Regenerator](https://github.com/facebook/regenerator) to bundle in a generator\nruntime.)\n\nInstall with: `npm install monocle-js`\n\nThe problem\n-----------\nA lot of Node libraries and Javascript libraries in general follow the callback\npattern. This isn't bad in and of itself but it encourages developers to write\ncode that drifts rightward and becomes difficult to read. Let's say we want to\nread some data from the web and write it to a file:\n\n```js\nvar request = require('request')\n  , fs = require('fs');\n\nvar myLibraryFunction = function(jsonUrl, cb) {\n    request(jsonUrl, function(err, resp, body) {\n        if (err) {\n            return cb(err);\n        }\n        fs.writeFile('/path/to/my/file.json', body, function(err) {\n            if (err) {\n                return cb(err);\n            }\n            cb(null, resp, body);\n        });\n    });\n};\n\nmyLibraryFunction('http://somesite.com/json/data', function(err, resp, body) {\n    if (err) {\n        console.log(\"Downloading and writing file failed!\");\n    } else {\n        console.log(\"Downloading and writing file was successful!\");\n        console.log(resp);\n        console.log(body);\n    }\n});\n```\n\nThis is obviously a contrived example, but when building up a library of\nproject-specific functionality, you often find yourself doing this in Node.\n\nHere's what the same code could look like using Monocle:\n\n```js\nvar request = require('monocle-request')\n  , fs = require('monocle-fs')\n  , monocle = require('monocle-js')\n  , o_O = monocle.o_O;\n\nvar myLibraryFunction = o_O(function*(jsonUrl) {\n    var data = yield request(jsonUrl);\n    yield fs.writeFile('/path/to/my/file.json', data[1]);\n    return data;\n});\n\nvar main = o_O(function*() {\n    try {\n        var data = yield myLibraryFunction('http://somesite.com/json/data');\n        console.log(\"Downloading and writing file was successful!\");\n        console.log(data[0]);\n        console.log(data[1]);\n    } catch (err) {\n        console.log(\"Downloading and writing file failed!\");\n    }\n});\n\nmonocle.launch(main);\n```\n\nAs you can see, the points at which you would have created an anonymous\nfunction to handle the asynchronous callback, you now simply use the `yield`\nkeyword to block until the callback's result is ready. And the library\nfunctions you create are 'monoclized' by wrapping them (or 'decorating them')\nwith the `o_O` method.\n\nAlso, notice that you don't need to do any explicit error handling if you don't\nwant to. Errors will be thrown like synchronous JS code, and can be caught and\nhandled appropriately.\n\nIt's important to understand that Monocle methods cannot simply be called like\nnormal functions--to actually begin executing them, pass them as arguments to\n`monocle.launch`. There's also a convenience method for launching a monoclized\ngenerator directly: `monocle.run`. With `monocle.run`, you can avoid having to\ndefine a `main` function in the example above, like so:\n\n```js\nmonocle.run(function*() {\n    try {\n        var data = yield myLibraryFunction('http://somesite.com/json/data');\n        console.log(\"Downloading and writing file was successful!\");\n        console.log(data[0]);\n        console.log(data[1]);\n    } catch (err) {\n        console.log(\"Downloading and writing file failed!\");\n    }\n});\n```\n\nUsing callback-based methods\n--------------------\nOf course, in the previous examples, I've required `monocle-fs` and\n`monocle-request`, libraries which didn't exist until I created them. What if\nyou want to make use of arbitrary callback-based library methods? You can do\nthat with Monocle as well. Here's the previous example without the assumption\nthat `request` and `fs` have already been 'monoclized'.\n\n```js\nvar request = require('request')\n  , fs = require('fs')\n  , monocle = require('monocle-js')\n  , o_O = monocle.o_O\n  , o_C = monocle.callback;\n\nvar myLibraryFunction = o_O(function*(jsonUrl) {\n    var cb = o_C();\n    request(jsonUrl, cb);\n    var data = yield cb;\n    cb = o_C();\n    fs.writeFile('/path/to/my/file.json', data[1], cb);\n    yield cb;\n    return data;\n});\n\nmonocle.run(function*() {\n    try {\n        var data = yield myLibraryFunction('http://somesite.com/json/data');\n        console.log(\"Downloading and writing file was successful!\");\n        console.log(data[0]);\n        console.log(data[1]);\n    } catch (err) {\n        console.log(\"Downloading and writing file failed!\");\n    }\n});\n```\n\nThe way it works is that first we create a special callback to be used in the\nlibrary method. We do this by calling `monocle.callback()` or `monocle.o_C()`\nfor short. This creates a callback we pass to the asynchronous method. Then, on\nthe next line, we simply `yield` to the callback, which blocks execution until\nthe asynchronous method is done and we have a result. Using this strategy, it's\neasy to incorporate library methods which have not yet been monoclized.\n\nFunctions which have been monoclized are called 'o-routines', and, from within\nother o-routines, can simply be yielded to without creating a callback. This is\nwhy we simply `yield myLibraryFunction(jsonUrl)` in the example above.\n\nYield! As in traffic\n-------------------\nReading through the examples above, you may have noticed that we're using\n`yield` in an interesting way. In a typical Javascript generator, `yield` is\nused to send data from the generator to the caller of `next()`. You could think\nof this as \"yield as in crops\". In Monocle, `yield` is a sign that we should\nwait for the result of an asynchronous function. It's much better to think of\nthis as \"yield as in traffic\" (hat tip to [the other\nmonocle](https://github.com/saucelabs/monocle) for this explanation). Take\na look at this code from the example above:\n\n```js\nvar data = yield request(jsonUrl);\nyield fs.writeFile('/path/to/my/file.json', data[1]);\nreturn data;\n```\n\nIn the first line, we're using yield as a way to retrieve the result of an\nasynchronous o-routine called `request`. This is what we mean by \"yield as in\ntraffic\". In the second line, we're doing the same kind of thing, only we're\nnot assigning the result to anything. These lines essentially say, \"wait until\nthe asynchronous process is finished, and give me the result\".\n\nThe third line, using the `return` statement, is how we actually send a result\nback to whoever is calling this particular function. So, the rule of thumb is\nthis:\n\n* `yield` when you want to wait for an o-routine or a callback and get its result\n* `return` when you want to send back the result of an o-routine\n\nBecause of these semantics, Monocle checks to make sure the only type of thing\nyou're yielding is an o-routine or callback. You can also yield iterators (what\nyou get when you call generators) directly--they're converted into o-routines\non the fly. See the examples below:\n\n```js\nvar myFunc = o_O(function*() {\n    // this is good, monocle.utils.sleep is an o-routine\n    yield monocle.utils.sleep(1000);\n\n    // this is good, cb is a monocle callback\n    var cb = o_C();\n    setTimeout(cb, 1000);\n    yield cb;\n\n    // this is good; pauseBriefly() returns an iterator\n    var pauseBriefly = function*() {\n        yield monocle.utils.sleep(500);\n    };\n    yield pauseBriefly();\n\n\n    // this is bad, we should be returning instead; Math.pow is not an o-routine.\n    // Monocle will throw an error\n    yield Math.pow(2, 3);\n\n    // this is bad, we should be returning instead.\n    // Monocle will throw an error\n    yield 5;\n});\n```\n\nPorting async libraries\n-----------------------\nWe saw above how to make use of pre-existing async functions in o-routines,\nusing monocle callbacks. Monocle also provides a helper function which can be\nused to turn a node-style async function into an o-routine automatically:\n`monocle.monoclize()` or `monocle.o_M()` for short. By \"node-style async\nfunction\", I mean one which takes a series of parameters, the last of which is\na callback. Monocle assumes this callback takes at least two parameters: the\nfirst of which is an error object (or `null`) used to determine whether the\noriginal function completed successfully.\n\nLet's look at an example. `fs.readFile()` is a node-style async function. We\ncan convert it into an o-routine like this:\n\n```js\nvar monocle = require('monocle-js')\n  , o_O = monocle.o_O\n  , o_C = monocle.o_C\n  , fs = require('fs');\n\nvar monoclizedRead = o_O(function*(filePath) {\n    var cb = o_C();\n    fs.readFile(filePath, cb);\n    return (yield cb);\n});\n```\n\nWe can eliminate this boilerplate by using `monoclize()`:\n\n```js\nvar monocle = require('monocle-js')\n  , o_O = monocle.o_O\n  , o_M = monocle.o_M\n  , fs = require('fs');\n\nvar monoclizedRead = o_M(fs.readFile);\n```\n\nFor an example of how this is used to port entire Node libraries, check out\n[monocle-fs](https://github.com/jlipps/monocle-fs).\n\nUsing Promises\n--------------\n[Promises](http://promises-aplus.github.io/promises-spec/) are another way of\nhandling asynchronous control flow in Javascript. There are many popular\npromises implementations, including [Q](https://github.com/kriskowal/q) and\n[Bluebird](https://github.com/petkaantonov/bluebird). Library methods which\nreturn promises can be used without modification in Monocle. For example,\nhere's a bit of functional testing code using\n[Wd.js](https://github.com/admc/wd)'s promise library:\n\n```js\nvar wd = require('wd')\n  , browser = wd.promiseRemote()\n  , should = require('chai').should();\n\nbrowser\n    .init({ browserName: 'chrome' })\n    .then(function () {\n        return browser.get(\"http://admc.io/wd/test-pages/guinea-pig.html\");\n    })\n    .then(function () { return browser.title();})\n    .then(function (title) {\n        title.should.equal('WD Tests');\n    })\n    .fin(function () { browser.quit(); })\n    .done();\n```\n\nThis code opens up a Chrome browser, navigates to a URL, and asserts that the\ntitle is as expected. We could rewrite this using Monocle as follows:\n\n```js\nvar wd = require('wd')\n  , run = require('monocle-js').run\n  , browser = wd.promiseRemote()\n  , should = require('chai').should();\n\nrun(function*() {\n    yield browser.init({ browserName: 'chrome' });\n    yield browser.get(\"http://admc.io/wd/test-pages/guinea-pig.html\");\n    var title = yield browser.title();\n    title.should.equal('WD Tests');\n    yield browser.quit();\n});\n```\n\nMany libraries exist which make use of promises, and Monocle makes it easy to\ntake advantage of them in a more streamlined and elegant fashion.\n\nRunning o-routines in parallel\n------------------------------\nHaving a blocking syntax is great, but we can also take advantage of the fact\nthat we're not really blocking! If we have a bunch of o-routines we want to run\nin parallel, it's really easy:\n\n```js\nvar monocle = require('monocle-js')\n  , run = monocle.run\n  , ll = monocle.parallel\n  , sleep = monocle.utils.sleep\n  , o_O = monocle.o_O;\n\nvar method1 = o_O(function*() {\n    yield sleep(500);\n    console.log(\"Hello\");\n});\n\nvar method2 = o_O(function*(sleepTime, text) {\n    yield sleep(sleepTime);\n    console.log(text);\n});\n\nrun(function*() {\n    yield ll([\n        method1,\n        [method2, 250, \"World!\"]\n    ]);\n});\n```\n\nIn the above example, we have two methods. The first prints out \"Hello\" after\nwaiting half a second. The second prints out arbitrary text after waiting an\narbitrary amount of time. Using the `parallel` (or `ll`) method, we can run\nboth of these simultaneously. Because of this parallelism, the result will\nactually look like this:\n\n```\nWorld!\nHello\n```\n\nAnd, everything will be printed out in half a second, not three quarters of\na second. You can see in the call how to pass parameters to parallel methods:\nsimply wrap the method and it's parameters in an array.\n\nChaining o-routines\n-------------------\nIt's common practice in Javascript to run asynchronous methods on the results\nof other asynchronous methods. This can be visualized like a chain:\n\n```\nobj1.foo() --> obj2\n  obj2.bar() --> obj3\n    obj3.baz() --> result\n```\n\nOr in code:\n\n```js\nvar result = obj1.foo().bar().baz()\n```\n\nOf course, if `foo`, `bar`, and `baz` are asynchronous, this would really look\nlike:\n\n```js\nobj1.foo(function(err, obj2) {\n    obj2.bar(function(err, obj3) {\n        obj3.baz(function(err, result) {\n            // do something with result\n        });\n    });\n});\n```\n\nOut of the box, Monocle makes this easier, but we still have to yield each call\nseparately, since they're each going to be o-routines:\n\n```js\nvar result = yield (yield (yield obj1.foo()).bar()).baz();\n```\n\nThis can admittedly get a bit ugly. However, if we define `foo` as a chainable\no-routine, then we can get around this limitation:\n\n```js\nClazz.prototype.foo = monocle.chainable(function*() {\n    // do some stuff\n    return objWithBarMethod;\n});\n\nvar obj1 = new Clazz();\nvar result = yield obj1.foo().bar();\n```\n\nAll that matters is that the first function be defined as `chainable`. There's\nalso a nice alias for `monocle.chainable`: `o_P`;\n\nGetting errors out of Monocle\n-----------------------------\n\nDespite the coolness of Monocle, Javascript is still, at the end of the day,\ncallback-based. We haven't descended into fibers! What this means is that this\nwill throw an unhandled error:\n\n```js\ntry {\n    monocle.run(function*() {\n        yield myFunc();\n        yield sleep(50);\n        throw new Error(\"whoops\");\n    });\n} catch (e) {\n    // we'll never get here, instead the error will crash the script\n}\n```\n\nRemember: `monocle.run` and `monocle.launch` are not synchronous! So if you\nwant to do something with an error inside `run`, catch it with `.fin` or\n`.nodeify`:\n\n```js\nmonocle.run(function*() {\n    yield myFunc();\n    yield sleep(50);\n    throw new Error(\"whoops\");\n}).fin(function(err) {\n    console.log(err);  // whoops\n});\n```\n\nIf you don't, we'll throw the error in the general context, which might cause strange undefined behavior, as mentioned above.\n\nEnabling Javascript generators\n----------------\nBy default, generators and proxies (used for chaining) are not enabled in the\nV8 Javascript engine which powers Node. In Node 11, generators are available\nbut not enabled unless you pass the `--harmony` flag. If you're using\nmonocle-js, make sure to do that!\n\nMaking libraries compatible with vanilla Node-style async methods\n----------------\nLet's say you want to use monocle-js to write your code, but you also want to\nexport library methods for people who don't have monocle-js to use. Basically,\nwhat we need is a way to take an o-routine (or generator) and turn it into\na regular Node-style callback-based method. This is super easy with\n`monocle.nodeify` (or `monocle.no` for short--get it? For when you want to say\n\"no\" to monocle!). Take this simple o-routine, for example:\n\n```js\nvar sleepTwice = o_O(function*(x, y) {\n    yield sleep(x);\n    yield sleep(y);\n});\n```\n\nIf we wanted to export this for others to use, we can simply add this to our\nexports:\n\n```js\nmodule.exports.sleepTwice = monocle.no(sleepTwice);\n```\n\nNow someone can call it as expected in their own callback-based code:\n\n```js\nvar sleepTwice = require('yourlibrary').sleepTwice;\n\nsleepTwice(50, 100, function(err) {\n    // do stuff\n});\n```\n\nRunning tests\n-------------\nMonocle's tests are written in Mocha. Simply run this command:\n\n```bash\nmocha --harmony test/\n```\n\nCase study\n----------\nI ported monocle-js for use in [Yiewd](https://github.com/jlipps/yiewd),\na generator-based WebDriver client library. All WebDriver calls are HTTP-based,\nand given Node's callback-based HTTP library, WebDriver test code descends\nquickly into callback hell. Yiewd is a good example of how an existing\ncallback-based library can be wrapped easily and its methods turned into\no-routines for use with Monocle.\n\nOnce you've 'monoclized' an existing library, or created a new library using\no-routines, it's easy to write asynchronous Javascript code in an easy-to-read\nsynchronous fashion.\n\nMonocle-enabled libraries\n-------------------------\nA list of Node libraries that export o-routines:\n\n* [Yiewd](https://github.com/jlipps/yiewd)\n* [monocle-fs](https://github.com/jlipps/monocle-fs)\n* [monocle-request](https://github.com/jlipps/monocle-request)\n\nFashion\n-------\nOne of the awesome things about the [original\nmonocle](https://github.com/saucelabs/monocle) was that the decorator (`@_o`) looked like a monocle-bearing individual! We can't start names with `@` in Javascript, hence the use of `o_O` in the port. But we have options. These are all exported for your particular taste:\n\n```\nmonocle.o0\nmonocle.o_0\nmonocle.oO\nmonocle.o_P  // for chaining\n```\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/jlipps/monocle-js/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n","maintainers":[{"name":"jlipps","email":"jlipps@gmail.com"}],"time":{"modified":"2022-06-20T08:40:20.489Z","created":"2013-09-04T20:21:04.307Z","0.1.4":"2013-09-04T20:21:05.907Z","0.1.5":"2013-09-30T11:59:15.479Z","0.1.6":"2013-09-30T12:12:11.149Z","0.1.7":"2013-09-30T13:24:44.600Z","0.1.8":"2013-10-03T11:49:47.669Z","0.1.9":"2013-10-09T19:44:36.933Z","0.2.0":"2013-10-24T16:33:58.172Z","0.3.0":"2013-11-22T19:35:35.410Z","0.4.0":"2013-12-24T19:37:38.213Z","0.5.0":"2014-01-03T22:33:35.270Z","0.5.1":"2014-01-24T03:22:44.835Z","0.5.2":"2014-01-24T03:27:37.593Z","0.6.0":"2014-03-15T00:06:39.874Z","0.6.1":"2014-03-24T21:32:58.257Z","0.6.2":"2014-04-22T00:32:12.368Z","0.6.3":"2014-04-22T00:46:57.251Z","0.6.4":"2014-04-22T23:32:24.486Z","0.6.5":"2014-05-09T21:16:08.466Z","0.6.6":"2014-06-12T18:44:01.537Z","1.0.0":"2014-08-15T00:10:31.741Z","1.0.1":"2015-01-14T19:03:35.599Z","1.0.2":"2015-09-08T22:06:19.605Z"},"author":{"name":"jlipps@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/jlipps/monocle-js.git"},"readmeFilename":"README.md","homepage":"https://github.com/jlipps/monocle-js#readme","bugs":{"url":"https://github.com/jlipps/monocle-js/issues"},"users":{"urucas":true}}