Multi items

This commit is contained in:
Gerrit Linnemann 2016-04-03 21:25:23 +02:00
parent fcc98b8f8a
commit ae76c95e7e
427 changed files with 68624 additions and 75 deletions

146
Adawim/helper.js Normal file
View File

@ -0,0 +1,146 @@
/**
* File: Adawim/helper.js
* Author: Gerrit Linnemann
*
* Swiss-knife.
*/
// load the things we need
var os = require('os')
, dns = require('dns')
, Log = require('./logging')
, Crypto = require('crypto');
exports.timeSince = function timeSince(date) {
var seconds = Math.floor((new Date() - date) / 1000);
var interval = Math.floor(seconds / 31536000);
if (interval > 1) {
return interval + " years";
}
interval = Math.floor(seconds / 2592000);
if (interval > 1) {
return interval + " months";
}
interval = Math.floor(seconds / 86400);
if (interval > 1) {
return interval + " days";
}
interval = Math.floor(seconds / 3600);
if (interval > 1) {
return interval + " hours";
}
interval = Math.floor(seconds / 60);
if (interval > 1) {
return interval + " minutes";
}
return Math.floor(seconds) + " seconds";
}
exports.isResultAvailable = function(res) {
return (
typeof res !== 'undefined' &&
res != null &&
typeof res.result !== 'undefined' &&
res.result != null
);
}
exports.isTypeAvailable = function(res) {
return (
typeof res !== 'undefined' &&
res != null &&
typeof res.type !== 'undefined' &&
res.type != null
);
}
exports.isJSON = function(toCheck) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
exports.isDefinedAndNotNull = function(toCheck) {
return (
typeof toCheck !== 'undefined' &&
toCheck != null
);
}
exports.cnt = function(db) {
var cnt = 0;
if(db.constructor === Array) { // do it the array-way
cnt = db.length;
} else { // oh boy, no array ...
var cnt_ = 0;
for (var key_ in db) { cnt_++; }
cnt = cnt_;
}
return cnt;
}
exports.each = function(db, callback) {
if(db.constructor === Array) { // do it the array-way
for(i=0; i < db.length; i++) {
var entry = db[i];
var isLast = ((i+1) == db.length);
callback(entry, isLast);
}
} else { // oh boy, no array ...
var cnt_ = 0;
for (var key_ in db) { cnt_++; }
var cnt = 0;
for (var key in db) {
cnt++;
var entry = db[key];
callback(entry, (cnt_==cnt));
}
}
}
exports.checkValueEquality = function(foo, bar) {
return doValueEqualityCheck(foo, bar);
}
exports.simpleHash = function(foo) {
var hash = Crypto.createHash('md5').update(foo).digest('hex');
return hash;
}
/* private */
function doValueEqualityCheck(foo, bar) {
var key;
for(key in foo) {
Log.debug( "Compare \"" + foo[key] + "\" with \"" + bar[key] + "\" for key \"" + key + "\"" );
if(typeof foo[key] === 'object' && typeof bar[key] === 'object') {
var isEquals = doValueEqualityCheck(foo, bar);
if(!isEquals) {
return false;
}
} else {
if(foo[key].localeCompare(bar[key]) != 0) {
return false;
}
}
}
return true;
}

101
Adawim/logging.js Normal file
View File

@ -0,0 +1,101 @@
/**
* File: Adawim/logging.js
* Author: Gerrit Linnemann
*
* Logging with several log-level.
* - debug: Printed only in development-state.
* - log: Needed log-output.
* - error: Prints log in error-level.
* - inspect: Prints a message and details of an object.
*/
// load the things we need
var DateFormat = require('dateformat')
, Helper = require('./helper.js')
, util = require('util')
, Inspect = require('eyespect').inspector();
var eyeFriendly = 'friendly';
var isDebug = true;
var isTrace = (isDebug && false);
exports.isEyeFriendlyMode = function() {
return eyeFriendly;
}
exports.isTrace = function() {
return isTrace;
}
exports.isDebug = function() {
return isDebug;
}
exports.trace = function(msg) {
msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " TRACE " + msg;
if(isTrace) {
consoleOut(msg);
}
}
exports.debug = function(msg) {
msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " DEBUG " + msg;
if(isDebug) {
consoleOut(msg);
}
}
exports.log = function(msg) {
msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " INFO " + msg;
consoleOut(msg);
}
exports.error = function(msg) {
msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " ERROR " + msg;
consoleErr(msg);
}
exports.inspect = function(msg, content) {
msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " INSPECT " + msg;
if(eyeFriendly) {
Inspect(content, msg);
} else {
var msgOut = msg + (Helper.isDefinedAndNotNull(content) ? ": "+JSON.stringify(content) : "");
consoleOut(msgOut);
}
}
/* private */
function consoleOut(msg, content) {
var hasContent = Helper.isDefinedAndNotNull(content);
if(hasContent) {
var msgAddon = (hasContent ? " | " + content : "");
if(Helper.isDefinedAndNotNull(msg)) {
console.log(msg + msgAddon);
}
} else if(Helper.isDefinedAndNotNull(msg)) {
console.log(msg);
}
}
/* private */
function consoleErr(msg, content) {
var hasContent = Helper.isDefinedAndNotNull(content);
if(hasContent) {
var msgAddon = (hasContent ? " | " + content : "");
if(Helper.isDefinedAndNotNull(msg)) {
console.error(msg + msgAddon);
}
} else if(Helper.isDefinedAndNotNull(msg)) {
console.error(msg);
}
}

View File

@ -1,60 +1,63 @@
var Tinkerforge = require('../Tinkerforge')
, Conf = require('./config.json')
, Helper = require('../Adawim/helper')
, Log = require('../Adawim/logging')
, http = require('http');
var HOST = Conf.host;
var PORT = Conf.port;
var UID = Conf.uid;
var ipcon = new Tinkerforge.IPConnection(); // Create IP connection
var dus = new Tinkerforge.BrickletDistanceUS(UID, ipcon); // Create device object
var counter = 0;
var readyForNextNotification = true;
ipcon.connect(HOST, PORT,
function (error) {
console.log('Error: ' + error);
}
); // Connect to brickd
// Don't use device before ipcon is connected
ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED,
function (connectReason) {
// Set period for distance value callback to 0.2s (200ms)
// Note: The distance value callback is only called every 0.2 seconds
// if the distance value has changed since the last call!
dus.setDistanceCallbackPeriod(200);
}
);
// Register distance value callback
dus.on(Tinkerforge.BrickletDistanceUS.CALLBACK_DISTANCE,
// Callback function for distance value callback
function (distance) {
//console.log('Distance Value: ' + distance);
if(distance < 200 && readyForNextNotification) {
counter++;
readyForNextNotification = false;
var url2callObj = (counter % 2 == 0 ? Conf.on.action.on : Conf.on.action.off);
console.log('Distance Value: ' + distance + ', URL to call: ' + url2callObj.host + ':' + url2callObj.port + url2callObj.path);
doHoBuDoorBellCall(url2callObj);
setTimeout(function() { readyForNextNotification = true; }, Conf.on.action.timeout);
Helper.each(Conf.items, function(item) {
var HOST = item.host;
var PORT = item.port;
var UID = item.uid;
var ipcon = new Tinkerforge.IPConnection(); // Create IP connection
var dus = new Tinkerforge.BrickletDistanceUS(UID, ipcon); // Create device object
var counter = 0;
var readyForNextNotification = true;
ipcon.connect(HOST, PORT,
function (error) {
Log.log('Error: ' + error);
}
}
);
console.log('Press key to exit');
process.stdin.on('data',
function (data) {
); // Connect to brickd
// Don't use device before ipcon is connected
ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED,
function (connectReason) {
// Set period for distance value callback to 0.2s (200ms)
// Note: The distance value callback is only called every 0.2 seconds
// if the distance value has changed since the last call!
dus.setDistanceCallbackPeriod(200);
}
);
// Register distance value callback
dus.on(Tinkerforge.BrickletDistanceUS.CALLBACK_DISTANCE,
// Callback function for distance value callback
function (distance) {
//Log.log('Distance Value: ' + distance);
if(distance < 200 && readyForNextNotification) {
counter++;
readyForNextNotification = false;
var url2callObj = (counter % 2 == 0 ? item.on.action.on : item.on.action.off);
Log.log('Distance Value: ' + distance + ', URL to call: ' + url2callObj.host + ':' + url2callObj.port + url2callObj.path);
doHoBuDoorBellCall(url2callObj);
setTimeout(function() { readyForNextNotification = true; }, item.on.action.timeout);
}
}
);
process.on( 'SIGINT', function() {
console.log( "\nGracefully disconnect " + HOST );
ipcon.disconnect();
process.exit(0);
}
);
process.exit( );
});
});
/* private */
@ -69,7 +72,7 @@ function doHoBuDoorBellCall(options) {
//the whole response has been recieved, so we just print it out here
response.on('end', function () {
console.log(str);
Log.log(str);
});
}

View File

@ -1,20 +1,24 @@
{
"host": "192.168.2.124",
"port": 4223,
"uid": "q2J",
"on": {
"action": {
"timeout": 4500,
"items": [
{
"host": "192.168.2.124",
"port": 4223,
"uid": "q2J",
"on": {
"host": "hobu",
"port": "2999",
"path": "/set/state/of/powercontrol/23/to/1/"
},
"off": {
"host": "hobu",
"port": "2999",
"path": "/set/state/of/powercontrol/23/to/0/"
"action": {
"timeout": 4500,
"on": {
"host": "hobu",
"port": "2999",
"path": "/set/state/of/powercontrol/23/to/1/"
},
"off": {
"host": "hobu",
"port": "2999",
"path": "/set/state/of/powercontrol/23/to/0/"
}
}
}
}
}
}
}
]
}

View File

@ -56,13 +56,11 @@ ai.on(Tinkerforge.BrickletAnalogInV2.CALLBACK_VOLTAGE,
}
);
console.log('Press key to exit');
process.stdin.on('data',
function (data) {
ipcon.disconnect();
process.exit(0);
}
);
process.on( 'SIGINT', function() {
console.log( "\nGracefully disconnect " + HOST );
ipcon.disconnect();
process.exit( );
});
/* private */

1
node_modules/.bin/dateformat generated vendored Symbolic link
View File

@ -0,0 +1 @@
../dateformat/bin/cli.js

1
node_modules/byline/.idea/.name generated vendored Normal file
View File

@ -0,0 +1 @@
node-byline

22
node_modules/byline/.idea/compiler.xml generated vendored Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

4
node_modules/byline/.idea/encodings.xml generated vendored Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

170
node_modules/byline/.idea/misc.xml generated vendored Normal file
View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
<component name="CopyrightManager" default="" />
<component name="CppTools.Loader" reportImplicitCastToBool="false" reportNameReferencedOnce="false" version="3" compilerSelect="AUTO" />
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="DependencyValidationManager">
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectModuleManager">
<modules />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" />
<component name="PropertiesComponent">
<property name="GoToClass.includeLibraries" value="false" />
<property name="GoToClass.toSaveIncludeLibraries" value="false" />
<property name="GoToFile.includeJavaFiles" value="false" />
<property name="MemberChooser.sorted" value="false" />
<property name="MemberChooser.showClasses" value="true" />
<property name="MemberChooser.copyJavadoc" value="false" />
<property name="options.lastSelected" value="preferences.pluginManager" />
<property name="options.splitter.main.proportions" value="0.3" />
<property name="options.splitter.details.proportions" value="0.2" />
</component>
<component name="RunManager">
<configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
<module name="" />
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
<option name="PROGRAM_PARAMETERS" />
<method />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
<method />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<method />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<method />
</configuration>
<list size="0" />
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
<Port>5050</Port>
</configuration>
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>JDK 1.7</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

8
node_modules/byline/.idea/modules.xml generated vendored Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/node-byline.iml" filepath="$PROJECT_DIR$/.idea/node-byline.iml" />
</modules>
</component>
</project>

9
node_modules/byline/.idea/node-byline.iml generated vendored Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

5
node_modules/byline/.idea/scopes/scope_settings.xml generated vendored Normal file
View File

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

97
node_modules/byline/.idea/shelf/CRLF_fix.patch generated vendored Normal file

File diff suppressed because one or more lines are too long

6
node_modules/byline/.idea/vcs.xml generated vendored Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

775
node_modules/byline/.idea/workspace.xml generated vendored Normal file
View File

