{"_id":"swerve","_rev":"35-8a93c0045f9dcb89bd2a90c0b138345f","name":"swerve","description":"Feature flipper.","dist-tags":{"latest":"0.5.0"},"versions":{"0.0.1":{"name":"swerve","version":"0.0.1","description":"Feature flipper.","author":{"name":"Jico Baligod","email":"jico@baligod.com"},"homepage":["https://github.com/jico/swerve"],"repository":{"type":"git","url":"https://github.com/jico/swerve"},"licenses":[{"type":"MIT","url":"http://github.com/jico/swerve/raw/master/LICENSE"}],"devDependencies":{"coffee-script":"1.6.2","expect.js":"0.2.0","jsdom":"0.5.6","mocha":"1.8.2"},"main":"./index.js","scripts":{"build":"./node_modules/.bin/coffee -o . src","test":"./node_modules/.bin/mocha --reporter spec --timeout 4000 --ignore-leaks","watch":"./node_modules/.bin/coffee -wo . src"},"readme":"# Swerve\n\nFeature flipping for Node.js\n\n## Installation\n\nAdd `swerve` to your `package.json` file and `npm install`. Or:\n\n```bash\nnpm install swerve --save\n```\n\nIf you're using Hem, also make sure you add it to your `slug.json` file as a\ndependency.\n\n## Configuration\n\nRequire Swerve and passing a hash of feature settings for each environment.\nTypically, you'll want Swerve globally available throughout your app.\n\n```coffeescript\nSwerve = require('swerve')\nSwerve.configure\n  development:\n    notifications: true\n  production:\n    notifications: false\n```\n\nSet the current environment.\n\n```coffeescript\nSwerve.setEnv('development')\n```\n\n## Feature flipping\n\nNow you can toggle different blocks of code throughout your app based on enabled features.\n\n```coffeescript\nif Swerve.feature('notifications')\n  # Code for new notifications feature\nelse\n  # Current code without new notifications\n```\n\n`Swerve.feature()` returns the value from the configuration (or URL param, see\nsection below). While you usually set the value to either `true` or `false`, you\nhave the flexibility of setting it to whatever you may need (i.e. a hash of\nsettings for that feature for each environment).\n\n## Toggling with URL parameters\n\nFeatures can also be enabled or disabled by passing in the feature name as a\nquery string in the URL. These params take precedence over those set in the\nconfiguration.\n\nSo if we visit `http://www.example.com?notifications=true` in our production\nenvironment, then that feature will be considered enabled, regardless of the\nsetting passed in through the original configuration.\n\n## License\n\nCopyright 2013 Jico Baligod.\n\nLicensed under the [MIT License](http://github.com/jico/swerve/raw/master/LICENSE).\n","readmeFilename":"README.md","_id":"swerve@0.0.1","dist":{"shasum":"3a91423a887c66064b2ae5c4529f86a4cb1937ac","tarball":"https://registry.npmjs.org/swerve/-/swerve-0.0.1.tgz","integrity":"sha512-xuUCM/WjSA9CJZQaRF2LnsB5rV2AEUnM5BUCb+JLKjj80rL6mWw3sQy4pba4oUBTcQOyJexuf8gm9sqxsp280g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF+yKTCzioUZMqij+5VWxHVuW3lIZdtoE4A2QnNkXQCMAiEAslOD5Hxbg+R8SNJDZ+yDwW4FxSHSPDh4l6u5WlvliAU="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"jico","email":"jico@baligod.com"},"maintainers":[{"name":"jico","email":"jico@baligod.com"}],"directories":{}},"0.0.2":{"name":"swerve","version":"0.0.2","description":"Feature flipper.","author":{"name":"Jico Baligod","email":"jico@baligod.com"},"homepage":["https://github.com/jico/swerve"],"repository":{"type":"git","url":"https://github.com/jico/swerve"},"licenses":[{"type":"MIT","url":"http://github.com/jico/swerve/raw/master/LICENSE"}],"devDependencies":{"coffee-script":"1.6.2","expect.js":"0.2.0","jsdom":"0.5.6","mocha":"1.8.2"},"main":"./index.js","scripts":{"build":"./node_modules/.bin/coffee -co . src","test":"./node_modules/.bin/mocha --reporter spec --timeout 4000 --ignore-leaks","watch":"./node_modules/.bin/coffee -wo . src"},"readme":"[![Build Status](https://travis-ci.org/jico/swerve.png)](https://travis-ci.org/jico/swerve)\n\n# Swerve\n\nFeature flipping for Node.js\n\n## Installation\n\nAdd `swerve` to your `package.json` file and `npm install`. Or:\n\n```bash\nnpm install swerve --save\n```\n\nIf you're using Hem, also make sure you add it to your `slug.json` file as a\ndependency.\n\n## Configuration\n\nRequire Swerve and passing a hash of feature settings for each environment.\nTypically, you'll want Swerve globally available throughout your app.\n\n```coffeescript\nSwerve = require('swerve')\nSwerve.configure\n  development:\n    notifications: true\n  production:\n    notifications: false\n```\n\nSet the current environment.\n\n```coffeescript\nSwerve.setEnv('development')\n```\n\n## Feature flipping\n\nNow you can toggle different blocks of code throughout your app based on enabled features.\n\n```coffeescript\nif Swerve.feature('notifications')\n  # Code for new notifications feature\nelse\n  # Current code without new notifications\n```\n\n`Swerve.feature()` returns the value from the configuration (or URL param, see\nsection below). While you usually set the value to either `true` or `false`, you\nhave the flexibility of setting it to whatever you may need (i.e. a hash of\nsettings for that feature for each environment).\n\n## Toggling with URL parameters\n\nFeatures can also be enabled or disabled by passing in the feature name as a\nquery string in the URL. These params take precedence over those set in the\nconfiguration.\n\nSo if we visit `http://www.example.com?notifications=true` in our production\nenvironment, then that feature will be considered enabled, regardless of the\nsetting passed in through the original configuration.\n\n## License\n\nCopyright 2013 Jico Baligod.\n\nLicensed under the [MIT License](http://github.com/jico/swerve/raw/master/LICENSE).\n","readmeFilename":"README.md","_id":"swerve@0.0.2","dist":{"shasum":"aec2056f19ae2dfebffd90000aed6bbfe7a91e5f","tarball":"https://registry.npmjs.org/swerve/-/swerve-0.0.2.tgz","integrity":"sha512-M5MXx/04SN4Wp+aefXa1Jd60SwgN1zOYzB83wn2p0HR/JiSjRvrXZDhWZoMhYxEyaCPVwRhTaQbc8a6DePF11A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCntu0GhUJpt8ZZRO5LJc+EF+HvHUXiCEGRabmOizbXigIhAO6ChzvTQa7yShxWahsyGMO70yCW2RboLvGmge+BH6W1"}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"jico","email":"jico@baligod.com"},"maintainers":[{"name":"jico","email":"jico@baligod.com"}],"directories":{}},"0.0.3":{"name":"swerve","version":"0.0.3","description":"Feature flipper.","author":{"name":"Jico Baligod","email":"jico@baligod.com"},"homepage":["https://github.com/jico/swerve"],"repository":{"type":"git","url":"https://github.com/jico/swerve"},"licenses":[{"type":"MIT","url":"http://github.com/jico/swerve/raw/master/LICENSE"}],"devDependencies":{"coffee-script":"1.6.2","expect.js":"0.2.0","jsdom":"0.5.6","mocha":"1.8.2"},"main":"./index.js","scripts":{"build":"./node_modules/.bin/coffee -co . src","test":"./node_modules/.bin/mocha --reporter spec --timeout 4000 --ignore-leaks","watch":"./node_modules/.bin/coffee -wo . src"},"readme":"[![Build Status](https://travis-ci.org/jico/swerve.png)](https://travis-ci.org/jico/swerve)\n\n# Swerve\n\nFeature flipping for Node.js\n\n## Installation\n\nAdd `swerve` to your `package.json` file and `npm install`. Or:\n\n```bash\nnpm install swerve --save\n```\n\nIf you're using Hem, also make sure you add it to your `slug.json` file as a\ndependency.\n\n## Configuration\n\nRequire Swerve and passing a hash of feature settings for each environment.\nTypically, you'll want Swerve globally available throughout your app.\n\n```coffeescript\nSwerve = require('swerve')\nSwerve.configure\n  development:\n    notifications: true\n  production:\n    notifications: false\n```\n\nSet the current environment.\n\n```coffeescript\nSwerve.setEnv('development')\n```\n\n## Feature flipping\n\nNow you can toggle different blocks of code throughout your app based on enabled features.\n\n```coffeescript\nif Swerve.feature('notifications')\n  # Code for new notifications feature\nelse\n  # Current code without new notifications\n```\n\n`Swerve.feature()` returns the value from the configuration (or URL param, see\nsection below). While you usually set the value to either `true` or `false`, you\nhave the flexibility of setting it to whatever you may need (i.e. a hash of\nsettings for that feature for each environment).\n\n## Toggling with URL parameters\n\nFeatures can also be enabled or disabled by passing in the feature name as a\nquery string in the URL. These params take precedence over those set in the\nconfiguration.\n\nSo if we visit `http://www.example.com?notifications=true` in our production\nenvironment, then that feature will be considered enabled, regardless of the\nsetting passed in through the original configuration.\n\n## License\n\nCopyright 2013 Jico Baligod.\n\nLicensed under the [MIT License](http://github.com/jico/swerve/raw/master/LICENSE).\n","readmeFilename":"README.md","_id":"swerve@0.0.3","dist":{"shasum":"cad4f5a14ba82a3515d6ad2a66174b3098caf59c","tarball":"https://registry.npmjs.org/swerve/-/swerve-0.0.3.tgz","integrity":"sha512-3kReo2MgOG9DT6X9+C3kiQVRbVE30KBpiDM5J7W3vnYF0mCE9wMSrS/3oFpKqqwfpsDtVXNYQnP+YxthNQGytQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDac7VOi2jvk96UorgUYW3xETzkJu7mSMNNat44c84ixAIhALvjFhEJ2+61nmea2XIIMQQg42ryMrmeSs6EWlTShor1"}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"jico","email":"jico@baligod.com"},"maintainers":[{"name":"jico","email":"jico@baligod.com"}],"directories":{}},"0.1.0":{"name":"swerve","version":"0.1.0","description":"Feature flipper.","author":{"name":"Jico Baligod","email":"jico@baligod.com"},"homepage":["https://github.com/jico/swerve"],"engines":{"node":">=0.8"},"repository":{"type":"git","url":"https://github.com/jico/swerve"},"licenses":[{"type":"MIT","url":"http://github.com/jico/swerve/raw/master/LICENSE"}],"devDependencies":{"coffee-script":"1.6.2","expect.js":"0.2.0","jsdom":"0.5.6","mocha":"1.8.2"},"main":"./index.js","scripts":{"build":"./node_modules/.bin/coffee -co . src","test":"./node_modules/.bin/mocha --reporter spec --timeout 4000 --ignore-leaks","watch":"./node_modules/.bin/coffee -wo . src"},"readme":"[![Build Status](https://travis-ci.org/jico/swerve.png?branch=master)](https://travis-ci.org/jico/swerve)\n\n# Swerve\n\nFeature flipping for Node.js\n\n## Installation\n\nAdd `swerve` to your `package.json` file and `npm install`. Or:\n\n```bash\nnpm install swerve --save\n```\n\nIf you're using Hem, also make sure you add it to your `slug.json` file as a\ndependency.\n\n## Configuration\n\nRequire Swerve and pass a hash of feature settings for each environment.\nTypically, you'll want Swerve globally available throughout your app. In\nCoffeeScript, you would have something similar to the following:\n\n```coffeescript\nSwerve = require('swerve')\nSwerve.configure\n  development:\n    notifications: true\n  production:\n    notifications: false\n```\n\nAlternatively, you can store your settings in a JSON file and pass the file name\ninstead.\n\n```coffeescript\nSwerve.configure('swerve.json')\n```\n\nOnce you've configured your feature settings, you need to set the current environment:\n\n```coffeescript\nSwerve.setEnv('development')\n```\n\n## Feature flipping\n\nNow you can toggle different blocks of code throughout your app based on enabled features.\n\n```coffeescript\nif Swerve.feature('notifications')\n  # Code for new notifications feature\nelse\n  # Current code without new notifications\n```\n\n`Swerve.feature()` returns the value from the configuration (or URL param, see\nsection below). While you usually set the value to either `true` or `false`, you\nhave the flexibility of setting it to whatever you may need (i.e. a hash of\nsettings for that feature for each environment).\n\n## Toggling with URL parameters\n\nFeatures can also be enabled or disabled by passing in the feature name as a\nquery string in the URL. These params take precedence over those set in the\nconfiguration.\n\nSo if we visit `http://www.example.com?notifications=true` in our production\nenvironment, then that feature will be considered enabled, regardless of the\nsetting passed in through the original configuration.\n\n## License\n\nCopyright 2013 Jico Baligod.\n\nLicensed under the [MIT License](http://github.com/jico/swerve/raw/master/LICENSE).\n","readmeFilename":"README.md","_id":"swerve@0.1.0","dist":{"shasum":"12532791ba970cb81f9516f647500af0f7499585","tarball":"https://registry.npmjs.org/swerve/-/swerve-0.1.0.tgz","integrity":"sha512-tMoL+BrpV2wCKMs3qDdMUiyVI/YaZwfodwTLpjSHumVQhXkd/e6BWuemPYMkqntaRr0dG+mDg7h5fs4khIXTwA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAa56qatKFjheQZkp4T/sjMFb7BhxgCo9N19BsFVk0upAiEA10yuD1sSg7UII6r5DWK7MnI+70WmLU/lq64X4xUhbjQ="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"jico","email":"jico@baligod.com"},"maintainers":[{"name":"jico","email":"jico@baligod.com"}],"directories":{}},"0.2.0":{"name":"swerve","version":"0.2.0","description":"Feature flipper.","author":{"name":"Jico Baligod","email":"jico@baligod.com"},"homepage":["https://github.com/jico/swerve"],"engines":{"node":">=0.8"},"repository":{"type":"git","url":"https://github.com/jico/swerve"},"licenses":[{"type":"MIT","url":"http://github.com/jico/swerve/raw/master/LICENSE"}],"devDependencies":{"coffee-script":"1.6.2","expect.js":"0.2.0","jsdom":"0.5.6","mocha":"1.8.2"},"main":"./index.js","scripts":{"build":"./node_modules/.bin/coffee -co . src","test":"./node_modules/.bin/mocha --reporter spec --timeout 4000 --ignore-leaks","watch":"./node_modules/.bin/coffee -wo . src"},"readme":"[![Build Status](https://travis-ci.org/jico/swerve.png?branch=master)](https://travis-ci.org/jico/swerve)\n\n# Swerve\n\nFeature flipping for Node.js\n\n## Installation\n\nAdd `swerve` to your `package.json` file and `npm install`. Or:\n\n```bash\nnpm install swerve --save\n```\n\nIf you're using Hem, also make sure you add it to your `slug.json` file as a\ndependency.\n\n## Configuration\n\nRequire Swerve and pass a hash of feature settings for each environment.\nTypically, you'll want Swerve globally available throughout your app. In\nCoffeeScript, you would have something similar to the following:\n\n```coffeescript\nSwerve = require('swerve')\nSwerve.configure\n  development:\n    notifications: true\n  production:\n    notifications: false\n```\n\nAlternatively, you can store your settings in a JSON file and pass the file name\ninstead.\n\n```coffeescript\nSwerve.configure('swerve.json')\n```\n\nOnce you've configured your feature settings, you need to set the current environment:\n\n```coffeescript\nSwerve.setEnv('development')\n```\n\n## Feature flipping\n\nNow you can toggle different blocks of code throughout your app based on enabled features.\n\n```coffeescript\nif Swerve.feature('notifications')\n  # Code for new notifications feature\nelse\n  # Current code without new notifications\n```\n\n`Swerve.feature()` returns the value from the configuration (or URL param, see\nsection below). While you usually set the value to either `true` or `false`, you\nhave the flexibility of setting it to whatever you may need (i.e. a hash of\nsettings for that feature for each environment).\n\n## Toggling on the fly\n\nA feature can be enabled by calling `Swerve.enable('notifications')` for\nexample, which simply sets that feature to `true` under the current environment.\nYou can optionally set the feature to a value:\n\n```coffeescript\nnotification_options =\n  gutter:  true\n  disrupt: false\nSwerve.enable 'notifications', notification_options\n```\n\nSimilarly, a feature can be disabled (set to `false`) by calling\n`Swerve.disable('notifications')`.\n\n## Toggling with URL parameters\n\nFeatures can also be enabled or disabled by passing in the feature name as a\nquery string in the URL. These params take precedence over those set in the\nconfiguration.\n\nSo if we visit `http://www.example.com?notifications=true` in our production\nenvironment, then that feature will be considered enabled, regardless of the\nsetting passed in through the original configuration.\n\n## License\n\nCopyright 2013 Jico Baligod.\n\nLicensed under the [MIT License](http://github.com/jico/swerve/raw/master/LICENSE).\n","readmeFilename":"README.md","_id":"swerve@0.2.0","dist":{"shasum":"f649c96328a863e5dd399ad2f5767625b2d74644","tarball":"https://registry.npmjs.org/swerve/-/swerve-0.2.0.tgz","integrity":"sha512-tcUx7WPOCOBqkl61HkSwGbuYCe2C3fK5V+WDxbCwboTekohKFMKQxBZDjmC5oXJdGe6QNnud6Yom8qnIa/1xeg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDKAxwtPht3Rj+CIyeJuNwFpW+wn2zID///iki0+RUgfgIhANlGK3bnjV8bzFD25pucB1iMUP+Lbhpmt8wnF+aDhFji"}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"jico","email":"jico@baligod.com"},"maintainers":[{"name":"jico","email":"jico@baligod.com"}],"directories":{}},"0.3.0":{"name":"swerve","version":"0.3.0","description":"Feature flipper.","author":{"name":"Jico Baligod","email":"jico@baligod.com"},"homepage":["https://github.com/jico/swerve"],"engines":{"node":">=0.8"},"repository":{"type":"git","url":"https://github.com/jico/swerve"},"licenses":[{"type":"MIT","url":"http://github.com/jico/swerve/raw/master/LICENSE"}],"devDependencies":{"coffee-script":"1.6.2","expect.js":"0.2.0","jsdom":"0.5.6","mocha":"1.8.2","rimraf":"2.1.4"},"main":"./index.js","scripts":{"build":"./node_modules/.bin/coffee -co . src","test":"./node_modules/.bin/mocha --reporter spec --timeout 4000 --ignore-leaks","watch":"./node_modules/.bin/coffee -wo . src"},"readme":"[![Build Status](https://travis-ci.org/jico/swerve.png?branch=master)](https://travis-ci.org/jico/swerve)\n\n# Swerve\n\nFeature flipping for Node.js\n\n## Installation\n\nAdd `swerve` to your `package.json` file and `npm install`. Or:\n\n```bash\nnpm install swerve --save\n```\n\nIf you're using Hem, also make sure you add it to your `slug.json` file as a\ndependency.\n\n## Configuration\n\nRequire Swerve (globally, in most cases). In CoffeeScript, you'll have something\nsimilar to below.\n\n```coffeescript\nSwerve = require('swerve')\n\n# Or, if you have this in some setup file\nwindow?.Swerve = require('swerve')\n```\n\nThen, you'll need to configure Swerve with the feature settings you want for\neach environment. There are three ways to do this:\n\n* Pass in a hash.\n\n  ```coffeescript\n  Swerve.configure\n    development:\n      notifications: true\n    production:\n      notifications: false\n  ```\n\n* Store your settings in a JSON file and pass the file name\ninstead.\n\n  ```coffeescript\n  Swerve.configure('features.json')\n  ```\n\n* Or, since `configure()` searches for a file named `swerve.json` in the current\n  working directory, you can save your settings in that file, or call `save()`\n  at some point in your application.\n\nFinally, once you've configured your feature settings, you need to set the current environment:\n\n```coffeescript\nSwerve.setEnv('development')\n```\n\n### Saving configuration\n\nYou can save the state of your current configuration at any time by calling\n`.save()`. This function takes a single, optional file name argument, which\ndefaults to `swerve.json`.\n\n## Feature flipping\n\nNow you can toggle different blocks of code throughout your app based on enabled features.\n\n```coffeescript\nif Swerve.feature('notifications')\n  # Code for new notifications feature\nelse\n  # Current code without new notifications\n```\n\n`Swerve.feature()` returns the value from the configuration (or URL param, see\nsection below). While you usually set the value to either `true` or `false`, you\nhave the flexibility of setting it to whatever you may need (i.e. a hash of\nsettings for that feature for each environment).\n\n## Toggling on the fly\n\nA feature can be enabled by calling `Swerve.enable('notifications')` for\nexample, which simply sets that feature to `true` under the current environment.\nYou can optionally set the feature to a value:\n\n```coffeescript\nnotification_options =\n  gutter:  true\n  disrupt: false\nSwerve.enable 'notifications', notification_options\n```\n\nSimilarly, a feature can be disabled (set to `false`) by calling\n`Swerve.disable('notifications')`.\n\n## Toggling with URL parameters\n\nFeatures can also be enabled or disabled by passing in the feature name as a\nquery string in the URL. These params take precedence over those set in the\nconfiguration.\n\nSo if we visit `http://www.example.com?notifications=true` in our production\nenvironment, then that feature will be considered enabled, regardless of the\nsetting passed in through the original configuration.\n\n## License\n\nCopyright 2013 Jico Baligod.\n\nLicensed under the [MIT License](http://github.com/jico/swerve/raw/master/LICENSE).\n","readmeFilename":"README.md","_id":"swerve@0.3.0","dist":{"shasum":"3d58780acfc1b49f36f453fa781f00fd3277f4d8","tarball":"https://registry.npmjs.org/swerve/-/swerve-0.3.0.tgz","integrity":"sha512-9klnlg5dRo2CR/x0+lIPrPUC5f1qUmgk0zPbIPDJJJbzuoybVTUv8dhX4Wc+LfAtcz2Zgwwp22sPH2a2wXnRpg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDoaD5Kt9pCvfoPXXaHWGwtKlJ4Dz6mo18FKxQyEC7mkQIgb16b76+/vwJS0zDmJdGAZjgK57CBjkIqkzh2SMNdlrI="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"jico","email":"jico@baligod.com"},"maintainers":[{"name":"jico","email":"jico@baligod.com"}],"directories":{}},"0.4.0":{"name":"swerve","version":"0.4.0","description":"Feature flipper.","author":{"name":"Jico Baligod","email":"jico@baligod.com"},"homepage":["https://github.com/jico/swerve"],"engines":{"node":">=0.8"},"repository":{"type":"git","url":"https://github.com/jico/swerve"},"licenses":[{"type":"MIT","url":"http://github.com/jico/swerve/raw/master/LICENSE"}],"devDependencies":{"coffee-script":"1.6.2","expect.js":"0.2.0","jsdom":"0.5.6","mocha":"1.8.2","rimraf":"2.1.4"},"main":"./index.js","scripts":{"build":"./node_modules/.bin/coffee -co . src","test":"./node_modules/.bin/mocha --reporter spec --timeout 4000 --ignore-leaks","watch":"./node_modules/.bin/coffee -wo . src"},"readme":"[![Build Status](https://travis-ci.org/jico/swerve.png?branch=master)](https://travis-ci.org/jico/swerve)\n\n# Swerve\n\nFeature flipping for Node.js\n\n## Installation\n\nAdd `swerve` to your `package.json` file and `npm install`. Or:\n\n```bash\nnpm install swerve --save\n```\n\nIf you're using Hem, also make sure you add it to your `slug.json` file as a\ndependency.\n\n## Configuration\n\nRequire Swerve (globally, in most cases). In CoffeeScript, you'll have something\nsimilar to below.\n\n```coffeescript\nSwerve = require('swerve')\n\n# Or, if you have this in some setup file\nwindow?.Swerve = require('swerve')\n```\n\nThen, you'll need to configure Swerve with the feature settings you want for\neach environment. There are three ways to do this:\n\nPass in a hash.\n```coffeescript\nSwerve.configure\n  development:\n    notifications: true\n  production:\n    notifications: false\n```\n\nStore your settings in a JSON file and pass the file name\ninstead.\n```coffeescript\nSwerve.configure('features.json')\n```\n\nOr, since `configure()` searches for a file named `swerve.json` in the current\nworking directory, you can save your settings in that file, or call `save()`\nat some point in your application.\n\nFinally, once you've configured your feature settings, you need to set the current environment:\n\n```coffeescript\nSwerve.setEnv('development')\n```\n\n### Saving configuration\n\nYou can save the state of your current configuration at any time by calling\n`save()`. This function takes a single, optional file name argument, which\ndefaults to `swerve.json`.\n\n## Feature flipping\n\nNow you can toggle different blocks of code throughout your app based on enabled\nfeatures in one of two ways:\n\nCheck the feature as a property on the `Swerve` object.\n```coffeescript\nif Swerve.notifications\n  console.log('You have notifications!')\nelse\n  console.log('Notifications coming soon.')\n```\n\nCall `feature` and pass in the feature name.\n```coffeescript\nif Swerve.feature('notifications')\n  console.log('You have notifications!')\nelse\n  console.log('Notifications coming soon.')\n```\n\nChecking a feature returns the value from the configuration (or URL param, see\nsection below). While you usually set the value to either `true` or `false`, you\nhave the flexibility of setting it to whatever you may need (i.e. a hash of\nsettings for that feature for each environment).\n\n## Toggling on the fly\n\nA feature can be enabled by calling `Swerve.enable('notifications')` for\nexample, which simply sets that feature to `true` under the current environment.\nYou can optionally set the feature to a value:\n\n```coffeescript\nnotification_options =\n  gutter:  true\n  disrupt: false\nSwerve.enable 'notifications', notification_options\n```\n\nSimilarly, a feature can be disabled (set to `false`) by calling\n`Swerve.disable('notifications')`.\n\n## Toggling with URL parameters\n\nFeatures can also be enabled or disabled by passing in the feature name as a\nquery string in the URL. These params take precedence over those set in the\nconfiguration.\n\nSo if we visit `http://www.example.com?notifications=true` in our production\nenvironment, then that feature will be considered enabled, regardless of the\nsetting passed in through the original configuration.\n\n## License\n\nCopyright 2013 Jico Baligod.\n\nLicensed under the [MIT License](http://github.com/jico/swerve/raw/master/LICENSE).\n","readmeFilename":"README.md","_id":"swerve@0.4.0","dist":{"shasum":"521887e0864736ee0920cf8562003a4cdbbd1767","tarball":"https://registry.npmjs.org/swerve/-/swerve-0.4.0.tgz","integrity":"sha512-oOvO1DHl/XkvtOdTHZizZnPuRBGH6ZqE3E5ZAEHra3o/OapesStGimQP1LU1KFP1QWTRdP/ueRrjHdiawEGWTg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAGpD885PZi8GO5pDZlTiec7Ev7gTGxE+xIH6JIBMkgMAiEAi/44SElG4u4EW/XJaROxRr13Vbo3IM/rHQVo07+X6Ow="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"jico","email":"jico@baligod.com"},"maintainers":[{"name":"jico","email":"jico@baligod.com"}]},"0.5.0":{"name":"swerve","version":"0.5.0","description":"Feature flipper.","author":{"name":"Jico Baligod","email":"jico@baligod.com"},"homepage":["https://github.com/jico/swerve"],"engines":{"node":">=0.8"},"repository":{"type":"git","url":"https://github.com/jico/swerve"},"licenses":[{"type":"MIT","url":"http://github.com/jico/swerve/raw/master/LICENSE"}],"devDependencies":{"coffee-script":"1.6.2","expect.js":"0.2.0","jsdom":"0.5.6","mocha":"1.8.2","rimraf":"2.1.4"},"main":"./index.js","scripts":{"build":"./node_modules/.bin/coffee -co . src","test":"./node_modules/.bin/mocha --reporter spec --timeout 4000 --ignore-leaks","watch":"./node_modules/.bin/coffee -wo . src"},"readme":"[![Build Status](https://travis-ci.org/jico/swerve.png?branch=master)](https://travis-ci.org/jico/swerve)\n\n# Swerve\n\nFeature flipping for Node.js\n\n## Installation\n\nAdd `swerve` to your `package.json` file and `npm install`. Or:\n\n```bash\nnpm install swerve --save\n```\n\nIf you're using Hem, also make sure you add it to your `slug.json` file as a\ndependency.\n\n## Configuration\n\nRequire Swerve (globally, in most cases). In CoffeeScript, you'll have something\nsimilar to below.\n\n```coffeescript\nSwerve = require('swerve')\n\n# Or, if you have this in some setup file\nwindow?.Swerve = require('swerve')\n```\n\nThen, you'll need to configure Swerve with the feature settings you want for\neach environment by passing in a hash.\n\n```coffeescript\nSwerve.configure\n  development:\n    notifications: true\n  production:\n    notifications: false\n```\n\nOnce you've configured your feature settings, you need to set the current environment:\n\n```coffeescript\nSwerve.setEnv('development')\n```\n\n## Feature flipping\n\nNow you can toggle different blocks of code throughout your app based on enabled\nfeatures in one of two ways:\n\nCheck the feature as a property on the `Swerve` object.\n```coffeescript\nif Swerve.notifications\n  console.log('You have notifications!')\nelse\n  console.log('Notifications coming soon.')\n```\n\nCall `feature` and pass in the feature name.\n```coffeescript\nif Swerve.feature('notifications')\n  console.log('You have notifications!')\nelse\n  console.log('Notifications coming soon.')\n```\n\nChecking a feature returns the value from the configuration (or URL param, see\nsection below). While you usually set the value to either `true` or `false`, you\nhave the flexibility of setting it to whatever you may need (i.e. a hash of\nsettings for that feature for each environment).\n\n## Toggling on the fly\n\nA feature can be enabled by calling `Swerve.enable('notifications')` for\nexample, which simply sets that feature to `true` under the current environment.\nYou can optionally set the feature to a value:\n\n```coffeescript\nnotification_options =\n  gutter:  true\n  disrupt: false\nSwerve.enable 'notifications', notification_options\n```\n\nSimilarly, a feature can be disabled (set to `false`) by calling\n`Swerve.disable('notifications')`.\n\n## Toggling with URL parameters\n\nFeatures can also be enabled or disabled by passing in the feature name as a\nquery string in the URL. These params take precedence over those set in the\nconfiguration.\n\nSo if we visit `http://www.example.com?notifications=true` in our production\nenvironment, then that feature will be considered enabled, regardless of the\nsetting passed in through the original configuration.\n\n## License\n\nCopyright 2013 Jico Baligod.\n\nLicensed under the [MIT License](http://github.com/jico/swerve/raw/master/LICENSE).\n","readmeFilename":"README.md","_id":"swerve@0.5.0","dist":{"shasum":"dc730b3451c4468c94b0325eca09e1d05081c5a3","tarball":"https://registry.npmjs.org/swerve/-/swerve-0.5.0.tgz","integrity":"sha512-i+aqSyLe6F5yBLNuq5X9S+Z/a8Y184AcAUONWq9mb7PBHO9fMofQIj7noXFG2jiCQqSNDHYJevy6GMpm/h4z4w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBahBVPHcI1+JBj3gcrfAC9EHFMiWDPt8pkK55Z615ueAiBhyoJtCBC2QYq6y6NKasEOgzTfjsnmamyhRcGDEUn9zg=="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"jico","email":"jico@baligod.com"},"maintainers":[{"name":"jico","email":"jico@baligod.com"}]}},"readme":"\nNode.js: fs-extra\n=================\n\n[![build status](https://secure.travis-ci.org/jprichardson/node-fs-extra.png)](http://travis-ci.org/jprichardson/node-fs-extra)\n\nThis module adds a few extra file system methods that aren't included in the native `fs` module. It is a drop in replacement for `fs`.\n\n\n\nWhy?\n----\n\nI got tired of including `mkdirp`, `rimraf`, and `cp -r` in most of my projects. \n\n\n\n\nInstallation\n------------\n\n    npm install --save fs-extra\n\n\n\nUsage\n-----\n\nDrop in replacement for native `fs`.\n\n\n```javascript\nvar fs = require('fs-extra');\n```\n\n\n\nMethods\n-------\n\n**NOTE:** You can still use the native Node.js methods. They are copied over to `fs-extra`.\n\n\n### copy(src, dest, callback)\n\nCopy a file or directory. The directory can have contents. Like `cp -r`. There isn't a synchronous version implemented yet.\n\nSync: (none)\n\n\nExamples:\n\n```javascript\nvar fs = require('fs-extra');\n\nfs.copy('/tmp/myfile', '/tmp/mynewfile', function(err){\n  if (err) {\n    console.error(err);\n  }\n  else {\n    console.log(\"success!\")\n  }\n}); //copies file\n\nfs.copy('/tmp/mydir', '/tmp/mynewdir', function(err){\n  if (err) {\n    console.error(err);\n  }\n  else {\n    console.log(\"success!\")\n  }\n}); //copies directory, even if it has subdirectories or files\n```\n\n\n### createFile(file, callback) \n\nCreates a file. If the file that is requested to be created is in directories that do not exist, these directories are created. If the file already exists, it is **NOT MODIFIED**.\n\nSync: `createFileSync()`\n\n\nExample:\n\n```javascript\nvar fs = require('fs-extra')\n  , file = '/tmp/this/path/does/not/exist/file.txt'\n\nfs.createFile(file, function(err) {\n  console.log(err); //null\n\n  //file has now been created, including the directory it is to be placed in\n})\n```\n\n\n\n### mkdirs(dir, callback) \n\nCreates a directory. If the parent hierarchy doesn't exist, it's created. Like `mkdir -p`.\n\nAlias: `mkdirp()`\n\nSync: `mkdirsSync()` / `mkdirpSync()`\n\n\nExamples:\n\n```javascript\nvar fs = require('fs-extra');\n\nfs.mkdirs('/tmp/some/long/path/that/prob/doesnt/exist', function(err){\n  if (err) {\n    console.error(err);\n  }\n  else {\n    console.log(\"success!\")\n  }\n});\n\nfs.mkdirsSync('/tmp/another/path');\n```\n\n\n### outputFile(file, data, callback)\n\nAlmost the same as `writeFile`, except that if the directory does not exist, it's created.\n\nSync: `outputFileSync()`\n\n\nExample:\n\n```javascript\nvar fs = require('fs-extra')\n  , file = '/tmp/this/path/does/not/exist/file.txt'\n\nfs.outputFile(file, 'hello!' function(err) {\n  console.log(err); //null\n\n  fs.readFile(file, 'utf8', function(err, data) {\n    console.log(data); //hello!\n  })\n})\n```\n\n\n### readJson(file, callback) \n\nReads a JSON file and then parses it into an object.\n\nAlias: `readJSON()`\n\nSync: `readJsonSync()`, `readJSONSync()`\n\n\nExample:\n\n```javascript\nvar fs = require('fs-extra');\n\nfs.readJson('./package.json', function(err, packageObj) {\n  console.log(packageObj.version); //0.1.3\n});\n```\n\n\n### remove(dir, callback)\n\nRemoves a file or directory. The directory can have contents. Like `rm -rf`.\n\nAlias: `delete()`\n\nSync: `removeSync()` / `deleteSync()`\n\n\nExamples:\n\n```javascript\nvar fs = require('fs-extra');\n\nfs.remove('/tmp/myfile', function(err){\n  if (err) {\n    console.error(err);\n  }\n  else {\n    console.log(\"success!\")\n  }\n});\n\nfs.removeSync('/home/jprichardson'); //I just deleted my entire HOME directory. \n```\n\n\n\n### writeJson(file, object, callback) \n\nWrites an object to a JSON file.\n\nAlias: `writeJSON()`\n\nSync: `writeJsonSync()`, `writeJSONSync()`\n\nExample:\n\n```javascript\nvar fs = require('fs-extra');\nfs.writeJson('./package.json', {name: 'fs-extra'}, function(err){\n  console.log(err);\n});\n```\n\n\n\nRoadmap to 1.0.0\n-----------------\n\nThis contains items that I'm considering doing. I'd love community feedback.\n\n* File system walker. I really like this one: https://github.com/daaku/nodejs-walker\n* File/directory tree watcher. There are quite a few.\n* Method to move files.\n* Copy sync.\n* Thinking about moving `rimraf`, `ncp`, and `mkdirps` code into this library. I'd like fs-extra to be a stable library that module authors\ncan depend upon. A bunch of other dependencies kinda sucks for modules/libraries.\n* Change documentation to use the `fse` prefix instead of `fs`. This may encourage people to start using `fse` as a prefix and hence make their code clearer that they're not using the native `fs`. I'm very undecided on this one since `fs-extra` is a drop in replacement for the native `fs`.\n\n\n\nNaming\n------\n\nI put a lot of thought into the naming of these function. Inspired by @coolaj86's request. So he deserves much of the credit for raising the issue. See discussion(s) here:\n\n* https://github.com/jprichardson/node-fs-extra/issues/2\n* https://github.com/flatiron/utile/issues/11\n* https://github.com/ryanmcgrath/wrench-js/issues/29\n* https://github.com/substack/node-mkdirp/issues/17\n\nFirst, I believe that in as many cases as possible, the [Node.js naming schemes](http://nodejs.org/api/fs.html) should be chosen. However, there are problems with the Node.js own naming schemes.\n\nFor example, `fs.readFile()` and `fs.readdir()`: the **F** is capitalized in *File* and the **d** is not capitalized in *dir*. Perhaps a bit pedantic, but they should still be consistent. Also, Node.js has chosen a lot of POSIX naming schemes, which I believe is great. See: `fs.mkdir()`, `fs.rmdir()`, `fs.chown()`, etc.\n\nWe have a dilemma though. How do you consistently name methods that perform the following POSIX commands: `cp`, `cp -r`, `mkdir -p`, and `rm -rf`?\n\nMy perspective: when in doubt, err on the side of simplicity. Consider that for a moment. A directory is just a hierarchical grouping of directories and files. So when you want to copy it or remove it, in most cases you'll want to copy or remove all of its contents. When you want to create a directory, if the directory that it's suppose to be contained in does not exist, then in most cases you'll want to create that too. \n\nSo, if you want to remove a file or a directory regardless of whether it has contents, just call `fs.remove(path)` or its alias `fs.delete(path)`. If you want to copy a file or a directory whether it has contents, just call `fs.copy(source, destination)`. If you want to create a directory regardless of whether its parent directories exist, just call `fs.mkdirs(path)` or `fs.mkdirp(path)`. \n\n\n\nContributors\n-------------\n- [JP Richardson](https://github.com/jprichardson)\n- [Mike McNeil](https://github.com/mikermcneil)\n- [Ian Crowther](https://github.com/iancrowther)\n- `<your name here>`\n\n\n\n\nLicense\n-------\n\n\nLicensed under MIT\n\nCopyright (c) 2011-2013 JP Richardson\n\n[1]: http://nodejs.org/docs/latest/api/fs.html \n\n\n[jsonfile]: https://github.com/jprichardson/node-jsonfile\n\n\n[aboutjp]: http://about.me/jprichardson\n[twitter]: http://twitter.com/jprichardson\n[procbits]: http://procbits.com\n[gitpilot]: http://gitpilot.com\n\n\n\n","maintainers":[{"name":"jico","email":"jico@baligod.com"}],"time":{"modified":"2022-06-27T02:55:08.419Z","created":"2013-04-12T12:10:33.445Z","0.0.1-alpha":"2013-04-12T12:10:34.914Z","0.0.1-alpha.1":"2013-04-12T12:29:31.609Z","0.0.1-alpha.2":"2013-04-12T12:42:33.563Z","0.0.1":"2013-04-12T14:52:23.657Z","0.0.2":"2013-04-12T20:02:45.318Z","0.0.3":"2013-04-12T20:12:02.161Z","0.1.0":"2013-04-14T00:49:11.756Z","0.2.0":"2013-04-14T21:34:06.499Z","0.3.0":"2013-04-20T10:20:25.558Z","0.4.0":"2013-04-27T22:23:47.525Z","0.5.0":"2013-12-06T16:41:12.139Z"},"author":{"name":"Jico Baligod","email":"jico@baligod.com"},"repository":{"type":"git","url":"https://github.com/jico/swerve"}}