@ -0,0 +1,775 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="8b19802c-3945-406b-93d9-3f02a5f17aac" name="Default" comment="" />
<ignored path="node-byline.iws" />
<ignored path=".idea/workspace.xml" />
<ignored path=".idea/dataSources.local.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager">
<favorites_list name="node-byline" />
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="byline.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/byline.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="2844">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="package.json" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-9.333333" vertical-offset="0" max-vertical-offset="576">
<caret line="14" column="14" selection-start-line="14" selection-start-column="14" selection-end-line="14" selection-end-column="14" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="LICENSE" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/LICENSE">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-10.8" vertical-offset="0" max-vertical-offset="432">
<caret line="18" column="16" selection-start-line="18" selection-start-column="16" selection-end-line="18" selection-end-column="16" />
<folding />
</state>
</provider>
<provider editor-type-id="com.intellij.database.editor.CsvTableFileEditorProvider">
<state />
</provider>
</entry>
</file>
<file leaf-file-name="README.md" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.06716418" vertical-offset="0" max-vertical-offset="2736">
<caret line="2" column="0" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
<folding />
</state>
</provider>
<provider editor-type-id="MarkdownPreviewEditor">
<state />
</provider>
</entry>
</file>
<file leaf-file-name="tests.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/tests.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="3906">
<caret line="0" column="26" selection-start-line="0" selection-start-column="26" selection-end-line="0" selection-end-column="26" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/test/tests.js" />
<option value="$PROJECT_DIR$/lib/byline.js" />
<option value="$PROJECT_DIR$/LICENSE" />
<option value="$PROJECT_DIR$/package.json" />
<option value="$PROJECT_DIR$/README.md" />
</list>
</option>
</component>
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="23" />
<option name="width" value="1680" />
<option name="height" value="979" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<OptionsSetting value="true" id="Undo Check Out" />
<OptionsSetting value="true" id="Get Latest Version" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
</navigator>
<panes>
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="node-byline" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="node-byline" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="node-byline" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="node-byline" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="node-byline" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="test" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="node-byline" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="node-byline" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="lib" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="GoToClass.includeLibraries" value="false" />
<property name="GoToClass.toSaveIncludeLibraries" value="false" />
<property name="GoToFile.includeJavaFiles" value="false" />
<property name="MemberChooser.sorted" value="false" />
<property name="MemberChooser.showClasses" value="true" />
<property name="MemberChooser.copyJavadoc" value="false" />
<property name="options.lastSelected" value="preferences.pluginManager" />
<property name="options.splitter.main.proportions" value="0.3" />
<property name="options.splitter.details.proportions" value="0.2" />
<property name="aspect.path.notification.shown" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="project.structure.last.edited" value="Facets" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.2" />
</component>
<component name="RunManager">
<configuration default="true" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application">
<method />
</configuration>
<configuration default="true" type="GrailsRunConfigurationType" factoryName="Grails">
<module name="" />
<setting name="vmparams" value="" />
<setting name="cmdLine" value="run-app" />
<setting name="depsClasspath" value="false" />
<setting name="passParentEnv" value="true" />
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<setting name="launchBrowser" value="false" />
<method />
</configuration>
<configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
<module name="" />
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
<option name="PROGRAM_PARAMETERS" />
<method />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
<method />
</configuration>
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
<method />
</configuration>
<configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" working-dir="">
<method />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<method />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<method />
</configuration>
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
<method />
</configuration>
<configuration default="true" type="FlashRunConfigurationType" factoryName="Flash App">
<option name="BCName" value="" />
<option name="IOSSimulatorSdkPath" value="" />
<option name="adlOptions" value="" />
<option name="airProgramParameters" value="" />
<option name="appDescriptorForEmulator" value="Android" />
<option name="debugTransport" value="USB" />
<option name="debuggerSdkRaw" value="BC SDK" />
<option name="emulator" value="NexusOne" />
<option name="emulatorAdlOptions" value="" />
<option name="fastPackaging" value="true" />
<option name="fullScreenHeight" value="0" />
<option name="fullScreenWidth" value="0" />
<option name="launchUrl" value="false" />
<option name="launcherParameters">
<LauncherParameters>
<option name="browser" value="a7bb68e0-33c0-4d6f-a81a-aac1fdb870c8" />
<option name="launcherType" value="OSDefault" />
<option name="newPlayerInstance" value="false" />
<option name="playerPath" value="/Applications/Flash Player Debugger.app" />
</LauncherParameters>
</option>
<option name="mobileRunTarget" value="Emulator" />
<option name="moduleName" value="" />
<option name="overriddenMainClass" value="" />
<option name="overriddenOutputFileName" value="" />
<option name="overrideMainClass" value="false" />
<option name="runTrusted" value="true" />
<option name="screenDpi" value="0" />
<option name="screenHeight" value="0" />
<option name="screenWidth" value="0" />
<option name="url" value="http://" />
<option name="usbDebugPort" value="7936" />
<method />
</configuration>
<configuration default="true" type="DartUnitRunConfigurationType" factoryName="DartUnit">
<method />
</configuration>
<configuration default="true" type="AndroidTestRunConfigurationType" factoryName="Android Tests">
<module name="" />
<option name="TESTING_TYPE" value="0" />
<option name="INSTRUMENTATION_RUNNER_CLASS" value="" />
<option name="METHOD_NAME" value="" />
<option name="CLASS_NAME" value="" />
<option name="PACKAGE_NAME" value="" />
<option name="TARGET_SELECTION_MODE" value="EMULATOR" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<option name="USE_COMMAND_LINE" value="true" />
<option name="COMMAND_LINE" value="" />
<option name="WIPE_USER_DATA" value="false" />
<option name="DISABLE_BOOT_ANIMATION" value="false" />
<option name="NETWORK_SPEED" value="full" />
<option name="NETWORK_LATENCY" value="none" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="true" />
<option name="FILTER_LOGCAT_AUTOMATICALLY" value="true" />
<method />
</configuration>
<configuration default="true" type="BashConfigurationType" factoryName="Bash">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="INTERPRETER_PATH" value="/bin/bash" />
<option name="WORKING_DIRECTORY" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SCRIPT_NAME" value="" />
<option name="PARAMETERS" value="" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="JarApplication" factoryName="JAR Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<envs />
<method />
</configuration>
<configuration default="true" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list />
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<method />
</configuration>
<configuration default="true" type="FlexUnitRunConfigurationType" factoryName="FlexUnit" appDescriptorForEmulator="Android" class_name="" emulatorAdlOptions="" method_name="" package_name="" scope="Class">
<option name="BCName" value="" />
<option name="launcherParameters">
<LauncherParameters>
<option name="browser" value="a7bb68e0-33c0-4d6f-a81a-aac1fdb870c8" />
<option name="launcherType" value="OSDefault" />
<option name="newPlayerInstance" value="false" />
<option name="playerPath" value="/Applications/Flash Player Debugger.app" />
</LauncherParameters>
</option>
<option name="moduleName" value="" />
<option name="trusted" value="true" />
<method />
</configuration>
<configuration default="true" type="CucumberJavaRunConfigurationType" factoryName="Cucumber java">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="myFilePath" />
<option name="GLUE" />
<option name="myNameFilter" />
<option name="myGeneratedName" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="AndroidRunConfigurationType" factoryName="Android Application">
<module name="" />
<option name="ACTIVITY_CLASS" value="" />
<option name="MODE" value="default_activity" />
<option name="DEPLOY" value="true" />
<option name="ARTIFACT_NAME" value="" />
<option name="TARGET_SELECTION_MODE" value="EMULATOR" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<option name="USE_COMMAND_LINE" value="true" />
<option name="COMMAND_LINE" value="" />
<option name="WIPE_USER_DATA" value="false" />
<option name="DISABLE_BOOT_ANIMATION" value="false" />
<option name="NETWORK_SPEED" value="full" />
<option name="NETWORK_LATENCY" value="none" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="true" />
<option name="FILTER_LOGCAT_AUTOMATICALLY" value="true" />
<method />
</configuration>
<list size="0" />
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
<Port>5050</Port>
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<recycled_changelist date="1422496156278">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/CRLF_fix.patch" />
<option name="DESCRIPTION" value="CRLF fix" />
</recycled_changelist>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="8b19802c-3945-406b-93d9-3f02a5f17aac" name="Default" comment="" />
<created>1422476791050</created>
<option name="number" value="Default" />
<updated>1422476791050</updated>
<workItem from="1422476791535" duration="30000" />
<workItem from="1422484167061" duration="14470000" />
</task>
<task id="LOCAL-00001" summary="#30 Push all buffered lines asynchronously before calling done()">
<created>1422484793683</created>
<option name="number" value="00001" />
<option name="project" value="LOCAL" />
<updated>1422484793683</updated>
</task>
<task id="LOCAL-00002" summary="#21 Support for old-style streams when encoding is unspecified">
<created>1422491307840</created>
<option name="number" value="00002" />
<option name="project" value="LOCAL" />
<updated>1422491307841</updated>
</task>
<task id="LOCAL-00003" summary="CRLF fix">
<created>1422496156805</created>
<option name="number" value="00003" />
<option name="project" value="LOCAL" />
<updated>1422496156805</updated>
</task>
<task id="LOCAL-00004" summary="Fix old-stlye stream test">
<created>1422496240971</created>
<option name="number" value="00004" />
<option name="project" value="LOCAL" />
<updated>1422496240971</updated>
</task>
<task id="LOCAL-00005" summary="#23 Don't split CRLF which spans two chunks">
<created>1422496703026</created>
<option name="number" value="00005" />
<option name="project" value="LOCAL" />
<updated>1422496703026</updated>
</task>
<task id="LOCAL-00006" summary="Added v0.10 streams2 API details and test">
<created>1422497710435</created>
<option name="number" value="00006" />
<option name="project" value="LOCAL" />
<updated>1422497710435</updated>
</task>
<task id="LOCAL-00007" summary="Use byline.js as the main module">
<created>1422498151277</created>
<option name="number" value="00007" />
<option name="project" value="LOCAL" />
<updated>1422498151277</updated>
</task>
<task id="LOCAL-00008" summary="Update copyright">
<created>1422498250062</created>
<option name="number" value="00008" />
<option name="project" value="LOCAL" />
<updated>1422498250062</updated>
</task>
<task id="LOCAL-00009" summary="Update copyright year">
<created>1422498379004</created>
<option name="number" value="00009" />
<option name="project" value="LOCAL" />
<updated>1422498379004</updated>
</task>
<task id="LOCAL-00010" summary="Fix alignment">
<created>1422498387185</created>
<option name="number" value="00010" />
<option name="project" value="LOCAL" />
<updated>1422498387185</updated>
</task>
<task id="LOCAL-00011" summary="Improve the README">
<created>1422499189524</created>
<option name="number" value="00011" />
<option name="project" value="LOCAL" />
<updated>1422499189524</updated>
</task>
<task id="LOCAL-00012" summary="Improve the README">
<created>1422499327833</created>
<option name="number" value="00012" />
<option name="project" value="LOCAL" />
<updated>1422499327833</updated>
</task>
<task id="LOCAL-00013" summary="Fix markdown for npm">
<created>1422500581638</created>
<option name="number" value="00013" />
<option name="project" value="LOCAL" />
<updated>1422500581638</updated>
</task>
<option name="localTasksCounter" value="14" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="14500000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1680" height="979" extended-state="0" />
<editor active="false" />
<layout>
<window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Changes" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.33032694" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Run with VisualVM" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Debug with VisualVM" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.23260073" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration">
<option name="myTodoPanelSettings">
<TodoPanelSettings />
</option>
<MESSAGE value="#30 Push all buffered lines asynchronously before calling done()" />
<MESSAGE value="#21 Support for old-style streams when encoding is unspecified" />
<MESSAGE value="CRLF fix" />
<MESSAGE value="Fix old-stlye stream test" />
<MESSAGE value="#23 Don't split CRLF which spans two chunks" />
<MESSAGE value="Added v0.10 streams2 API details and test" />
<MESSAGE value="Use byline.js as the main module" />
<MESSAGE value="Update copyright" />
<MESSAGE value="Update copyright year" />
<MESSAGE value="Fix alignment" />
<MESSAGE value="Improve the README" />
<MESSAGE value="Fix markdown for npm" />
<option name="LAST_COMMIT_MESSAGE" value="Fix markdown for npm" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="1" />
</breakpoint-manager>
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/lib/byline.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="2718">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/tests.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="3906">
<caret line="0" column="26" selection-start-line="0" selection-start-column="26" selection-end-line="0" selection-end-column="26" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/byline.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="2844">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-9.333333" vertical-offset="0" max-vertical-offset="576">
<caret line="14" column="14" selection-start-line="14" selection-start-column="14" selection-end-line="14" selection-end-column="14" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LICENSE">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-10.8" vertical-offset="0" max-vertical-offset="432">
<caret line="18" column="16" selection-start-line="18" selection-start-column="16" selection-end-line="18" selection-end-column="16" />
<folding />
</state>
</provider>
<provider editor-type-id="com.intellij.database.editor.CsvTableFileEditorProvider">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.06716418" vertical-offset="0" max-vertical-offset="2736">
<caret line="2" column="0" selection-start-line="2" selection-start-column="0" selection-end-line="2" selection-end-column="0" />
<folding />
</state>
</provider>
<provider editor-type-id="MarkdownPreviewEditor">
<state />
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<last-edited>Detection</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<last-edited>Dart SDK</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>JDK 1.6</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>node-byline</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>JDK 1.7</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

2
node_modules/byline/.npmignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
.DS_Store
node_modules

19
node_modules/byline/LICENSE generated vendored Normal file
View File

@ -0,0 +1,19 @@
node-byline (C) 2011-2015 John Hewson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

146
node_modules/byline/README.md generated vendored Normal file
View File

@ -0,0 +1,146 @@
# byline — buffered stream for reading lines
![npm package](https://nodei.co/npm/byline.png?downloads=true&downloadRank=true)
`byline` is a simple module providing a `LineStream`.
- node v0.10 `streams2` (transform stream)
- supports `pipe`
- supports both UNIX and Windows line endings
- can wrap any readable stream
- can be used as a readable-writable "through-stream" (transform stream)
- super-simple: `stream = byline(stream);`
## Install
npm install byline
or from source:
git clone git://github.com/jahewson/node-byline.git
cd node-byline
npm link
# Convenience API
The `byline` module can be used as a function to quickly wrap a readable stream:
```javascript
var fs = require('fs'),
byline = require('byline');
var stream = byline(fs.createReadStream('sample.txt', { encoding: 'utf8' }));
```
The `data` event then emits lines:
```javascript
stream.on('data', function(line) {
console.log(line);
});
```
# Standard API
You just need to add one line to wrap your readable `Stream` with a `LineStream`.
```javascript
var fs = require('fs'),
byline = require('byline');
var stream = fs.createReadStream('sample.txt');
stream = byline.createStream(stream);
stream.on('data', function(line) {
console.log(line);
});
```
# Piping
`byline` supports `pipe` (though it strips the line endings, of course).
```javascript
var stream = fs.createReadStream('sample.txt');
stream = byline.createStream(stream);
stream.pipe(fs.createWriteStream('nolines.txt'));
```
Alternatively, you can create a readable/writable "through-stream" which doesn't wrap any specific
stream:
```javascript
var stream = fs.createReadStream('sample.txt');
stream = byline.createStream(stream);
stream.pipe(fs.createWriteStream('nolines.txt'));
var input = fs.createReadStream('LICENSE');
var lineStream = byline.createStream();
input.pipe(lineStream);
var output = fs.createWriteStream('test.txt');
lineStream.pipe(output);
```
# Streams2 API
Node v0.10 added a new streams2 API. This allows the stream to be used in non-flowing mode and is
preferred over the legacy pause() and resume() methods.
```javascript
var stream = fs.createReadStream('sample.txt');
stream = byline.createStream(stream);
stream.on('readable', function() {
var line;
while (null !== (line = stream.read())) {
console.log(line);
}
});
```
# Transform Stream
The `byline` transform stream can be directly manipulated like so:
```javascript
var LineStream = require('byline').LineStream;
var input = fs.createReadStream('sample.txt');
var output = fs.createWriteStream('nolines.txt');
var lineStream = new LineStream();
input.pipe(lineStream);
lineStream.pipe(output);
```
# Empty Lines
By default byline skips empty lines, if you want to keep them, pass the `keepEmptyLines` option in
the call to `byline.createStream(stream, options)` or `byline(stream, options)`.
# Tests
npm test
# v0.8
If you want to use `node-byline` with node v0.8 then you can use the 2.1.x series. Simply use the
following in your `package.json`:
```javascript
"dependencies": {
"byline": ">=2.1.0 <3.0.0"
},
```
# Simple
Unlike other modules (of which there are many), `byline` contains no:
- monkeypatching
- dependencies
- non-standard 'line' events which break `pipe`
- limitations to only file streams
- CoffeeScript
- unnecessary code

152
node_modules/byline/lib/byline.js generated vendored Normal file
View File

@ -0,0 +1,152 @@
// Copyright (C) 2011-2015 John Hewson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
var stream = require('stream'),
util = require('util');
// convinience API
module.exports = function(readStream, options) {
return module.exports.createStream(readStream, options);
};
// basic API
module.exports.createStream = function(readStream, options) {
if (readStream) {
return createLineStream(readStream, options);
} else {
return new LineStream(options);
}
};
// deprecated API
module.exports.createLineStream = function(readStream) {
console.log('WARNING: byline#createLineStream is deprecated and will be removed soon');
return createLineStream(readStream);
};
function createLineStream(readStream, options) {
if (!readStream) {
throw new Error('expected readStream');
}
if (!readStream.readable) {
throw new Error('readStream must be readable');
}
var ls = new LineStream(options);
readStream.pipe(ls);
return ls;
}
//
// using the new node v0.10 "streams2" API
//
module.exports.LineStream = LineStream;
function LineStream(options) {
stream.Transform.call(this, options);
options = options || {};
// use objectMode to stop the output from being buffered
// which re-concatanates the lines, just without newlines.
this._readableState.objectMode = true;
this._lineBuffer = [];
this._keepEmptyLines = options.keepEmptyLines || false;
this._lastChunkEndedWithCR = false;
// take the source's encoding if we don't have one
this.on('pipe', function(src) {
if (!this.encoding) {
// but we can't do this for old-style streams
if (src instanceof stream.Readable) {
this.encoding = src._readableState.encoding;
}
}
});
}
util.inherits(LineStream, stream.Transform);
LineStream.prototype._transform = function(chunk, encoding, done) {
// decode binary chunks as UTF-8
encoding = encoding || 'utf8';
if (Buffer.isBuffer(chunk)) {
if (encoding == 'buffer') {
chunk = chunk.toString(); // utf8
encoding = 'utf8';
}
else {
chunk = chunk.toString(encoding);
}
}
this._chunkEncoding = encoding;
var lines = chunk.split(/\r\n|\r|\n/g);
// don't split CRLF which spans chunks
if (this._lastChunkEndedWithCR && chunk[0] == '\n') {
lines.shift();
}
if (this._lineBuffer.length > 0) {
this._lineBuffer[this._lineBuffer.length - 1] += lines[0];
lines.shift();
}
this._lastChunkEndedWithCR = chunk[chunk.length - 1] == '\r';
this._lineBuffer = this._lineBuffer.concat(lines);
this._pushBuffer(encoding, 1, done);
};
LineStream.prototype._pushBuffer = function(encoding, keep, done) {
// always buffer the last (possibly partial) line
while (this._lineBuffer.length > keep) {
var line = this._lineBuffer.shift();
// skip empty lines
if (this._keepEmptyLines || line.length > 0 ) {
if (!this.push(this._reencode(line, encoding))) {
// when the high-water mark is reached, defer pushes until the next tick
var self = this;
setImmediate(function() {
self._pushBuffer(encoding, keep, done);
});
return;
}
}
}
done();
};
LineStream.prototype._flush = function(done) {
this._pushBuffer(this._chunkEncoding, 0, done);
};
// see Readable::push
LineStream.prototype._reencode = function(line, chunkEncoding) {
if (this.encoding && this.encoding != chunkEncoding) {
return new Buffer(line, chunkEncoding).toString(this.encoding);
}
else if (this.encoding) {
// this should be the most common case, i.e. we're using an encoded source stream
return line;
}
else {
return new Buffer(line, chunkEncoding);
}
};

50
node_modules/byline/package.json generated vendored Normal file
View File

@ -0,0 +1,50 @@
{
"name": "byline",
"description": "simple line-by-line stream reader",
"homepage": "https://github.com/jahewson/node-byline",
"bugs": {
"url": "https://github.com/jahewson/node-byline/issues"
},
"version": "4.2.1",
"author": {
"name": "John Hewson"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/jahewson/node-byline"
},
"engines": {
"node": ">=0.10.0"
},
"main": "./lib/byline.js",
"devDependencies": {
"mocha": "~2.1.0",
"request": "~2.27.0"
},
"scripts": {
"test": "mocha -R spec --timeout 60000"
},
"gitHead": "188a2591657f7acd4fc44100576f4b4ec2ae7ae7",
"_id": "byline@4.2.1",
"_shasum": "f74a66fa6d8feff88b2725e0b2b0cf830cdf3f86",
"_from": "byline@*",
"_npmVersion": "2.3.0",
"_nodeVersion": "0.10.36",
"_npmUser": {
"name": "jahewson",
"email": "john@jahewson.com"
},
"maintainers": [
{
"name": "jahewson",
"email": "johnahewson@yahoo.co.uk"
}
],
"dist": {
"shasum": "f74a66fa6d8feff88b2725e0b2b0cf830cdf3f86",
"tarball": "https://registry.npmjs.org/byline/-/byline-4.2.1.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/byline/-/byline-4.2.1.tgz"
}

2
node_modules/byline/test/CRLF.txt generated vendored Normal file

File diff suppressed because one or more lines are too long

6
node_modules/byline/test/empty.txt generated vendored Normal file
View File

@ -0,0 +1,6 @@
Line 6

9859
node_modules/byline/test/rfc.txt generated vendored Normal file

File diff suppressed because it is too large Load Diff

19718
node_modules/byline/test/rfc_huge.txt generated vendored Normal file

File diff suppressed because it is too large Load Diff

212
node_modules/byline/test/tests.js generated vendored Normal file
View File

@ -0,0 +1,212 @@
// Copyright (C) 2013-2015 John Hewson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
var assert = require("assert"),
fs = require('fs'),
byline = require('../lib/byline'),
request = require('request');
describe('byline', function() {
it('should pipe a small file', function(done) {
var input = fs.createReadStream('LICENSE');
var lineStream = byline(input); // convinience API
var output = fs.createWriteStream('test.txt');
lineStream.pipe(output);
output.on('close', function() {
var out = fs.readFileSync('test.txt', 'utf8');
var in_ = fs.readFileSync('LICENSE', 'utf8').replace(/\n/g, '');
assert.equal(in_, out);
fs.unlinkSync('test.txt');
done();
});
});
it('should work with streams2 API', function(done) {
var stream = fs.createReadStream('LICENSE');
stream = byline.createStream(stream);
stream.on('readable', function() {
var line;
while (null !== (line = stream.read())) {
}
});
stream.on('end', function() {
done();
});
});
it('should ignore empty lines by default', function(done) {
var input = fs.createReadStream('test/empty.txt');
var lineStream = byline(input);
lineStream.setEncoding('utf8');
var lines1 = [];
lineStream.on('data', function(line) {
lines1.push(line);
});
lineStream.on('end', function() {
var lines2 = fs.readFileSync('test/empty.txt', 'utf8').split(/\r\n|\r|\n/g);
lines2 = lines2.filter(function(line) {
return line.length > 0;
});
assert.deepEqual(lines2, lines1);
done();
});
});
it('should keep empty lines when keepEmptyLines is true', function(done) {
var input = fs.createReadStream('test/empty.txt');
var lineStream = byline(input, { keepEmptyLines: true });
lineStream.setEncoding('utf8');
var lines = [];
lineStream.on('data', function(line) {
lines.push(line);
});
lineStream.on('end', function() {
assert.deepEqual([ '', '', '', '', '', 'Line 6' ], lines);
done();
});
});
it('should not split a CRLF which spans two chunks', function(done) {
var input = fs.createReadStream('test/CRLF.txt');
var lineStream = byline(input, { keepEmptyLines: true });
lineStream.setEncoding('utf8');
var lines = [];
lineStream.on('data', function(line) {
lines.push(line);
});
lineStream.on('end', function() {
assert.equal(2, lines.length);
done();
});
});
it('should read a large file', function(done) {
readFile('test/rfc.txt', done);
});
it('should read a huge file', function(done) {
// Readable highWaterMark is 16384, so we test a file with more lines than this
readFile('test/rfc_huge.txt', done);
});
function readFile(filename, done) {
var input = fs.createReadStream(filename);
var lineStream = byline(input);
lineStream.setEncoding('utf8');
var lines2 = fs.readFileSync(filename, 'utf8').split(/\r\n|\r|\n/g);
lines2 = lines2.filter(function(line) {
return line.length > 0;
});
var lines1 = [];
var i = 0;
lineStream.on('data', function(line) {
lines1.push(line);
if (line != lines2[i]) {
console.log('EXPECTED:', lines2[i]);
console.log(' GOT:', line);
assert.fail(null, null, 'difference at line ' + (i + 1));
}
i++;
});
lineStream.on('end', function() {
assert.equal(lines2.length, lines1.length);
assert.deepEqual(lines2, lines1);
done();
});
}
it('should handle encodings like fs', function(done) {
areStreamsEqualTypes(null, function() {
areStreamsEqualTypes({ encoding: 'utf8' }, function() {
done();
});
});
});
it('should work with old-style streams', function(done) {
var stream = byline(request.get('http://www.google.com'));
stream.on('data',function (data) {
});
stream.on('end',function () {
done();
});
});
it('should pause() and resume() with a huge file', function(done) {
var input = fs.createReadStream('test/rfc_huge.txt');
var lineStream = byline(input);
lineStream.setEncoding('utf8');
var lines2 = fs.readFileSync('test/rfc_huge.txt', 'utf8').split(/\r\n|\r|\n/g);
lines2 = lines2.filter(function(line) {
return line.length > 0;
});
var lines1 = [];
var i = 0;
lineStream.on('data', function(line) {
lines1.push(line);
if (line != lines2[i]) {
console.log('EXPECTED:', lines2[i]);
console.log(' GOT:', line);
assert.fail(null, null, 'difference at line ' + (i + 1));
}
i++;
// pause/resume
lineStream.pause();
setTimeout(function() {
lineStream.resume();
}, 0);
});
lineStream.on('end', function() {
assert.equal(lines2.length, lines1.length);
assert.deepEqual(lines2, lines1);
done();
});
});
function areStreamsEqualTypes(options, callback) {
var fsStream = fs.createReadStream('LICENSE', options);
var lineStream = byline(fs.createReadStream('LICENSE', options));
fsStream.on('data', function(data1) {
lineStream.on('data', function(data2) {
assert.equal(Buffer.isBuffer(data1), Buffer.isBuffer(data2));
});
lineStream.on('end', function() {
callback();
});
});
}
});

57
node_modules/dateformat/.npmignore generated vendored Normal file
View File

@ -0,0 +1,57 @@
# .gitignore <https://github.com/tunnckoCore/dotfiles>
#
# Copyright (c) 2014 Charlike Mike Reagent, contributors.
# Released under the MIT license.
#
# Always-ignore dirs #
# ####################
_gh_pages
node_modules
bower_components
components
vendor
build
dest
dist
src
lib-cov
coverage
nbproject
cache
temp
tmp
# Packages #
# ##########
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# OS, Logs and databases #
# #########################
*.pid
*.dat
*.log
*.sql
*.sqlite
*~
~*
# Another files #
# ###############
Icon?
.DS_Store*
Thumbs.db
ehthumbs.db
Desktop.ini
npm-debug.log
.directory
._*
koa-better-body

4
node_modules/dateformat/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,4 @@
language: node_js
node_js:
- "0.11"
- "0.10"

20
node_modules/dateformat/LICENSE generated vendored Normal file
View File

@ -0,0 +1,20 @@
(c) 2007-2009 Steven Levithan <stevenlevithan.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

82
node_modules/dateformat/Readme.md generated vendored Normal file
View File

@ -0,0 +1,82 @@
# dateformat
A node.js package for Steven Levithan's excellent [dateFormat()][dateformat] function.
[![Build Status](https://travis-ci.org/felixge/node-dateformat.svg)](https://travis-ci.org/felixge/node-dateformat)
## Modifications
* Removed the `Date.prototype.format` method. Sorry folks, but extending native prototypes is for suckers.
* Added a `module.exports = dateFormat;` statement at the bottom
* Added the placeholder `N` to get the ISO 8601 numeric representation of the day of the week
## Installation
```bash
$ npm install dateformat
$ dateformat --help
```
## Usage
As taken from Steven's post, modified to match the Modifications listed above:
```js
var dateFormat = require('dateformat');
var now = new Date();
// Basic usage
dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");
// Saturday, June 9th, 2007, 5:46:21 PM
// You can use one of several named masks
dateFormat(now, "isoDateTime");
// 2007-06-09T17:46:21
// ...Or add your own
dateFormat.masks.hammerTime = 'HH:MM! "Can\'t touch this!"';
dateFormat(now, "hammerTime");
// 17:46! Can't touch this!
// When using the standalone dateFormat function,
// you can also provide the date as a string
dateFormat("Jun 9 2007", "fullDate");
// Saturday, June 9, 2007
// Note that if you don't include the mask argument,
// dateFormat.masks.default is used
dateFormat(now);
// Sat Jun 09 2007 17:46:21
// And if you don't include the date argument,
// the current date and time is used
dateFormat();
// Sat Jun 09 2007 17:46:22
// You can also skip the date argument (as long as your mask doesn't
// contain any numbers), in which case the current date/time is used
dateFormat("longTime");
// 5:46:22 PM EST
// And finally, you can convert local time to UTC time. Simply pass in
// true as an additional argument (no argument skipping allowed in this case):
dateFormat(now, "longTime", true);
// 10:46:21 PM UTC
// ...Or add the prefix "UTC:" or "GMT:" to your mask.
dateFormat(now, "UTC:h:MM:ss TT Z");
// 10:46:21 PM UTC
// You can also get the ISO 8601 week of the year:
dateFormat(now, "W");
// 42
// and also get the ISO 8601 numeric representation of the day of the week:
dateFormat(now,"N");
// 6
```
## License
(c) 2007-2009 Steven Levithan [stevenlevithan.com][stevenlevithan], MIT license.
[dateformat]: http://blog.stevenlevithan.com/archives/date-time-format
[stevenlevithan]: http://stevenlevithan.com/

75
node_modules/dateformat/bin/cli.js generated vendored Executable file
View File

@ -0,0 +1,75 @@
#!/usr/bin/env node
/**
* dateformat <https://github.com/felixge/node-dateformat>
*
* Copyright (c) 2014 Charlike Mike Reagent (cli), contributors.
* Released under the MIT license.
*/
'use strict';
/**
* Module dependencies.
*/
var dateFormat = require('../lib/dateformat');
var meow = require('meow');
var stdin = require('get-stdin');
var cli = meow({
pkg: '../package.json',
help: [
'Options',
' --help Show this help',
' --version Current version of package',
' -d | --date Date that want to format (Date object as Number or String)',
' -m | --mask Mask that will use to format the date',
' -u | --utc Convert local time to UTC time or use `UTC:` prefix in mask',
' -g | --gmt You can use `GMT:` prefix in mask',
'',
'Usage',
' dateformat [date] [mask]',
' dateformat "Nov 26 2014" "fullDate"',
' dateformat 1416985417095 "dddd, mmmm dS, yyyy, h:MM:ss TT"',
' dateformat 1315361943159 "W"',
' dateformat "UTC:h:MM:ss TT Z"',
' dateformat "longTime" true',
' dateformat "longTime" false true',
' dateformat "Jun 9 2007" "fullDate" true',
' date +%s | dateformat',
''
].join('\n')
})
var date = cli.input[0] || cli.flags.d || cli.flags.date || Date.now();
var mask = cli.input[1] || cli.flags.m || cli.flags.mask || dateFormat.masks.default;
var utc = cli.input[2] || cli.flags.u || cli.flags.utc || false;
var gmt = cli.input[3] || cli.flags.g || cli.flags.gmt || false;
utc = utc === 'true' ? true : false;
gmt = gmt === 'true' ? true : false;
if (!cli.input.length) {
stdin(function(date) {
console.log(dateFormat(date, dateFormat.masks.default, utc, gmt));
});
return;
}
if (cli.input.length === 1 && date) {
mask = date;
date = Date.now();
console.log(dateFormat(date, mask, utc, gmt));
return;
}
if (cli.input.length >= 2 && date && mask) {
if (mask === 'true' || mask === 'false') {
utc = mask === 'true' ? true : false;
gmt = !utc;
mask = date
date = Date.now();
}
console.log(dateFormat(date, mask, utc, gmt));
return;
}

226
node_modules/dateformat/lib/dateformat.js generated vendored Normal file
View File

@ -0,0 +1,226 @@
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
* MIT license
*
* Includes enhancements by Scott Trenda <scott.trenda.net>
* and Kris Kowal <cixar.com/~kris.kowal/>
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*/
(function(global) {
'use strict';
var dateFormat = (function() {
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|'[^']*'|'[^']*'/g;
var timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
var timezoneClip = /[^-+\dA-Z]/g;
// Regexes and supporting functions are cached through closure
return function (date, mask, utc, gmt) {
// You can't provide utc if you skip other args (use the 'UTC:' mask prefix)
if (arguments.length === 1 && kindOf(date) === 'string' && !/\d/.test(date)) {
mask = date;
date = undefined;
}
date = date || new Date;
if(!(date instanceof Date)) {
date = new Date(date);
}
if (isNaN(date)) {
throw TypeError('Invalid date');
}
mask = String(dateFormat.masks[mask] || mask || dateFormat.masks['default']);
// Allow setting the utc/gmt argument via the mask
var maskSlice = mask.slice(0, 4);
if (maskSlice === 'UTC:' || maskSlice === 'GMT:') {
mask = mask.slice(4);
utc = true;
if (maskSlice === 'GMT:') {
gmt = true;
}
}
var _ = utc ? 'getUTC' : 'get';
var d = date[_ + 'Date']();
var D = date[_ + 'Day']();
var m = date[_ + 'Month']();
var y = date[_ + 'FullYear']();
var H = date[_ + 'Hours']();
var M = date[_ + 'Minutes']();
var s = date[_ + 'Seconds']();
var L = date[_ + 'Milliseconds']();
var o = utc ? 0 : date.getTimezoneOffset();
var W = getWeek(date);
var N = getDayOfWeek(date);
var flags = {
d: d,
dd: pad(d),
ddd: dateFormat.i18n.dayNames[D],
dddd: dateFormat.i18n.dayNames[D + 7],
m: m + 1,
mm: pad(m + 1),
mmm: dateFormat.i18n.monthNames[m],
mmmm: dateFormat.i18n.monthNames[m + 12],
yy: String(y).slice(2),
yyyy: y,
h: H % 12 || 12,
hh: pad(H % 12 || 12),
H: H,
HH: pad(H),
M: M,
MM: pad(M),
s: s,
ss: pad(s),
l: pad(L, 3),
L: pad(Math.round(L / 10)),
t: H < 12 ? 'a' : 'p',
tt: H < 12 ? 'am' : 'pm',
T: H < 12 ? 'A' : 'P',
TT: H < 12 ? 'AM' : 'PM',
Z: gmt ? 'GMT' : utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''),
o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10],
W: W,
N: N
};
return mask.replace(token, function (match) {
if (match in flags) {
return flags[match];
}
return match.slice(1, match.length - 1);
});
};
})();
dateFormat.masks = {
'default': 'ddd mmm dd yyyy HH:MM:ss',
'shortDate': 'm/d/yy',
'mediumDate': 'mmm d, yyyy',
'longDate': 'mmmm d, yyyy',
'fullDate': 'dddd, mmmm d, yyyy',
'shortTime': 'h:MM TT',
'mediumTime': 'h:MM:ss TT',
'longTime': 'h:MM:ss TT Z',
'isoDate': 'yyyy-mm-dd',
'isoTime': 'HH:MM:ss',
'isoDateTime': 'yyyy-mm-dd\'T\'HH:MM:sso',
'isoUtcDateTime': 'UTC:yyyy-mm-dd\'T\'HH:MM:ss\'Z\'',
'expiresHeaderFormat': 'ddd, dd mmm yyyy HH:MM:ss Z'
};
// Internationalization strings
dateFormat.i18n = {
dayNames: [
'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
],
monthNames: [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
]
};
function pad(val, len) {
val = String(val);
len = len || 2;
while (val.length < len) {
val = '0' + val;
}
return val;
}
/**
* Get the ISO 8601 week number
* Based on comments from
* http://techblog.procurios.nl/k/n618/news/view/33796/14863/Calculate-ISO-8601-week-and-year-in-javascript.html
*
* @param {Object} `date`
* @return {Number}
*/
function getWeek(date) {
// Remove time components of date
var targetThursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
// Change date to Thursday same week
targetThursday.setDate(targetThursday.getDate() - ((targetThursday.getDay() + 6) % 7) + 3);
// Take January 4th as it is always in week 1 (see ISO 8601)
var firstThursday = new Date(targetThursday.getFullYear(), 0, 4);
// Change date to Thursday same week
firstThursday.setDate(firstThursday.getDate() - ((firstThursday.getDay() + 6) % 7) + 3);
// Check if daylight-saving-time-switch occured and correct for it
var ds = targetThursday.getTimezoneOffset() - firstThursday.getTimezoneOffset();
targetThursday.setHours(targetThursday.getHours() - ds);
// Number of weeks between target Thursday and first Thursday
var weekDiff = (targetThursday - firstThursday) / (86400000*7);
return 1 + Math.floor(weekDiff);
}
/**
* Get ISO-8601 numeric representation of the day of the week
* 1 (for Monday) through 7 (for Sunday)
*
* @param {Object} `date`
* @return {Number}
*/
function getDayOfWeek(date) {
var dow = date.getDay();
if(dow === 0) {
dow = 7;
}
return dow;
}
/**
* kind-of shortcut
* @param {*} val
* @return {String}
*/
function kindOf(val) {
if (val === null) {
return 'null';
}
if (val === undefined) {
return 'undefined';
}
if (typeof val !== 'object') {
return typeof val;
}
if (Array.isArray(val)) {
return 'array';
}
return {}.toString.call(val)
.slice(8, -1).toLowerCase();
};
if (typeof define === 'function' && define.amd) {
define(function () {
return dateFormat;
});
} else if (typeof exports === 'object') {
module.exports = dateFormat;
} else {
global.dateFormat = dateFormat;
}
})(this);

View File

@ -0,0 +1,49 @@
'use strict';
module.exports = function (cb) {
var stdin = process.stdin;
var ret = '';
if (stdin.isTTY) {
setImmediate(cb, '');
return;
}
stdin.setEncoding('utf8');
stdin.on('readable', function () {
var chunk;
while (chunk = stdin.read()) {
ret += chunk;
}
});
stdin.on('end', function () {
cb(ret);
});
};
module.exports.buffer = function (cb) {
var stdin = process.stdin;
var ret = [];
var len = 0;
if (stdin.isTTY) {
setImmediate(cb, new Buffer(''));
return;
}
stdin.on('readable', function () {
var chunk;
while (chunk = stdin.read()) {
ret.push(chunk);
len += chunk.length;
}
});
stdin.on('end', function () {
cb(Buffer.concat(ret, len));
});
};

View File

@ -0,0 +1,63 @@
{
"name": "get-stdin",
"version": "4.0.1",
"description": "Easier stdin",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/sindresorhus/get-stdin"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "node test.js && node test-buffer.js && echo unicorns | node test-real.js"
},
"files": [
"index.js"
],
"keywords": [
"std",
"stdin",
"stdio",
"concat",
"buffer",
"stream",
"process",
"stream"
],
"devDependencies": {
"ava": "0.0.4",
"buffer-equal": "0.0.1"
},
"gitHead": "65c744975229b25d6cc5c7546f49b6ad9099553f",
"bugs": {
"url": "https://github.com/sindresorhus/get-stdin/issues"
},
"homepage": "https://github.com/sindresorhus/get-stdin",
"_id": "get-stdin@4.0.1",
"_shasum": "b968c6b0a04384324902e8bf1a5df32579a450fe",
"_from": "get-stdin@^4.0.1",
"_npmVersion": "1.4.28",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "b968c6b0a04384324902e8bf1a5df32579a450fe",
"tarball": "http://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz"
}

View File

@ -0,0 +1,44 @@
# get-stdin [![Build Status](https://travis-ci.org/sindresorhus/get-stdin.svg?branch=master)](https://travis-ci.org/sindresorhus/get-stdin)
> Easier stdin
## Install
```sh
$ npm install --save get-stdin
```
## Usage
```js
// example.js
var stdin = require('get-stdin');
stdin(function (data) {
console.log(data);
//=> unicorns
});
```
```sh
$ echo unicorns | node example.js
unicorns
```
## API
### stdin(callback)
Get `stdin` as a string.
### stdin.buffer(callback)
Get `stdin` as a buffer.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

82
node_modules/dateformat/node_modules/meow/index.js generated vendored Normal file
View File

@ -0,0 +1,82 @@
'use strict';
var path = require('path');
var minimist = require('minimist');
var objectAssign = require('object-assign');
var camelcaseKeys = require('camelcase-keys');
var decamelize = require('decamelize');
var mapObj = require('map-obj');
var trimNewlines = require('trim-newlines');
var redent = require('redent');
var readPkgUp = require('read-pkg-up');
var loudRejection = require('loud-rejection');
var normalizePackageData = require('normalize-package-data');
// get the uncached parent
delete require.cache[__filename];
var parentDir = path.dirname(module.parent.filename);
module.exports = function (opts, minimistOpts) {
loudRejection();
if (Array.isArray(opts) || typeof opts === 'string') {
opts = {help: opts};
}
opts = objectAssign({
pkg: readPkgUp.sync({
cwd: parentDir,
normalize: false
}).pkg,
argv: process.argv.slice(2)
}, opts);
minimistOpts = objectAssign({}, minimistOpts);
minimistOpts.default = mapObj(minimistOpts.default || {}, function (key, value) {
return [decamelize(key, '-'), value];
});
if (Array.isArray(opts.help)) {
opts.help = opts.help.join('\n');
}
var pkg = typeof opts.pkg === 'string' ? require(path.join(parentDir, opts.pkg)) : opts.pkg;
var argv = minimist(opts.argv, minimistOpts);
var help = redent(trimNewlines(opts.help || ''), 2);
normalizePackageData(pkg);
process.title = pkg.bin ? Object.keys(pkg.bin)[0] : pkg.name;
var description = opts.description;
if (!description && description !== false) {
description = pkg.description;
}
help = (description ? '\n ' + description + '\n' : '') + (help ? '\n' + help : '\n');
var showHelp = function (code) {
console.log(help);
process.exit(code || 0);
};
if (argv.version && opts.version !== false) {
console.log(typeof opts.version === 'string' ? opts.version : pkg.version);
process.exit();
}
if (argv.help && opts.help !== false) {
showHelp();
}
var _ = argv._;
delete argv._;
return {
input: _,
flags: camelcaseKeys(argv),
pkg: pkg,
help: help,
showHelp: showHelp
};
};

21
node_modules/dateformat/node_modules/meow/license generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,12 @@
'use strict';
var mapObj = require('map-obj');
var camelCase = require('camelcase');
module.exports = function (input, options) {
options = options || {};
var exclude = options.exclude || [];
return mapObj(input, function (key, val) {
key = exclude.indexOf(key) === -1 ? camelCase(key) : key;
return [key, val];
});
};

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,56 @@
'use strict';
function preserveCamelCase(str) {
var isLastCharLower = false;
for (var i = 0; i < str.length; i++) {
var c = str.charAt(i);
if (isLastCharLower && (/[a-zA-Z]/).test(c) && c.toUpperCase() === c) {
str = str.substr(0, i) + '-' + str.substr(i);
isLastCharLower = false;
i++;
} else {
isLastCharLower = (c.toLowerCase() === c);
}
}
return str;
}
module.exports = function () {
var str = [].map.call(arguments, function (str) {
return str.trim();
}).filter(function (str) {
return str.length;
}).join('-');
if (!str.length) {
return '';
}
if (str.length === 1) {
return str;
}
if (!(/[_.\- ]+/).test(str)) {
if (str === str.toUpperCase()) {
return str.toLowerCase();
}
if (str[0] !== str[0].toLowerCase()) {
return str[0].toLowerCase() + str.slice(1);
}
return str;
}
str = preserveCamelCase(str);
return str
.replace(/^[_.\- ]+/, '')
.toLowerCase()
.replace(/[_.\- ]+(\w|$)/g, function (m, p1) {
return p1.toUpperCase();
});
};

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,72 @@
{
"name": "camelcase",
"version": "2.1.1",
"description": "Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/sindresorhus/camelcase"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"camelcase",
"camel-case",
"camel",
"case",
"dash",
"hyphen",
"dot",
"underscore",
"separator",
"string",
"text",
"convert"
],
"devDependencies": {
"ava": "*",
"xo": "*"
},
"gitHead": "35c9c8abce5b9cc9defe534ab25823dc6383180f",
"bugs": {
"url": "https://github.com/sindresorhus/camelcase/issues"
},
"homepage": "https://github.com/sindresorhus/camelcase",
"_id": "camelcase@2.1.1",
"_shasum": "7c1d16d679a1bbe59ca02cacecfb011e201f5a1f",
"_from": "camelcase@^2.0.0",
"_npmVersion": "2.14.12",
"_nodeVersion": "4.3.0",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "7c1d16d679a1bbe59ca02cacecfb011e201f5a1f",
"tarball": "http://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/camelcase-2.1.1.tgz_1457803836074_0.4515206723008305"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz"
}

View File

@ -0,0 +1,57 @@
# camelcase [![Build Status](https://travis-ci.org/sindresorhus/camelcase.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase)
> Convert a dash/dot/underscore/space separated string to camelCase: `foo-bar``fooBar`
## Install
```
$ npm install --save camelcase
```
## Usage
```js
const camelCase = require('camelcase');
camelCase('foo-bar');
//=> 'fooBar'
camelCase('foo_bar');
//=> 'fooBar'
camelCase('Foo-Bar');
//=> 'fooBar'
camelCase('--foo.bar');
//=> 'fooBar'
camelCase('__foo__bar__');
//=> 'fooBar'
camelCase('foo bar');
//=> 'fooBar'
console.log(process.argv[3]);
//=> '--foo-bar'
camelCase(process.argv[3]);
//=> 'fooBar'
camelCase('foo', 'bar');
//=> 'fooBar'
camelCase('__foo__', '--bar');
//=> 'fooBar'
```
## Related
- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,85 @@
{
"name": "camelcase-keys",
"version": "2.1.0",
"description": "Convert object keys to camelCase",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/sindresorhus/camelcase-keys"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"map",
"obj",
"object",
"key",
"keys",
"value",
"values",
"val",
"iterate",
"camelcase",
"camel-case",
"camel",
"case",
"dash",
"hyphen",
"dot",
"underscore",
"separator",
"string",
"text",
"convert"
],
"devDependencies": {
"ava": "*",
"xo": "*"
},
"dependencies": {
"camelcase": "^2.0.0",
"map-obj": "^1.0.0"
},
"gitHead": "d92dfb3b5eb2985d62839cdd44672f01139d1822",
"bugs": {
"url": "https://github.com/sindresorhus/camelcase-keys/issues"
},
"homepage": "https://github.com/sindresorhus/camelcase-keys",
"_id": "camelcase-keys@2.1.0",
"_shasum": "308beeaffdf28119051efa1d932213c91b8f92e7",
"_from": "camelcase-keys@^2.0.0",
"_npmVersion": "2.14.12",
"_nodeVersion": "4.3.0",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "308beeaffdf28119051efa1d932213c91b8f92e7",
"tarball": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"_npmOperationalInternal": {
"host": "packages-13-west.internal.npmjs.com",
"tmp": "tmp/camelcase-keys-2.1.0.tgz_1458051723517_0.14490422373637557"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz"
}

View File

@ -0,0 +1,54 @@
# camelcase-keys [![Build Status](https://travis-ci.org/sindresorhus/camelcase-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase-keys)
> Convert object keys to camelCase using [`camelcase`](https://github.com/sindresorhus/camelcase)
## Install
```
$ npm install --save camelcase-keys
```
## Usage
```js
const camelcaseKeys = require('camelcase-keys');
camelcaseKeys({'foo-bar': true});
//=> {fooBar: true}
const argv = require('minimist')(process.argv.slice(2));
//=> {_: [], 'foo-bar': true}
camelcaseKeys(argv);
//=> {_: [], fooBar: true}
```
## API
### camelcaseKeys(input, [options])
#### input
Type: `object`
Object to camelCase.
#### options
Type: `object`
##### exclude
Type: `array`
Default: `[]`
Exclude keys from being camelCased.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,13 @@
'use strict';
module.exports = function (str, sep) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
sep = typeof sep === 'undefined' ? '_' : sep;
return str
.replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
.toLowerCase();
};

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,71 @@
{
"name": "decamelize",
"version": "1.2.0",
"description": "Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/decamelize.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"decamelize",
"decamelcase",
"camelcase",
"lowercase",
"case",
"dash",
"hyphen",
"string",
"str",
"text",
"convert"
],
"devDependencies": {
"ava": "*",
"xo": "*"
},
"gitHead": "95980ab6fb44c40eaca7792bdf93aff7c210c805",
"bugs": {
"url": "https://github.com/sindresorhus/decamelize/issues"
},
"homepage": "https://github.com/sindresorhus/decamelize#readme",
"_id": "decamelize@1.2.0",
"_shasum": "f6534d15148269b20352e7bee26f501f9a191290",
"_from": "decamelize@^1.1.2",
"_npmVersion": "3.8.0",
"_nodeVersion": "4.3.0",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "f6534d15148269b20352e7bee26f501f9a191290",
"tarball": "http://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/decamelize-1.2.0.tgz_1457167749082_0.9810893186368048"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz"
}

View File

@ -0,0 +1,48 @@
# decamelize [![Build Status](https://travis-ci.org/sindresorhus/decamelize.svg?branch=master)](https://travis-ci.org/sindresorhus/decamelize)
> Convert a camelized string into a lowercased one with a custom separator<br>
> Example: `unicornRainbow``unicorn_rainbow`
## Install
```
$ npm install --save decamelize
```
## Usage
```js
const decamelize = require('decamelize');
decamelize('unicornRainbow');
//=> 'unicorn_rainbow'
decamelize('unicornRainbow', '-');
//=> 'unicorn-rainbow'
```
## API
### decamelize(input, [separator])
#### input
Type: `string`
#### separator
Type: `string`<br>
Default: `_`
## Related
See [`camelcase`](https://github.com/sindresorhus/camelcase) for the inverse.
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@ -0,0 +1,33 @@
'use strict';
var arrayFindIndex = require('array-find-index');
// WARNING: This undocumented API is subject to change.
module.exports = function (process) {
var unhandledRejections = [];
process.on('unhandledRejection', function (reason, p) {
unhandledRejections.push({reason: reason, promise: p});
});
process.on('rejectionHandled', function (p) {
var index = arrayFindIndex(unhandledRejections, function (x) {
return x.promise === p;
});
unhandledRejections.splice(index, 1);
});
function currentlyUnhandled() {
return unhandledRejections.map(function (entry) {
return {
reason: entry.reason,
promise: entry.promise
};
});
}
return {
currentlyUnhandled: currentlyUnhandled
};
};

View File

@ -0,0 +1,35 @@
'use strict';
var util = require('util');
var onExit = require('signal-exit');
var api = require('./api');
var installed = false;
function outputRejectedMessage(err) {
if (err instanceof Error) {
console.error(err.stack);
} else {
console.error('Promise rejected with value: ' + util.inspect(err));
}
}
module.exports = function () {
if (installed) {
return;
}
installed = true;
var tracker = api(process);
onExit(function () {
var unhandledRejections = tracker.currentlyUnhandled();
if (unhandledRejections.length > 0) {
unhandledRejections.forEach(function (x) {
outputRejectedMessage(x.reason);
});
process.exitCode = 1;
}
});
};

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,25 @@
'use strict';
module.exports = function (arr, predicate, ctx) {
if (typeof Array.prototype.findIndex === 'function') {
return arr.findIndex(predicate, ctx);
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(arr);
var len = list.length;
if (len === 0) {
return -1;
}
for (var i = 0; i < len; i++) {
if (predicate.call(ctx, list[i], i, list)) {
return i;
}
}
return -1;
};

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,65 @@
{
"name": "array-find-index",
"version": "1.0.1",
"description": "ES2015 `Array#findIndex()` ponyfill",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/sindresorhus/array-find-index"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"es6",
"es2015",
"ponyfill",
"polyfill",
"shim",
"find",
"index",
"findindex",
"array"
],
"devDependencies": {
"ava": "*",
"xo": "*"
},
"gitHead": "0b2eea2c3e42aeb97be82b50f64a5672d2847036",
"bugs": {
"url": "https://github.com/sindresorhus/array-find-index/issues"
},
"homepage": "https://github.com/sindresorhus/array-find-index",
"_id": "array-find-index@1.0.1",
"_shasum": "0bc25ddac941ec8a496ae258fd4ac188003ef3af",
"_from": "array-find-index@^1.0.0",
"_npmVersion": "2.14.12",
"_nodeVersion": "4.2.4",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "0bc25ddac941ec8a496ae258fd4ac188003ef3af",
"tarball": "http://registry.npmjs.org/array-find-index/-/array-find-index-1.0.1.tgz"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"directories": {},
"_resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.1.tgz"
}

View File

@ -0,0 +1,32 @@
# array-find-index [![Build Status](https://travis-ci.org/sindresorhus/array-find-index.svg?branch=master)](https://travis-ci.org/sindresorhus/array-find-index)
> ES2015 [`Array#findIndex()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) ponyfill
> Ponyfill: A polyfill that doesn't overwrite the native method
## Install
```
$ npm install --save array-find-index
```
## Usage
```js
arrayFindIndex = require('array-find-index');
arrayFindIndex(['rainbow', 'unicorn', 'pony'], x => x === 'unicorn');
//=> 1
```
## API
Same as `Array#findIndex()`, but with the input array as the first argument.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,4 @@
node_modules
.DS_Store
nyc_output
coverage

View File

@ -0,0 +1,7 @@
sudo: false
language: node_js
node_js:
- '0.12'
- '0.10'
- iojs
after_success: npm run coverage

View File

@ -0,0 +1,14 @@
Copyright (c) 2015, Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice
appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -0,0 +1,38 @@
# signal-exit
[![Build Status](https://travis-ci.org/bcoe/signal-exit.png)](https://travis-ci.org/bcoe/signal-exit)
[![Coverage Status](https://coveralls.io/repos/bcoe/signal-exit/badge.svg?branch=)](https://coveralls.io/r/bcoe/signal-exit?branch=)
[![NPM version](https://img.shields.io/npm/v/signal-exit.svg)](https://www.npmjs.com/package/signal-exit)
When you want to fire an event no matter how a process exits:
* reaching the end of execution.
* explicitly having `process.exit(code)` called.
* having `process.kill(pid, sig)` called.
* receiving a fatal signal from outside the process
Use `signal-exit`.
```js
var onExit = require('signal-exit')
onExit(function (code, signal) {
console.log('process exited!')
})
```
## API
`var remove = onExit(function (code, signal) {}, options)`
The return value of the function is a function that will remove the
handler.
Note that the function *only* fires for signals if the signal would
cause the proces to exit. That is, there are no other listeners, and
it is a fatal signal.
## Options
* `alwaysLast`: Run this handler after any other signal or exit
handlers. This causes `process.emit` to be monkeypatched.

View File

@ -0,0 +1,148 @@
// Note: since nyc uses this module to output coverage, any lines
// that are in the direct sync flow of nyc's outputCoverage are
// ignored, since we can never get coverage for them.
var assert = require('assert')
var signals = require('./signals.js')
var EE = require('events')
/* istanbul ignore if */
if (typeof EE !== 'function') {
EE = EE.EventEmitter
}
var emitter
if (process.__signal_exit_emitter__) {
emitter = process.__signal_exit_emitter__
} else {
emitter = process.__signal_exit_emitter__ = new EE()
emitter.count = 0
emitter.emitted = {}
}
module.exports = function (cb, opts) {
assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler')
if (loaded === false) {
load()
}
var ev = 'exit'
if (opts && opts.alwaysLast) {
ev = 'afterexit'
}
var remove = function () {
emitter.removeListener(ev, cb)
if (emitter.listeners('exit').length === 0 &&
emitter.listeners('afterexit').length === 0) {
unload()
}
}
emitter.on(ev, cb)
return remove
}
module.exports.unload = unload
function unload () {
if (!loaded) {
return
}
loaded = false
signals.forEach(function (sig) {
try {
process.removeListener(sig, sigListeners[sig])
} catch (er) {}
})
process.emit = originalProcessEmit
process.reallyExit = originalProcessReallyExit
emitter.count -= 1
}
function emit (event, code, signal) {
if (emitter.emitted[event]) {
return
}
emitter.emitted[event] = true
emitter.emit(event, code, signal)
}
// { <signal>: <listener fn>, ... }
var sigListeners = {}
signals.forEach(function (sig) {
sigListeners[sig] = function listener () {
// If there are no other listeners, an exit is coming!
// Simplest way: remove us and then re-send the signal.
// We know that this will kill the process, so we can
// safely emit now.
var listeners = process.listeners(sig)
if (listeners.length === emitter.count) {
unload()
emit('exit', null, sig)
/* istanbul ignore next */
emit('afterexit', null, sig)
/* istanbul ignore next */
process.kill(process.pid, sig)
}
}
})
module.exports.signals = function () {
return signals
}
module.exports.load = load
var loaded = false
function load () {
if (loaded) {
return
}
loaded = true
// This is the number of onSignalExit's that are in play.
// It's important so that we can count the correct number of
// listeners on signals, and don't wait for the other one to
// handle it instead of us.
emitter.count += 1
signals = signals.filter(function (sig) {
try {
process.on(sig, sigListeners[sig])
return true
} catch (er) {
return false
}
})
process.emit = processEmit
process.reallyExit = processReallyExit
}
var originalProcessReallyExit = process.reallyExit
function processReallyExit (code) {
process.exitCode = code || 0
emit('exit', process.exitCode, null)
/* istanbul ignore next */
emit('afterexit', process.exitCode, null)
/* istanbul ignore next */
originalProcessReallyExit.call(process, process.exitCode)
}
var originalProcessEmit = process.emit
function processEmit (ev, arg) {
if (ev === 'exit') {
if (arg !== undefined) {
process.exitCode = arg
}
var ret = originalProcessEmit.apply(this, arguments)
emit('exit', process.exitCode, null)
/* istanbul ignore next */
emit('afterexit', process.exitCode, null)
return ret
} else {
return originalProcessEmit.apply(this, arguments)
}
}

View File

@ -0,0 +1,60 @@
{
"name": "signal-exit",
"version": "2.1.2",
"description": "when you want to fire an event no matter how a process exits.",
"main": "index.js",
"scripts": {
"test": "standard && nyc tap --timeout=240 ./test/*.js",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bcoe/signal-exit.git"
},
"keywords": [
"signal",
"exit"
],
"author": {
"name": "Ben Coe",
"email": "ben@npmjs.com"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/bcoe/signal-exit/issues"
},
"homepage": "https://github.com/bcoe/signal-exit",
"devDependencies": {
"chai": "^2.3.0",
"coveralls": "^2.11.2",
"nyc": "^2.1.2",
"standard": "^3.9.0",
"tap": "1.0.4"
},
"gitHead": "8d50231bda6d0d1c4d39de20fc09d11487eb9951",
"_id": "signal-exit@2.1.2",
"_shasum": "375879b1f92ebc3b334480d038dc546a6d558564",
"_from": "signal-exit@^2.1.2",
"_npmVersion": "2.9.0",
"_nodeVersion": "2.0.2",
"_npmUser": {
"name": "bcoe",
"email": "ben@npmjs.com"
},
"dist": {
"shasum": "375879b1f92ebc3b334480d038dc546a6d558564",
"tarball": "http://registry.npmjs.org/signal-exit/-/signal-exit-2.1.2.tgz"
},
"maintainers": [
{
"name": "bcoe",
"email": "ben@npmjs.com"
},
{
"name": "isaacs",
"email": "isaacs@npmjs.com"
}
],
"directories": {},
"_resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-2.1.2.tgz"
}

View File

@ -0,0 +1,47 @@
// This is not the set of all possible signals.
//
// It IS, however, the set of all signals that trigger
// an exit on either Linux or BSD systems. Linux is a
// superset of the signal names supported on BSD, and
// the unknown signals just fail to register, so we can
// catch that easily enough.
//
// Don't bother with SIGKILL. It's uncatchable, which
// means that we can't fire any callbacks anyway.
//
// If a user does happen to register a handler on a non-
// fatal signal like SIGWINCH or something, and then
// exit, it'll end up firing `process.emit('exit')`, so
// the handler will be fired anyway.
module.exports = [
'SIGABRT',
'SIGALRM',
'SIGBUS',
'SIGFPE',
'SIGHUP',
'SIGILL',
'SIGINT',
'SIGIOT',
'SIGPIPE',
'SIGPROF',
'SIGQUIT',
'SIGSEGV',
'SIGSYS',
'SIGTERM',
'SIGTRAP',
'SIGUSR2',
'SIGVTALRM',
'SIGXCPU',
'SIGXFSZ'
]
if (process.platform === 'linux') {
module.exports.push(
'SIGIO',
'SIGPOLL',
'SIGPWR',
'SIGSTKFLT',
'SIGUNUSED'
)
}

View File

@ -0,0 +1,94 @@
/* global describe, it */
var exec = require('child_process').exec,
assert = require('assert')
require('chai').should()
require('tap').mochaGlobals()
var onSignalExit = require('../')
describe('all-signals-integration-test', function () {
// These are signals that are aliases for other signals, so
// the result will sometimes be one of the others. For these,
// we just verify that we GOT a signal, not what it is.
function weirdSignal (sig) {
return sig === 'SIGIOT' ||
sig === 'SIGIO' ||
sig === 'SIGSYS' ||
sig === 'SIGIOT' ||
sig === 'SIGABRT' ||
sig === 'SIGPOLL' ||
sig === 'SIGUNUSED'
}
// Exhaustively test every signal, and a few numbers.
var signals = onSignalExit.signals()
signals.concat('', 0, 1, 2, 3, 54).forEach(function (sig) {
var node = process.execPath
var js = require.resolve('./fixtures/exiter.js')
it('exits properly: ' + sig, function (done) {
// travis has issues with SIGUSR1 on Node 0.x.10.
if (process.env.TRAVIS && sig === 'SIGUSR1') return done()
exec(node + ' ' + js + ' ' + sig, function (err, stdout, stderr) {
if (sig) {
assert(err)
if (!isNaN(sig)) {
assert.equal(err.code, sig)
} else if (!weirdSignal(sig)) {
if (!process.env.TRAVIS) err.signal.should.equal(sig)
} else if (sig) {
if (!process.env.TRAVIS) assert(err.signal)
}
} else {
assert.ifError(err)
}
try {
var data = JSON.parse(stdout)
} catch (er) {
console.error('invalid json: %j', stdout, stderr)
throw er
}
if (weirdSignal(sig)) {
data.wanted[1] = true
data.found[1] = !!data.found[1]
}
assert.deepEqual(data.found, data.wanted)
done()
})
})
})
signals.forEach(function (sig) {
var node = process.execPath
var js = require.resolve('./fixtures/parent.js')
it('exits properly: (external sig) ' + sig, function (done) {
// travis has issues with SIGUSR1 on Node 0.x.10.
if (process.env.TRAVIS && sig === 'SIGUSR1') return done()
var cmd = node + ' ' + js + ' ' + sig
exec(cmd, function (err, stdout, stderr) {
assert.ifError(err)
try {
var data = JSON.parse(stdout)
} catch (er) {
console.error('invalid json: %j', stdout, stderr)
throw er
}
if (weirdSignal(sig)) {
data.wanted[1] = true
data.found[1] = !!data.found[1]
data.external[1] = !!data.external[1]
}
assert.deepEqual(data.found, data.wanted)
assert.deepEqual(data.external, data.wanted)
done()
})
})
})
})

View File

@ -0,0 +1,35 @@
var expectSignal = process.argv[2]
if (!expectSignal || !isNaN(expectSignal)) {
throw new Error('signal not provided')
}
var onSignalExit = require('../../')
onSignalExit(function (code, signal) {
// some signals don't always get recognized properly, because
// they have the same numeric code.
if (wanted[1] === true) {
signal = !!signal
}
console.log('%j', {
found: [ code, signal ],
wanted: wanted
})
})
var wanted
switch (expectSignal) {
case 'SIGIOT':
case 'SIGUNUSED':
case 'SIGPOLL':
wanted = [ null, true ]
break
default:
wanted = [ null, expectSignal ]
break
}
console.error('want', wanted)
setTimeout(function () {}, 1000)

View File

@ -0,0 +1,800 @@
{
"explicit 0 nochange sigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"explicit 0 nochange nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"explicit 0 change sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"explicit 0 change nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"explicit 0 code sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"explicit 0 code nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"explicit 0 twice sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"explicit 0 twice nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"explicit 0 twicecode sigexit": {
"code": 6,
"signal": null,
"exitCode": 6,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
},
"explicit 0 twicecode nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
},
"explicit 2 nochange sigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 2,
"actualSignal": null,
"stderr": [
"first code=2",
"second code=2"
]
},
"explicit 2 nochange nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 2,
"actualSignal": null,
"stderr": [
"first code=2",
"second code=2"
]
},
"explicit 2 change sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5"
]
},
"explicit 2 change nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5"
]
},
"explicit 2 code sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5",
"second code=2"
]
},
"explicit 2 code nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5",
"second code=2"
]
},
"explicit 2 twice sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5"
]
},
"explicit 2 twice nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5"
]
},
"explicit 2 twicecode sigexit": {
"code": 6,
"signal": null,
"exitCode": 6,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5",
"set code from 5 to 6"
]
},
"explicit 2 twicecode nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5",
"set code from 5 to 6"
]
},
"explicit null nochange sigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"explicit null nochange nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"explicit null change sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"explicit null change nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"explicit null code sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"explicit null code nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"explicit null twice sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"explicit null twice nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"explicit null twicecode sigexit": {
"code": 6,
"signal": null,
"exitCode": 6,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
},
"explicit null twicecode nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
},
"code 0 nochange sigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"code 0 nochange nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"code 0 change sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"code 0 change nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"code 0 code sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"code 0 code nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"code 0 twice sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"code 0 twice nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"code 0 twicecode sigexit": {
"code": 6,
"signal": null,
"exitCode": 6,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
},
"code 0 twicecode nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
},
"code 2 nochange sigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 2,
"actualSignal": null,
"stderr": [
"first code=2",
"second code=2"
]
},
"code 2 nochange nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 2,
"actualSignal": null,
"stderr": [
"first code=2",
"second code=2"
]
},
"code 2 change sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5"
]
},
"code 2 change nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5"
]
},
"code 2 code sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5",
"second code=2"
]
},
"code 2 code nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5",
"second code=2"
]
},
"code 2 twice sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5"
]
},
"code 2 twice nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5"
]
},
"code 2 twicecode sigexit": {
"code": 6,
"signal": null,
"exitCode": 6,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5",
"set code from 5 to 6"
]
},
"code 2 twicecode nosigexit": {
"code": 2,
"signal": null,
"exitCode": 2,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=2",
"set code from 2 to 5",
"set code from 5 to 6"
]
},
"code null nochange sigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"code null nochange nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"code null change sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"code null change nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"code null code sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"code null code nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"code null twice sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"code null twice nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"code null twicecode sigexit": {
"code": 6,
"signal": null,
"exitCode": 6,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
},
"code null twicecode nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
},
"normal 0 nochange sigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"normal 0 nochange nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 0,
"actualSignal": null,
"stderr": [
"first code=0",
"second code=0"
]
},
"normal 0 change sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"normal 0 change nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"normal 0 code sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"normal 0 code nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"second code=0"
]
},
"normal 0 twice sigexit": {
"code": 5,
"signal": null,
"exitCode": 5,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"normal 0 twice nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 5,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5"
]
},
"normal 0 twicecode sigexit": {
"code": 6,
"signal": null,
"exitCode": 6,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
},
"normal 0 twicecode nosigexit": {
"code": 0,
"signal": null,
"exitCode": 0,
"actualCode": 6,
"actualSignal": null,
"stderr": [
"first code=0",
"set code from 0 to 5",
"set code from 5 to 6"
]
}
}

View File

@ -0,0 +1,96 @@
if (process.argv.length === 2) {
var types = [ 'explicit', 'code', 'normal' ]
var codes = [ 0, 2, 'null' ]
var changes = [ 'nochange', 'change', 'code', 'twice', 'twicecode']
var handlers = [ 'sigexit', 'nosigexit' ]
var opts = []
types.forEach(function (type) {
var testCodes = type === 'normal' ? [ 0 ] : codes
testCodes.forEach(function (code) {
changes.forEach(function (change) {
handlers.forEach(function (handler) {
opts.push([type, code, change, handler].join(' '))
})
})
})
})
var results = {}
var exec = require('child_process').exec
run(opts.shift())
} else {
var type = process.argv[2]
var code = +process.argv[3]
var change = process.argv[4]
var sigexit = process.argv[5] !== 'nosigexit'
if (sigexit) {
var onSignalExit = require('../../')
onSignalExit(listener)
} else {
process.on('exit', listener)
}
process.on('exit', function (code) {
console.error('first code=%j', code)
})
if (change !== 'nochange') {
process.once('exit', function (code) {
console.error('set code from %j to %j', code, 5)
if (change === 'code' || change === 'twicecode') {
process.exitCode = 5
} else {
process.exit(5)
}
})
if (change === 'twicecode' || change === 'twice') {
process.once('exit', function (code) {
code = process.exitCode || code
console.error('set code from %j to %j', code, code + 1)
process.exit(code + 1)
})
}
}
process.on('exit', function (code) {
console.error('second code=%j', code)
})
if (type === 'explicit') {
if (code || code === 0) {
process.exit(code)
} else {
process.exit()
}
} else if (type === 'code') {
process.exitCode = +code || 0
}
}
function listener (code, signal) {
signal = signal || null
console.log('%j', { code: code, signal: signal, exitCode: process.exitCode || 0 })
}
function run (opt) {
console.error(opt)
exec(process.execPath + ' ' + __filename + ' ' + opt, function (err, stdout, stderr) {
var res = JSON.parse(stdout)
if (err) {
res.actualCode = err.code
res.actualSignal = err.signal
} else {
res.actualCode = 0
res.actualSignal = null
}
res.stderr = stderr.trim().split('\n')
results[opt] = res
if (opts.length) {
run(opts.shift())
} else {
console.log(JSON.stringify(results, null, 2))
}
})
}

View File

@ -0,0 +1,5 @@
var onSignalExit = require('../../')
onSignalExit(function (code, signal) {
console.log('reached end of execution, ' + code + ', ' + signal)
})

View File

@ -0,0 +1,14 @@
var onSignalExit = require('../../')
var counter = 0
onSignalExit(function (code, signal) {
counter++
console.log('last counter=%j, code=%j, signal=%j',
counter, code, signal)
}, {alwaysLast: true})
onSignalExit(function (code, signal) {
counter++
console.log('first counter=%j, code=%j, signal=%j',
counter, code, signal)
})

View File

@ -0,0 +1,7 @@
var onSignalExit = require('../../')
onSignalExit(function (code, signal) {
console.log('exited with process.exit(), ' + code + ', ' + signal)
})
process.exit(32)

View File

@ -0,0 +1,45 @@
var exit = process.argv[2] || 0
var onSignalExit = require('../../')
onSignalExit(function (code, signal) {
// some signals don't always get recognized properly, because
// they have the same numeric code.
if (wanted[1] === true) {
signal = !!signal
}
console.log('%j', {
found: [ code, signal ],
wanted: wanted
})
})
var wanted
if (isNaN(exit)) {
switch (exit) {
case 'SIGIOT':
case 'SIGUNUSED':
case 'SIGPOLL':
wanted = [ null, true ]
break
default:
wanted = [ null, exit ]
break
}
try {
process.kill(process.pid, exit)
setTimeout(function () {}, 1000)
} catch (er) {
wanted = [ 0, null ]
}
} else {
exit = +exit
wanted = [ exit, null ]
// If it's explicitly requested 0, then explicitly call it.
// "no arg" = "exit naturally"
if (exit || process.argv[2]) {
process.exit(exit)
}
}

View File

@ -0,0 +1,7 @@
// just be silly with calling these functions a bunch
// mostly just to get coverage of the guard branches
var onSignalExit = require('../../')
onSignalExit.load()
onSignalExit.load()
onSignalExit.unload()
onSignalExit.unload()

View File

@ -0,0 +1,52 @@
// simulate cases where the module could be loaded from multiple places
var onSignalExit = require('../../')
var counter = 0
onSignalExit(function (code, signal) {
counter++
console.log('last counter=%j, code=%j, signal=%j',
counter, code, signal)
}, {alwaysLast: true})
onSignalExit(function (code, signal) {
counter++
console.log('first counter=%j, code=%j, signal=%j',
counter, code, signal)
})
delete require('module')._cache[require.resolve('../../')]
var onSignalExit = require('../../')
onSignalExit(function (code, signal) {
counter++
console.log('last counter=%j, code=%j, signal=%j',
counter, code, signal)
}, {alwaysLast: true})
onSignalExit(function (code, signal) {
counter++
console.log('first counter=%j, code=%j, signal=%j',
counter, code, signal)
})
// Lastly, some that should NOT be shown
delete require('module')._cache[require.resolve('../../')]
var onSignalExit = require('../../')
var unwrap = onSignalExit(function (code, signal) {
counter++
console.log('last counter=%j, code=%j, signal=%j',
counter, code, signal)
}, {alwaysLast: true})
unwrap()
unwrap = onSignalExit(function (code, signal) {
counter++
console.log('first counter=%j, code=%j, signal=%j',
counter, code, signal)
})
unwrap()
process.kill(process.pid, 'SIGHUP')
setTimeout(function () {}, 1000)

View File

@ -0,0 +1,51 @@
var signal = process.argv[2]
var gens = +process.argv[3] || 0
if (!signal || !isNaN(signal)) {
throw new Error('signal not provided')
}
var spawn = require('child_process').spawn
var file = require.resolve('./awaiter.js')
console.error(process.pid, signal, gens)
if (gens > 0) {
file = __filename
}
var child = spawn(process.execPath, [file, signal, gens - 1], {
stdio: [ 0, 'pipe', 'pipe' ]
})
if (!gens) {
child.stderr.on('data', function () {
child.kill(signal)
})
}
var result = ''
child.stdout.on('data', function (c) {
result += c
})
child.on('close', function (code, sig) {
try {
result = JSON.parse(result)
} catch (er) {
console.log('%j', {
error: 'failed to parse json\n' + er.message,
result: result,
pid: process.pid,
child: child.pid,
gens: gens,
expect: [ null, signal ],
actual: [ code, sig ]
})
return
}
if (result.wanted[1] === true) {
sig = !!sig
}
result.external = result.external || [ code, sig ]
console.log('%j', result)
})

View File

@ -0,0 +1,11 @@
var onSignalExit = require('../../')
onSignalExit(function (code, signal) {
console.log('exited with sigint, ' + code + ', ' + signal)
})
// For some reason, signals appear to not always be fast enough
// to come in before the process exits. Just a few ticks needed.
setTimeout(function () {}, 1000)
process.kill(process.pid, 'SIGINT')

View File

@ -0,0 +1,19 @@
// SIGKILL can't be caught, and in fact, even trying to add the
// listener will throw an error.
// We handle that nicely.
//
// This is just here to get another few more lines of test
// coverage. That's also why it lies about being on a linux
// platform so that we pull in those other event types.
Object.defineProperty(process, 'platform', {
value: 'linux',
writable: false,
enumerable: true,
configurable: true
})
var signals = require('../../signals.js')
signals.push('SIGKILL')
var onSignalExit = require('../../')
onSignalExit.load()

View File

@ -0,0 +1,99 @@
// This fixture is not used in any tests. It is here merely as a way to
// do research into the various signal behaviors on Linux and Darwin.
// Run with no args to cycle through every signal type. Run with a signal
// arg to learn about how that signal behaves.
if (process.argv[2]) {
child(process.argv[2])
} else {
var signals = [
'SIGABRT',
'SIGALRM',
'SIGBUS',
'SIGCHLD',
'SIGCLD',
'SIGCONT',
'SIGEMT',
'SIGFPE',
'SIGHUP',
'SIGILL',
'SIGINFO',
'SIGINT',
'SIGIO',
'SIGIOT',
'SIGKILL',
'SIGLOST',
'SIGPIPE',
'SIGPOLL',
'SIGPROF',
'SIGPWR',
'SIGQUIT',
'SIGSEGV',
'SIGSTKFLT',
'SIGSTOP',
'SIGSYS',
'SIGTERM',
'SIGTRAP',
'SIGTSTP',
'SIGTTIN',
'SIGTTOU',
'SIGUNUSED',
'SIGURG',
'SIGUSR1',
'SIGUSR2',
'SIGVTALRM',
'SIGWINCH',
'SIGXCPU',
'SIGXFSZ'
]
var spawn = require('child_process').spawn
;(function test (signal) {
if (!signal) {
return
}
var child = spawn(process.execPath, [__filename, signal], { stdio: 'inherit' })
var timer = setTimeout(function () {
console.log('requires SIGCONT')
process.kill(child.pid, 'SIGCONT')
}, 750)
child.on('close', function (code, signal) {
console.log('code=%j signal=%j\n', code, signal)
clearTimeout(timer)
test(signals.pop())
})
})(signals.pop())
}
function child (signal) {
console.log('signal=%s', signal)
// set a timeout so we know whether or not the process terminated.
setTimeout(function () {
console.log('not terminated')
}, 200)
process.on('exit', function (code) {
console.log('emit exit code=%j', code)
})
try {
process.on(signal, function fn () {
console.log('signal is catchable', signal)
process.removeListener(signal, fn)
setTimeout(function () {
console.error('signal again')
process.kill(process.pid, signal)
})
})
} catch (er) {
console.log('not listenable')
}
try {
process.kill(process.pid, signal)
} catch (er) {
console.log('not issuable')
}
}

View File

@ -0,0 +1,17 @@
var onSignalExit = require('../../')
var counter = 0
onSignalExit(function (code, signal) {
counter++
console.log('last counter=%j, code=%j, signal=%j',
counter, code, signal)
}, {alwaysLast: true})
onSignalExit(function (code, signal) {
counter++
console.log('first counter=%j, code=%j, signal=%j',
counter, code, signal)
})
process.kill(process.pid, 'SIGHUP')
setTimeout(function () {}, 1000)

View File

@ -0,0 +1,23 @@
var onSignalExit = require('../../')
setTimeout(function () {})
var calledListener = 0
onSignalExit(function (code, signal) {
console.log('exited calledListener=%j, code=%j, signal=%j',
calledListener, code, signal)
})
process.on('SIGHUP', listener)
process.kill(process.pid, 'SIGHUP')
function listener () {
calledListener++
if (calledListener > 3) {
process.removeListener('SIGHUP', listener)
}
setTimeout(function () {
process.kill(process.pid, 'SIGHUP')
})
}

View File

@ -0,0 +1,8 @@
var onSignalExit = require('../..')
onSignalExit(function (code, signal) {
console.error('onSignalExit(%j,%j)', code, signal)
})
setTimeout(function () {
console.log('hello')
})
process.kill(process.pid, 'SIGPIPE')

View File

@ -0,0 +1,9 @@
var onSignalExit = require('../../')
onSignalExit(function (code, signal) {
console.log('exited with sigterm, ' + code + ', ' + signal)
})
setTimeout(function () {}, 1000)
process.kill(process.pid, 'SIGTERM')

View File

@ -0,0 +1,37 @@
// simulate cases where the module could be loaded from multiple places
// Need to lie about this a little bit, since nyc uses this module
// for its coverage wrap-up handling
if (process.env.NYC_CWD) {
var emitter = process.__signal_exit_emitter__
var listeners = emitter.listeners('afterexit')
process.removeAllListeners('SIGHUP')
delete process.__signal_exit_emitter__
delete require('module')._cache[require.resolve('../../')]
}
var onSignalExit = require('../../')
var counter = 0
var unwrap = onSignalExit(function (code, signal) {
counter++
console.log('last counter=%j, code=%j, signal=%j',
counter, code, signal)
}, {alwaysLast: true})
unwrap()
unwrap = onSignalExit(function (code, signal) {
counter++
console.log('first counter=%j, code=%j, signal=%j',
counter, code, signal)
})
unwrap()
if (global.__coverage__ && listeners && listeners.length) {
listeners.forEach(function (fn) {
onSignalExit(fn, { alwaysLast: true })
})
}
process.kill(process.pid, 'SIGHUP')
setTimeout(function () {}, 1000)

View File

@ -0,0 +1,58 @@
var exec = require('child_process').exec,
t = require('tap')
var fixture = require.resolve('./fixtures/change-code.js')
var expect = require('./fixtures/change-code-expect.json')
// process.exitCode has problems prior to:
// https://github.com/joyent/node/commit/c0d81f90996667a658aa4403123e02161262506a
function isZero10 () {
return /^v0\.10\..+$/.test(process.version)
}
// process.exit(code), process.exitCode = code, normal exit
var types = [ 'explicit', 'normal' ]
if (!isZero10()) types.push('code')
// initial code that is set. Note, for 'normal' exit, there's no
// point doing these, because we just exit without modifying code
var codes = [ 0, 2, 'null' ]
// do not change, change to 5 with exit(), change to 5 with exitCode,
// change to 5 and then to 2 with exit(), change twice with exitcode
var changes = [ 'nochange', 'change', 'twice']
if (!isZero10()) changes.push('code', 'twicecode')
// use signal-exit, use process.on('exit')
var handlers = [ 'sigexit', 'nosigexit' ]
var opts = []
types.forEach(function (type) {
var testCodes = type === 'normal' ? [0] : codes
testCodes.forEach(function (code) {
changes.forEach(function (change) {
handlers.forEach(function (handler) {
opts.push([type, code, change, handler].join(' '))
})
})
})
})
opts.forEach(function (opt) {
t.test(opt, function (t) {
var cmd = process.execPath + ' ' + fixture + ' ' + opt
exec(cmd, function (err, stdout, stderr) {
var res = JSON.parse(stdout)
if (err) {
res.actualCode = err.code
res.actualSignal = err.signal
} else {
res.actualCode = 0
res.actualSignal = null
}
res.stderr = stderr.trim().split('\n')
t.same(res, expect[opt])
t.end()
})
})
})

View File

@ -0,0 +1,108 @@
/* global describe, it */
var exec = require('child_process').exec,
expect = require('chai').expect,
assert = require('assert')
require('chai').should()
require('tap').mochaGlobals()
describe('signal-exit', function () {
it('receives an exit event when a process exits normally', function (done) {
exec(process.execPath + ' ./test/fixtures/end-of-execution.js', function (err, stdout, stderr) {
expect(err).to.equal(null)
stdout.should.match(/reached end of execution, 0, null/)
done()
})
})
it('receives an exit event when a process is terminated with sigint', function (done) {
exec(process.execPath + ' ./test/fixtures/sigint.js', function (err, stdout, stderr) {
assert(err)
stdout.should.match(/exited with sigint, null, SIGINT/)
done()
})
})
it('receives an exit event when a process is terminated with sigterm', function (done) {
exec(process.execPath + ' ./test/fixtures/sigterm.js', function (err, stdout, stderr) {
assert(err)
stdout.should.match(/exited with sigterm, null, SIGTERM/)
done()
})
})
it('receives an exit event when process.exit() is called', function (done) {
exec(process.execPath + ' ./test/fixtures/exit.js', function (err, stdout, stderr) {
err.code.should.equal(32)
stdout.should.match(/exited with process\.exit\(\), 32, null/)
done()
})
})
it('does not exit if user handles signal', function (done) {
exec(process.execPath + ' ./test/fixtures/signal-listener.js', function (err, stdout, stderr) {
assert(err)
assert.equal(stdout, 'exited calledListener=4, code=null, signal="SIGHUP"\n')
done()
})
})
it('ensures that if alwaysLast=true, the handler is run last (signal)', function (done) {
exec(process.execPath + ' ./test/fixtures/signal-last.js', function (err, stdout, stderr) {
assert(err)
stdout.should.match(/first counter=1/)
stdout.should.match(/last counter=2/)
done()
})
})
it('ensures that if alwaysLast=true, the handler is run last (normal exit)', function (done) {
exec(process.execPath + ' ./test/fixtures/exit-last.js', function (err, stdout, stderr) {
assert.ifError(err)
stdout.should.match(/first counter=1/)
stdout.should.match(/last counter=2/)
done()
})
})
it('works when loaded multiple times', function (done) {
exec(process.execPath + ' ./test/fixtures/multiple-load.js', function (err, stdout, stderr) {
assert(err)
stdout.should.match(/first counter=1, code=null, signal="SIGHUP"/)
stdout.should.match(/first counter=2, code=null, signal="SIGHUP"/)
stdout.should.match(/last counter=3, code=null, signal="SIGHUP"/)
stdout.should.match(/last counter=4, code=null, signal="SIGHUP"/)
done()
})
})
// TODO: test on a few non-OSX machines.
it('removes handlers when fully unwrapped', function (done) {
exec(process.execPath + ' ./test/fixtures/unwrap.js', function (err, stdout, stderr) {
// on Travis CI no err.signal is populated but
// err.code is 129 (which I think tends to be SIGHUP).
var expectedCode = process.env.TRAVIS ? 129 : null
assert(err)
if (!process.env.TRAVIS) err.signal.should.equal('SIGHUP')
expect(err.code).to.equal(expectedCode)
done()
})
})
it('does not load() or unload() more than once', function (done) {
exec(process.execPath + ' ./test/fixtures/load-unload.js', function (err, stdout, stderr) {
assert.ifError(err)
done()
})
})
it('handles uncatchable signals with grace and poise', function (done) {
exec(process.execPath + ' ./test/fixtures/sigkill.js', function (err, stdout, stderr) {
assert.ifError(err)
done()
})
})
})

View File

@ -0,0 +1,93 @@
{
"name": "loud-rejection",
"version": "1.3.0",
"description": "Make unhandled promise rejections fail loudly instead of the default silent fail",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/loud-rejection.git"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"files": [
"index.js",
"register.js",
"api.js"
],
"keywords": [
"promise",
"promises",
"unhandled",
"uncaught",
"rejection",
"loud",
"fail",
"catch",
"throw",
"handler",
"exit",
"debug",
"debugging",
"verbose"
],
"dependencies": {
"array-find-index": "^1.0.0",
"signal-exit": "^2.1.2"
},
"devDependencies": {
"ava": "*",
"bluebird": "^3.0.5",
"coveralls": "^2.11.4",
"delay": "^1.0.0",
"get-stream": "^1.0.0",
"nyc": "^5.0.1",
"xo": "*"
},
"config": {
"nyc": {
"exclude": [
"fixture.js"
]
}
},
"gitHead": "0bc730030d190edc2050d8e529f6252ae765edb7",
"bugs": {
"url": "https://github.com/sindresorhus/loud-rejection/issues"
},
"homepage": "https://github.com/sindresorhus/loud-rejection#readme",
"_id": "loud-rejection@1.3.0",
"_shasum": "f289a392f17d2baacf194d0a673004394433b115",
"_from": "loud-rejection@^1.0.0",
"_npmVersion": "2.14.12",
"_nodeVersion": "4.3.0",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "f289a392f17d2baacf194d0a673004394433b115",
"tarball": "http://registry.npmjs.org/loud-rejection/-/loud-rejection-1.3.0.tgz"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"_npmOperationalInternal": {
"host": "packages-5-east.internal.npmjs.com",
"tmp": "tmp/loud-rejection-1.3.0.tgz_1455804204049_0.4460844199638814"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.3.0.tgz"
}

View File

@ -0,0 +1,55 @@
# loud-rejection [![Build Status](https://travis-ci.org/sindresorhus/loud-rejection.svg?branch=master)](https://travis-ci.org/sindresorhus/loud-rejection) [![Coverage Status](https://coveralls.io/repos/sindresorhus/loud-rejection/badge.svg?branch=master&service=github)](https://coveralls.io/github/sindresorhus/loud-rejection?branch=master)
> Make unhandled promise rejections fail loudly instead of the default [silent fail](https://gist.github.com/benjamingr/0237932cee84712951a2)
By default, promises fail silently if you don't attach a `.catch()` handler to them.
Use it in top-level things like tests, CLI tools, apps, etc, **but not in reusable modules.**
## Install
```
$ npm install --save loud-rejection
```
## Usage
```js
const loudRejection = require('loud-rejection');
const promiseFn = require('promise-fn');
// Install the unhandledRejection listeners
loudRejection();
promiseFn();
```
Without this module it's more verbose and you might even miss some that will fail silently:
```js
const promiseFn = require('promise-fn');
function error(err) {
console.error(err.stack);
process.exit(1);
}
promiseFn().catch(error);
```
### Register script
Alternatively to the above, you may simply require `loud-rejection/register` and the unhandledRejection listener will be automagically installed for you.
This is handy for ES2015 imports:
```js
import 'loud-rejection/register';
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,3 @@
'use strict';
require('./')();

View File

@ -0,0 +1,13 @@
'use strict';
module.exports = function (obj, cb) {
var ret = {};
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var res = cb(key, obj[key], obj);
ret[res[0]] = res[1];
}
return ret;
};

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,65 @@
{
"name": "map-obj",
"version": "1.0.1",
"description": "Map object keys and values into a new object",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/sindresorhus/map-obj"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "node test.js"
},
"files": [
"index.js"
],
"keywords": [
"map",
"obj",
"object",
"key",
"keys",
"value",
"values",
"val",
"iterate",
"iterator"
],
"devDependencies": {
"ava": "0.0.4"
},
"gitHead": "a4f2d49ae6b5f7c0e55130b49ab0412298b797bc",
"bugs": {
"url": "https://github.com/sindresorhus/map-obj/issues"
},
"homepage": "https://github.com/sindresorhus/map-obj",
"_id": "map-obj@1.0.1",
"_shasum": "d933ceb9205d82bdcf4886f6742bdc2b4dea146d",
"_from": "map-obj@^1.0.1",
"_npmVersion": "2.7.4",
"_nodeVersion": "0.12.2",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"dist": {
"shasum": "d933ceb9205d82bdcf4886f6742bdc2b4dea146d",
"tarball": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"directories": {},
"_resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz"
}

View File

@ -0,0 +1,29 @@
# map-obj [![Build Status](https://travis-ci.org/sindresorhus/map-obj.svg?branch=master)](https://travis-ci.org/sindresorhus/map-obj)
> Map object keys and values into a new object
## Install
```
$ npm install --save map-obj
```
## Usage
```js
var mapObj = require('map-obj');
var newObject = mapObj({foo: 'bar'}, function (key, value, object) {
// first element is the new key and second is the new value
// here we reverse the order
return [value, key];
});
//=> {bar: 'foo'}
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,8 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
- "iojs"
before_install:
- npm install -g npm@~1.4.6

View File

@ -0,0 +1,18 @@
This software is released under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,2 @@
var argv = require('../')(process.argv.slice(2));
console.dir(argv);

View File

@ -0,0 +1,236 @@
module.exports = function (args, opts) {
if (!opts) opts = {};
var flags = { bools : {}, strings : {}, unknownFn: null };
if (typeof opts['unknown'] === 'function') {
flags.unknownFn = opts['unknown'];
}
if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
flags.allBools = true;
} else {
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
flags.bools[key] = true;
});
}
var aliases = {};
Object.keys(opts.alias || {}).forEach(function (key) {
aliases[key] = [].concat(opts.alias[key]);
aliases[key].forEach(function (x) {
aliases[x] = [key].concat(aliases[key].filter(function (y) {
return x !== y;
}));
});
});
[].concat(opts.string).filter(Boolean).forEach(function (key) {
flags.strings[key] = true;
if (aliases[key]) {
flags.strings[aliases[key]] = true;
}
});
var defaults = opts['default'] || {};
var argv = { _ : [] };
Object.keys(flags.bools).forEach(function (key) {
setArg(key, defaults[key] === undefined ? false : defaults[key]);
});
var notFlags = [];
if (args.indexOf('--') !== -1) {
notFlags = args.slice(args.indexOf('--')+1);
args = args.slice(0, args.indexOf('--'));
}
function argDefined(key, arg) {
return (flags.allBools && /^--[^=]+$/.test(arg)) ||
flags.strings[key] || flags.bools[key] || aliases[key];
}
function setArg (key, val, arg) {
if (arg && flags.unknownFn && !argDefined(key, arg)) {
if (flags.unknownFn(arg) === false) return;
}
var value = !flags.strings[key] && isNumber(val)
? Number(val) : val
;
setKey(argv, key.split('.'), value);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), value);
});
}
function setKey (obj, keys, value) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
if (o[key] === undefined) o[key] = {};
o = o[key];
});
var key = keys[keys.length - 1];
if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
o[key] = value;
}
else if (Array.isArray(o[key])) {
o[key].push(value);
}
else {
o[key] = [ o[key], value ];
}
}
function aliasIsBoolean(key) {
return aliases[key].some(function (x) {
return flags.bools[x];
});
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (/^--.+=/.test(arg)) {
// Using [\s\S] instead of . because js doesn't support the
// 'dotall' regex modifier. See:
// http://stackoverflow.com/a/1068308/13216
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
var key = m[1];
var value = m[2];
if (flags.bools[key]) {
value = value !== 'false';
}
setArg(key, value, arg);
}
else if (/^--no-.+/.test(arg)) {
var key = arg.match(/^--no-(.+)/)[1];
setArg(key, false, arg);
}
else if (/^--.+/.test(arg)) {
var key = arg.match(/^--(.+)/)[1];
var next = args[i + 1];
if (next !== undefined && !/^-/.test(next)
&& !flags.bools[key]
&& !flags.allBools
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, next, arg);
i++;
}
else if (/^(true|false)$/.test(next)) {
setArg(key, next === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
else if (/^-[^-]+/.test(arg)) {
var letters = arg.slice(1,-1).split('');
var broken = false;
for (var j = 0; j < letters.length; j++) {
var next = arg.slice(j+2);
if (next === '-') {
setArg(letters[j], next, arg)
continue;
}
if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
setArg(letters[j], next.split('=')[1], arg);
broken = true;
break;
}
if (/[A-Za-z]/.test(letters[j])
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next, arg);
broken = true;
break;
}
if (letters[j+1] && letters[j+1].match(/\W/)) {
setArg(letters[j], arg.slice(j+2), arg);
broken = true;
break;
}
else {
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
}
}
var key = arg.slice(-1)[0];
if (!broken && key !== '-') {
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
&& !flags.bools[key]
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, args[i+1], arg);
i++;
}
else if (args[i+1] && /true|false/.test(args[i+1])) {
setArg(key, args[i+1] === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
}
else {
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
argv._.push(
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
);
}
if (opts.stopEarly) {
argv._.push.apply(argv._, args.slice(i + 1));
break;
}
}
}
Object.keys(defaults).forEach(function (key) {
if (!hasKey(argv, key.split('.'))) {
setKey(argv, key.split('.'), defaults[key]);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), defaults[key]);
});
}
});
if (opts['--']) {
argv['--'] = new Array();
notFlags.forEach(function(key) {
argv['--'].push(key);
});
}
else {
notFlags.forEach(function(key) {
argv._.push(key);
});
}
return argv;
};
function hasKey (obj, keys) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
o = (o[key] || {});
});
var key = keys[keys.length - 1];
return key in o;
}
function isNumber (x) {
if (typeof x === 'number') return true;
if (/^0x[0-9a-f]+$/i.test(x)) return true;
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}

View File

@ -0,0 +1,70 @@
{
"name": "minimist",
"version": "1.2.0",
"description": "parse argument options",
"main": "index.js",
"devDependencies": {
"covert": "^1.0.0",
"tap": "~0.4.0",
"tape": "^3.5.0"
},
"scripts": {
"test": "tap test/*.js",
"coverage": "covert test/*.js"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/6..latest",
"ff/5",
"firefox/latest",
"chrome/10",
"chrome/latest",
"safari/5.1",
"safari/latest",
"opera/12"
]
},
"repository": {
"type": "git",
"url": "git://github.com/substack/minimist.git"
},
"homepage": "https://github.com/substack/minimist",
"keywords": [
"argv",
"getopt",
"parser",
"optimist"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"license": "MIT",
"gitHead": "dc624482fcfec5bc669c68cdb861f00573ed4e64",
"bugs": {
"url": "https://github.com/substack/minimist/issues"
},
"_id": "minimist@1.2.0",
"_shasum": "a35008b20f41383eec1fb914f4cd5df79a264284",
"_from": "minimist@^1.1.3",
"_npmVersion": "3.2.2",
"_nodeVersion": "2.4.0",
"_npmUser": {
"name": "substack",
"email": "substack@gmail.com"
},
"dist": {
"shasum": "a35008b20f41383eec1fb914f4cd5df79a264284",
"tarball": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz"
},
"maintainers": [
{
"name": "substack",
"email": "mail@substack.net"
}
],
"directories": {},
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz"
}

View File

@ -0,0 +1,91 @@
# minimist
parse argument options
This module is the guts of optimist's argument parser without all the
fanciful decoration.
[![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist)
[![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist)
# example
``` js
var argv = require('minimist')(process.argv.slice(2));
console.dir(argv);
```
```
$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
```
```
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
x: 3,
y: 4,
n: 5,
a: true,
b: true,
c: true,
beep: 'boop' }
```
# methods
``` js
var parseArgs = require('minimist')
```
## var argv = parseArgs(args, opts={})
Return an argument object `argv` populated with the array arguments from `args`.
`argv._` contains all the arguments that didn't have an option associated with
them.
Numeric-looking arguments will be returned as numbers unless `opts.string` or
`opts.boolean` is set for that argument name.
Any arguments after `'--'` will not be parsed and will end up in `argv._`.
options can be:
* `opts.string` - a string or array of strings argument names to always treat as
strings
* `opts.boolean` - a boolean, string or array of strings to always treat as
booleans. if `true` will treat all double hyphenated arguments without equal signs
as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
* `opts.alias` - an object mapping string names to strings or arrays of string
argument names to use as aliases
* `opts.default` - an object mapping string argument names to default values
* `opts.stopEarly` - when true, populate `argv._` with everything after the
first non-option
* `opts['--']` - when true, populate `argv._` with everything before the `--`
and `argv['--']` with everything after the `--`. Here's an example:
* `opts.unknown` - a function which is invoked with a command line parameter not
defined in the `opts` configuration object. If the function returns `false`, the
unknown option is not added to `argv`.
```
> require('./')('one two three -- four five --six'.split(' '), { '--': true })
{ _: [ 'one', 'two', 'three' ],
'--': [ 'four', 'five', '--six' ] }
```
Note that with `opts['--']` set, parsing for arguments still stops after the
`--`.
# install
With [npm](https://npmjs.org) do:
```
npm install minimist
```
# license
MIT

View File

@ -0,0 +1,32 @@
var parse = require('../');
var test = require('tape');
test('flag boolean true (default all --args to boolean)', function (t) {
var argv = parse(['moo', '--honk', 'cow'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});
test('flag boolean true only affects double hyphen arguments without equals signs', function (t) {
var argv = parse(['moo', '--honk', 'cow', '-p', '55', '--tacos=good'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
tacos: 'good',
p: 55,
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});

View File

@ -0,0 +1,166 @@
var parse = require('../');
var test = require('tape');
test('flag boolean default false', function (t) {
var argv = parse(['moo'], {
boolean: ['t', 'verbose'],
default: { verbose: false, t: false }
});
t.deepEqual(argv, {
verbose: false,
t: false,
_: ['moo']
});
t.deepEqual(typeof argv.verbose, 'boolean');
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('boolean groups', function (t) {
var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], {
boolean: ['x','y','z']
});
t.deepEqual(argv, {
x : true,
y : false,
z : true,
_ : [ 'one', 'two', 'three' ]
});
t.deepEqual(typeof argv.x, 'boolean');
t.deepEqual(typeof argv.y, 'boolean');
t.deepEqual(typeof argv.z, 'boolean');
t.end();
});
test('boolean and alias with chainable api', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
herp: { alias: 'h', boolean: true }
};
var aliasedArgv = parse(aliased, {
boolean: 'herp',
alias: { h: 'herp' }
});
var propertyArgv = parse(regular, {
boolean: 'herp',
alias: { h: 'herp' }
});
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias with options hash', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
alias: { 'h': 'herp' },
boolean: 'herp'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias array with options hash', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var alt = [ '--harp', 'derp' ];
var opts = {
alias: { 'h': ['herp', 'harp'] },
boolean: 'h'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var altPropertyArgv = parse(alt, opts);
var expected = {
harp: true,
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.same(altPropertyArgv, expected);
t.end();
});
test('boolean and alias using explicit true', function (t) {
var aliased = [ '-h', 'true' ];
var regular = [ '--herp', 'true' ];
var opts = {
alias: { h: 'herp' },
boolean: 'h'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
// regression, see https://github.com/substack/node-optimist/issues/71
test('boolean and --x=true', function(t) {
var parsed = parse(['--boool', '--other=true'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'true');
parsed = parse(['--boool', '--other=false'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'false');
t.end();
});
test('boolean --boool=true', function (t) {
var parsed = parse(['--boool=true'], {
default: {
boool: false
},
boolean: ['boool']
});
t.same(parsed.boool, true);
t.end();
});
test('boolean --boool=false', function (t) {
var parsed = parse(['--boool=false'], {
default: {
boool: true
},
boolean: ['boool']
});
t.same(parsed.boool, false);
t.end();
});

Some files were not shown because too many files have changed in this diff Show More