summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/extsprintf
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2018-04-20 18:26:37 -0700
committerRebecca Turner <me@re-becca.org>2018-05-24 23:24:45 -0700
commit468ab4519e1b92473acefb22801497a1af6aebae (patch)
treebdac1d062cd4b094bde3a21147bab5d82c792ece /deps/npm/node_modules/extsprintf
parentac8226115e2192a7a46ba07789fa5136f74223e1 (diff)
downloadnode-new-468ab4519e1b92473acefb22801497a1af6aebae.tar.gz
deps: upgrade npm to 6.1.0
PR-URL: https://github.com/nodejs/node/pull/20190 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'deps/npm/node_modules/extsprintf')
-rw-r--r--deps/npm/node_modules/extsprintf/.gitmodules0
-rw-r--r--deps/npm/node_modules/extsprintf/.npmignore2
-rw-r--r--deps/npm/node_modules/extsprintf/LICENSE19
-rw-r--r--deps/npm/node_modules/extsprintf/Makefile24
-rw-r--r--deps/npm/node_modules/extsprintf/Makefile.targ285
-rw-r--r--deps/npm/node_modules/extsprintf/README.md46
-rw-r--r--deps/npm/node_modules/extsprintf/jsl.node.conf136
-rw-r--r--deps/npm/node_modules/extsprintf/lib/extsprintf.js183
-rw-r--r--deps/npm/node_modules/extsprintf/package.json44
9 files changed, 739 insertions, 0 deletions
diff --git a/deps/npm/node_modules/extsprintf/.gitmodules b/deps/npm/node_modules/extsprintf/.gitmodules
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/deps/npm/node_modules/extsprintf/.gitmodules
diff --git a/deps/npm/node_modules/extsprintf/.npmignore b/deps/npm/node_modules/extsprintf/.npmignore
new file mode 100644
index 0000000000..6ed1ae9750
--- /dev/null
+++ b/deps/npm/node_modules/extsprintf/.npmignore
@@ -0,0 +1,2 @@
+/deps
+/examples
diff --git a/deps/npm/node_modules/extsprintf/LICENSE b/deps/npm/node_modules/extsprintf/LICENSE
new file mode 100644
index 0000000000..cbc0bb3ba3
--- /dev/null
+++ b/deps/npm/node_modules/extsprintf/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2012, Joyent, Inc. All rights reserved.
+
+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
diff --git a/deps/npm/node_modules/extsprintf/Makefile b/deps/npm/node_modules/extsprintf/Makefile
new file mode 100644
index 0000000000..db845189ad
--- /dev/null
+++ b/deps/npm/node_modules/extsprintf/Makefile
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2012, Joyent, Inc. All rights reserved.
+#
+# Makefile: top-level Makefile
+#
+# This Makefile contains only repo-specific logic and uses included makefiles
+# to supply common targets (javascriptlint, jsstyle, restdown, etc.), which are
+# used by other repos as well.
+#
+
+#
+# Files
+#
+JSL = jsl
+JSSTYLE = jsstyle
+JS_FILES := $(shell find examples lib -name '*.js')
+JSL_FILES_NODE = $(JS_FILES)
+JSSTYLE_FILES = $(JS_FILES)
+JSL_CONF_NODE = jsl.node.conf
+
+# Default target is "check"
+check:
+
+include ./Makefile.targ
diff --git a/deps/npm/node_modules/extsprintf/Makefile.targ b/deps/npm/node_modules/extsprintf/Makefile.targ
new file mode 100644
index 0000000000..2a64fe7e95
--- /dev/null
+++ b/deps/npm/node_modules/extsprintf/Makefile.targ
@@ -0,0 +1,285 @@
+# -*- mode: makefile -*-
+#
+# Copyright (c) 2012, Joyent, Inc. All rights reserved.
+#
+# Makefile.targ: common targets.
+#
+# NOTE: This makefile comes from the "eng" repo. It's designed to be dropped
+# into other repos as-is without requiring any modifications. If you find
+# yourself changing this file, you should instead update the original copy in
+# eng.git and then update your repo to use the new version.
+#
+# This Makefile defines several useful targets and rules. You can use it by
+# including it from a Makefile that specifies some of the variables below.
+#
+# Targets defined in this Makefile:
+#
+# check Checks JavaScript files for lint and style
+# Checks bash scripts for syntax
+# Checks SMF manifests for validity against the SMF DTD
+#
+# clean Removes built files
+#
+# docs Builds restdown documentation in docs/
+#
+# prepush Depends on "check" and "test"
+#
+# test Does nothing (you should override this)
+#
+# xref Generates cscope (source cross-reference index)
+#
+# For details on what these targets are supposed to do, see the Joyent
+# Engineering Guide.
+#
+# To make use of these targets, you'll need to set some of these variables. Any
+# variables left unset will simply not be used.
+#
+# BASH_FILES Bash scripts to check for syntax
+# (paths relative to top-level Makefile)
+#
+# CLEAN_FILES Files to remove as part of the "clean" target. Note
+# that files generated by targets in this Makefile are
+# automatically included in CLEAN_FILES. These include
+# restdown-generated HTML and JSON files.
+#
+# DOC_FILES Restdown (documentation source) files. These are
+# assumed to be contained in "docs/", and must NOT
+# contain the "docs/" prefix.
+#
+# JSL_CONF_NODE Specify JavaScriptLint configuration files
+# JSL_CONF_WEB (paths relative to top-level Makefile)
+#
+# Node.js and Web configuration files are separate
+# because you'll usually want different global variable
+# configurations. If no file is specified, none is given
+# to jsl, which causes it to use a default configuration,
+# which probably isn't what you want.
+#
+# JSL_FILES_NODE JavaScript files to check with Node config file.
+# JSL_FILES_WEB JavaScript files to check with Web config file.
+#
+# You can also override these variables:
+#
+# BASH Path to bash (default: bash)
+#
+# CSCOPE_DIRS Directories to search for source files for the cscope
+# index. (default: ".")
+#
+# JSL Path to JavaScriptLint (default: "jsl")
+#
+# JSL_FLAGS_NODE Additional flags to pass through to JSL
+# JSL_FLAGS_WEB
+# JSL_FLAGS
+#
+# JSSTYLE Path to jsstyle (default: jsstyle)
+#
+# JSSTYLE_FLAGS Additional flags to pass through to jsstyle
+#
+
+#
+# Defaults for the various tools we use.
+#
+BASH ?= bash
+BASHSTYLE ?= tools/bashstyle
+CP ?= cp
+CSCOPE ?= cscope
+CSCOPE_DIRS ?= .
+JSL ?= jsl
+JSSTYLE ?= jsstyle
+MKDIR ?= mkdir -p
+MV ?= mv
+RESTDOWN_FLAGS ?=
+RMTREE ?= rm -rf
+JSL_FLAGS ?= --nologo --nosummary
+
+ifeq ($(shell uname -s),SunOS)
+ TAR ?= gtar
+else
+ TAR ?= tar
+endif
+
+
+#
+# Defaults for other fixed values.
+#
+BUILD = build
+DISTCLEAN_FILES += $(BUILD)
+DOC_BUILD = $(BUILD)/docs/public
+
+#
+# Configure JSL_FLAGS_{NODE,WEB} based on JSL_CONF_{NODE,WEB}.
+#
+ifneq ($(origin JSL_CONF_NODE), undefined)
+ JSL_FLAGS_NODE += --conf=$(JSL_CONF_NODE)
+endif
+
+ifneq ($(origin JSL_CONF_WEB), undefined)
+ JSL_FLAGS_WEB += --conf=$(JSL_CONF_WEB)
+endif
+
+#
+# Targets. For descriptions on what these are supposed to do, see the
+# Joyent Engineering Guide.
+#
+
+#
+# Instruct make to keep around temporary files. We have rules below that
+# automatically update git submodules as needed, but they employ a deps/*/.git
+# temporary file. Without this directive, make tries to remove these .git
+# directories after the build has completed.
+#
+.SECONDARY: $($(wildcard deps/*):%=%/.git)
+
+#
+# This rule enables other rules that use files from a git submodule to have
+# those files depend on deps/module/.git and have "make" automatically check
+# out the submodule as needed.
+#
+deps/%/.git:
+ git submodule update --init deps/$*
+
+#
+# These recipes make heavy use of dynamically-created phony targets. The parent
+# Makefile defines a list of input files like BASH_FILES. We then say that each
+# of these files depends on a fake target called filename.bashchk, and then we
+# define a pattern rule for those targets that runs bash in check-syntax-only
+# mode. This mechanism has the nice properties that if you specify zero files,
+# the rule becomes a noop (unlike a single rule to check all bash files, which
+# would invoke bash with zero files), and you can check individual files from
+# the command line with "make filename.bashchk".
+#
+.PHONY: check-bash
+check-bash: $(BASH_FILES:%=%.bashchk) $(BASH_FILES:%=%.bashstyle)
+
+%.bashchk: %
+ $(BASH) -n $^
+
+%.bashstyle: %
+ $(BASHSTYLE) $^
+
+.PHONY: check-jsl check-jsl-node check-jsl-web
+check-jsl: check-jsl-node check-jsl-web
+
+check-jsl-node: $(JSL_FILES_NODE:%=%.jslnodechk)
+
+check-jsl-web: $(JSL_FILES_WEB:%=%.jslwebchk)
+
+%.jslnodechk: % $(JSL_EXEC)
+ $(JSL) $(JSL_FLAGS) $(JSL_FLAGS_NODE) $<
+
+%.jslwebchk: % $(JSL_EXEC)
+ $(JSL) $(JSL_FLAGS) $(JSL_FLAGS_WEB) $<
+
+.PHONY: check-jsstyle
+check-jsstyle: $(JSSTYLE_FILES:%=%.jsstylechk)
+
+%.jsstylechk: % $(JSSTYLE_EXEC)
+ $(JSSTYLE) $(JSSTYLE_FLAGS) $<
+
+.PHONY: check
+check: check-jsl check-jsstyle check-bash
+ @echo check ok
+
+.PHONY: clean
+clean::
+ -$(RMTREE) $(CLEAN_FILES)
+
+.PHONY: distclean
+distclean:: clean
+ -$(RMTREE) $(DISTCLEAN_FILES)
+
+CSCOPE_FILES = cscope.in.out cscope.out cscope.po.out
+CLEAN_FILES += $(CSCOPE_FILES)
+
+.PHONY: xref
+xref: cscope.files
+ $(CSCOPE) -bqR
+
+.PHONY: cscope.files
+cscope.files:
+ find $(CSCOPE_DIRS) -name '*.c' -o -name '*.h' -o -name '*.cc' \
+ -o -name '*.js' -o -name '*.s' -o -name '*.cpp' > $@
+
+#
+# The "docs" target is complicated because we do several things here:
+#
+# (1) Use restdown to build HTML and JSON files from each of DOC_FILES.
+#
+# (2) Copy these files into $(DOC_BUILD) (build/docs/public), which
+# functions as a complete copy of the documentation that could be
+# mirrored or served over HTTP.
+#
+# (3) Then copy any directories and media from docs/media into
+# $(DOC_BUILD)/media. This allows projects to include their own media,
+# including files that will override same-named files provided by
+# restdown.
+#
+# Step (3) is the surprisingly complex part: in order to do this, we need to
+# identify the subdirectories in docs/media, recreate them in
+# $(DOC_BUILD)/media, then do the same with the files.
+#
+DOC_MEDIA_DIRS := $(shell find docs/media -type d 2>/dev/null | grep -v "^docs/media$$")
+DOC_MEDIA_DIRS := $(DOC_MEDIA_DIRS:docs/media/%=%)
+DOC_MEDIA_DIRS_BUILD := $(DOC_MEDIA_DIRS:%=$(DOC_BUILD)/media/%)
+
+DOC_MEDIA_FILES := $(shell find docs/media -type f 2>/dev/null)
+DOC_MEDIA_FILES := $(DOC_MEDIA_FILES:docs/media/%=%)
+DOC_MEDIA_FILES_BUILD := $(DOC_MEDIA_FILES:%=$(DOC_BUILD)/media/%)
+
+#
+# Like the other targets, "docs" just depends on the final files we want to
+# create in $(DOC_BUILD), leveraging other targets and recipes to define how
+# to get there.
+#
+.PHONY: docs
+docs: \
+ $(DOC_FILES:%.restdown=$(DOC_BUILD)/%.html) \
+ $(DOC_FILES:%.restdown=$(DOC_BUILD)/%.json) \
+ $(DOC_MEDIA_FILES_BUILD)
+
+#
+# We keep the intermediate files so that the next build can see whether the
+# files in DOC_BUILD are up to date.
+#
+.PRECIOUS: \
+ $(DOC_FILES:%.restdown=docs/%.html) \
+ $(DOC_FILES:%.restdown=docs/%json)
+
+#
+# We do clean those intermediate files, as well as all of DOC_BUILD.
+#
+CLEAN_FILES += \
+ $(DOC_BUILD) \
+ $(DOC_FILES:%.restdown=docs/%.html) \
+ $(DOC_FILES:%.restdown=docs/%.json)
+
+#
+# Before installing the files, we must make sure the directories exist. The |
+# syntax tells make that the dependency need only exist, not be up to date.
+# Otherwise, it might try to rebuild spuriously because the directory itself
+# appears out of date.
+#
+$(DOC_MEDIA_FILES_BUILD): | $(DOC_MEDIA_DIRS_BUILD)
+
+$(DOC_BUILD)/%: docs/% | $(DOC_BUILD)
+ $(CP) $< $@
+
+docs/%.json docs/%.html: docs/%.restdown | $(DOC_BUILD) $(RESTDOWN_EXEC)
+ $(RESTDOWN) $(RESTDOWN_FLAGS) -m $(DOC_BUILD) $<
+
+$(DOC_BUILD):
+ $(MKDIR) $@
+
+$(DOC_MEDIA_DIRS_BUILD):
+ $(MKDIR) $@
+
+#
+# The default "test" target does nothing. This should usually be overridden by
+# the parent Makefile. It's included here so we can define "prepush" without
+# requiring the repo to define "test".
+#
+.PHONY: test
+test:
+
+.PHONY: prepush
+prepush: check test
diff --git a/deps/npm/node_modules/extsprintf/README.md b/deps/npm/node_modules/extsprintf/README.md
new file mode 100644
index 0000000000..b22998d63a
--- /dev/null
+++ b/deps/npm/node_modules/extsprintf/README.md
@@ -0,0 +1,46 @@
+# extsprintf: extended POSIX-style sprintf
+
+Stripped down version of s[n]printf(3c). We make a best effort to throw an
+exception when given a format string we don't understand, rather than ignoring
+it, so that we won't break existing programs if/when we go implement the rest
+of this.
+
+This implementation currently supports specifying
+
+* field alignment ('-' flag),
+* zero-pad ('0' flag)
+* always show numeric sign ('+' flag),
+* field width
+* conversions for strings, decimal integers, and floats (numbers).
+* argument size specifiers. These are all accepted but ignored, since
+ Javascript has no notion of the physical size of an argument.
+
+Everything else is currently unsupported, most notably: precision, unsigned
+numbers, non-decimal numbers, and characters.
+
+Besides the usual POSIX conversions, this implementation supports:
+
+* `%j`: pretty-print a JSON object (using node's "inspect")
+* `%r`: pretty-print an Error object
+
+# Example
+
+First, install it:
+
+ # npm install extsprintf
+
+Now, use it:
+
+ var mod_extsprintf = require('extsprintf');
+ console.log(mod_extsprintf.sprintf('hello %25s', 'world'));
+
+outputs:
+
+ hello world
+
+# Also supported
+
+**printf**: same args as sprintf, but prints the result to stdout
+
+**fprintf**: same args as sprintf, preceded by a Node stream. Prints the result
+to the given stream.
diff --git a/deps/npm/node_modules/extsprintf/jsl.node.conf b/deps/npm/node_modules/extsprintf/jsl.node.conf
new file mode 100644
index 0000000000..eabe9650f5
--- /dev/null
+++ b/deps/npm/node_modules/extsprintf/jsl.node.conf
@@ -0,0 +1,136 @@
+#
+# Configuration File for JavaScript Lint
+#
+# This configuration file can be used to lint a collection of scripts, or to enable
+# or disable warnings for scripts that are linted via the command line.
+#
+
+### Warnings
+# Enable or disable warnings based on requirements.
+# Use "+WarningName" to display or "-WarningName" to suppress.
+#
++ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent
++ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
++ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement
++anon_no_return_value # anonymous function does not always return value
++assign_to_function_call # assignment to a function call
+-block_without_braces # block statement without curly braces
++comma_separated_stmts # multiple statements separated by commas (use semicolons?)
++comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
++default_not_at_end # the default case is not at the end of the switch statement
++dup_option_explicit # duplicate "option explicit" control comment
++duplicate_case_in_switch # duplicate case in switch statement
++duplicate_formal # duplicate formal argument {name}
++empty_statement # empty statement or extra semicolon
++identifier_hides_another # identifer {name} hides an identifier in a parent scope
+-inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
++incorrect_version # Expected /*jsl:content-type*/ control comment. The script was parsed with the wrong version.
++invalid_fallthru # unexpected "fallthru" control comment
++invalid_pass # unexpected "pass" control comment
++jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
++leading_decimal_point # leading decimal point may indicate a number or an object member
++legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
++meaningless_block # meaningless block; curly braces have no impact
++mismatch_ctrl_comments # mismatched control comment; "ignore" and "end" control comments must have a one-to-one correspondence
++misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
++missing_break # missing break statement
++missing_break_for_last_case # missing break statement for last case in switch
++missing_default_case # missing default case in switch statement
++missing_option_explicit # the "option explicit" control comment is missing
++missing_semicolon # missing semicolon
++missing_semicolon_for_lambda # missing semicolon for lambda assignment
++multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
++nested_comment # nested comment
++no_return_value # function {name} does not always return a value
++octal_number # leading zeros make an octal number
++parseint_missing_radix # parseInt missing radix parameter
++partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag
++redeclared_var # redeclaration of {name}
++trailing_comma_in_array # extra comma is not recommended in array initializers
++trailing_decimal_point # trailing decimal point may indicate a number or an object member
++undeclared_identifier # undeclared identifier: {name}
++unreachable_code # unreachable code
+-unreferenced_argument # argument declared but never referenced: {name}
+-unreferenced_function # function is declared but never referenced: {name}
++unreferenced_variable # variable is declared but never referenced: {name}
++unsupported_version # JavaScript {version} is not supported
++use_of_label # use of label
++useless_assign # useless assignment
++useless_comparison # useless comparison; comparing identical expressions
+-useless_quotes # the quotation marks are unnecessary
++useless_void # use of the void type may be unnecessary (void is always undefined)
++var_hides_arg # variable {name} hides argument
++want_assign_or_call # expected an assignment or function call
++with_statement # with statement hides undeclared variables; use temporary variable instead
+
+
+### Output format
+# Customize the format of the error message.
+# __FILE__ indicates current file path
+# __FILENAME__ indicates current file name
+# __LINE__ indicates current line
+# __COL__ indicates current column
+# __ERROR__ indicates error message (__ERROR_PREFIX__: __ERROR_MSG__)
+# __ERROR_NAME__ indicates error name (used in configuration file)
+# __ERROR_PREFIX__ indicates error prefix
+# __ERROR_MSG__ indicates error message
+#
+# For machine-friendly output, the output format can be prefixed with
+# "encode:". If specified, all items will be encoded with C-slashes.
+#
+# Visual Studio syntax (default):
++output-format __FILE__(__LINE__): __ERROR__
+# Alternative syntax:
+#+output-format __FILE__:__LINE__: __ERROR__
+
+
+### Context
+# Show the in-line position of the error.
+# Use "+context" to display or "-context" to suppress.
+#
++context
+
+
+### Control Comments
+# Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for
+# the /*@keyword@*/ control comments and JScript conditional comments. (The latter is
+# enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason,
+# although legacy control comments are enabled by default for backward compatibility.
+#
+-legacy_control_comments
+
+
+### Defining identifiers
+# By default, "option explicit" is enabled on a per-file basis.
+# To enable this for all files, use "+always_use_option_explicit"
+-always_use_option_explicit
+
+# Define certain identifiers of which the lint is not aware.
+# (Use this in conjunction with the "undeclared identifier" warning.)
+#
+# Common uses for webpages might be:
++define __dirname
++define clearInterval
++define clearTimeout
++define console
++define exports
++define global
++define process
++define require
++define setInterval
++define setTimeout
++define Buffer
++define JSON
++define Math
+
+### JavaScript Version
+# To change the default JavaScript version:
+#+default-type text/javascript;version=1.5
+#+default-type text/javascript;e4x=1
+
+### Files
+# Specify which files to lint
+# Use "+recurse" to enable recursion (disabled by default).
+# To add a set of files, use "+process FileName", "+process Folder\Path\*.js",
+# or "+process Folder\Path\*.htm".
+#
diff --git a/deps/npm/node_modules/extsprintf/lib/extsprintf.js b/deps/npm/node_modules/extsprintf/lib/extsprintf.js
new file mode 100644
index 0000000000..ed883d32b9
--- /dev/null
+++ b/deps/npm/node_modules/extsprintf/lib/extsprintf.js
@@ -0,0 +1,183 @@
+/*
+ * extsprintf.js: extended POSIX-style sprintf
+ */
+
+var mod_assert = require('assert');
+var mod_util = require('util');
+
+/*
+ * Public interface
+ */
+exports.sprintf = jsSprintf;
+exports.printf = jsPrintf;
+exports.fprintf = jsFprintf;
+
+/*
+ * Stripped down version of s[n]printf(3c). We make a best effort to throw an
+ * exception when given a format string we don't understand, rather than
+ * ignoring it, so that we won't break existing programs if/when we go implement
+ * the rest of this.
+ *
+ * This implementation currently supports specifying
+ * - field alignment ('-' flag),
+ * - zero-pad ('0' flag)
+ * - always show numeric sign ('+' flag),
+ * - field width
+ * - conversions for strings, decimal integers, and floats (numbers).
+ * - argument size specifiers. These are all accepted but ignored, since
+ * Javascript has no notion of the physical size of an argument.
+ *
+ * Everything else is currently unsupported, most notably precision, unsigned
+ * numbers, non-decimal numbers, and characters.
+ */
+function jsSprintf(fmt)
+{
+ var regex = [
+ '([^%]*)', /* normal text */
+ '%', /* start of format */
+ '([\'\\-+ #0]*?)', /* flags (optional) */
+ '([1-9]\\d*)?', /* width (optional) */
+ '(\\.([1-9]\\d*))?', /* precision (optional) */
+ '[lhjztL]*?', /* length mods (ignored) */
+ '([diouxXfFeEgGaAcCsSp%jr])' /* conversion */
+ ].join('');
+
+ var re = new RegExp(regex);
+ var args = Array.prototype.slice.call(arguments, 1);
+ var flags, width, precision, conversion;
+ var left, pad, sign, arg, match;
+ var ret = '';
+ var argn = 1;
+
+ mod_assert.equal('string', typeof (fmt));
+
+ while ((match = re.exec(fmt)) !== null) {
+ ret += match[1];
+ fmt = fmt.substring(match[0].length);
+
+ flags = match[2] || '';
+ width = match[3] || 0;
+ precision = match[4] || '';
+ conversion = match[6];
+ left = false;
+ sign = false;
+ pad = ' ';
+
+ if (conversion == '%') {
+ ret += '%';
+ continue;
+ }
+
+ if (args.length === 0)
+ throw (new Error('too few args to sprintf'));
+
+ arg = args.shift();
+ argn++;
+
+ if (flags.match(/[\' #]/))
+ throw (new Error(
+ 'unsupported flags: ' + flags));
+
+ if (precision.length > 0)
+ throw (new Error(
+ 'non-zero precision not supported'));
+
+ if (flags.match(/-/))
+ left = true;
+
+ if (flags.match(/0/))
+ pad = '0';
+
+ if (flags.match(/\+/))
+ sign = true;
+
+ switch (conversion) {
+ case 's':
+ if (arg === undefined || arg === null)
+ throw (new Error('argument ' + argn +
+ ': attempted to print undefined or null ' +
+ 'as a string'));
+ ret += doPad(pad, width, left, arg.toString());
+ break;
+
+ case 'd':
+ arg = Math.floor(arg);
+ /*jsl:fallthru*/
+ case 'f':
+ sign = sign && arg > 0 ? '+' : '';
+ ret += sign + doPad(pad, width, left,
+ arg.toString());
+ break;
+
+ case 'x':
+ ret += doPad(pad, width, left, arg.toString(16));
+ break;
+
+ case 'j': /* non-standard */
+ if (width === 0)
+ width = 10;
+ ret += mod_util.inspect(arg, false, width);
+ break;
+
+ case 'r': /* non-standard */
+ ret += dumpException(arg);
+ break;
+
+ default:
+ throw (new Error('unsupported conversion: ' +
+ conversion));
+ }
+ }
+
+ ret += fmt;
+ return (ret);
+}
+
+function jsPrintf() {
+ var args = Array.prototype.slice.call(arguments);
+ args.unshift(process.stdout);
+ jsFprintf.apply(null, args);
+}
+
+function jsFprintf(stream) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ return (stream.write(jsSprintf.apply(this, args)));
+}
+
+function doPad(chr, width, left, str)
+{
+ var ret = str;
+
+ while (ret.length < width) {
+ if (left)
+ ret += chr;
+ else
+ ret = chr + ret;
+ }
+
+ return (ret);
+}
+
+/*
+ * This function dumps long stack traces for exceptions having a cause() method.
+ * See node-verror for an example.
+ */
+function dumpException(ex)
+{
+ var ret;
+
+ if (!(ex instanceof Error))
+ throw (new Error(jsSprintf('invalid type for %%r: %j', ex)));
+
+ /* Note that V8 prepends "ex.stack" with ex.toString(). */
+ ret = 'EXCEPTION: ' + ex.constructor.name + ': ' + ex.stack;
+
+ if (ex.cause && typeof (ex.cause) === 'function') {
+ var cex = ex.cause();
+ if (cex) {
+ ret += '\nCaused by: ' + dumpException(cex);
+ }
+ }
+
+ return (ret);
+}
diff --git a/deps/npm/node_modules/extsprintf/package.json b/deps/npm/node_modules/extsprintf/package.json
new file mode 100644
index 0000000000..c96db9bb20
--- /dev/null
+++ b/deps/npm/node_modules/extsprintf/package.json
@@ -0,0 +1,44 @@
+{
+ "_from": "extsprintf@1.3.0",
+ "_id": "extsprintf@1.3.0",
+ "_inBundle": false,
+ "_integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
+ "_location": "/extsprintf",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "extsprintf@1.3.0",
+ "name": "extsprintf",
+ "escapedName": "extsprintf",
+ "rawSpec": "1.3.0",
+ "saveSpec": null,
+ "fetchSpec": "1.3.0"
+ },
+ "_requiredBy": [
+ "/jsprim",
+ "/verror"
+ ],
+ "_resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
+ "_shasum": "96918440e3041a7a414f8c52e3c574eb3c3e1e05",
+ "_spec": "extsprintf@1.3.0",
+ "_where": "/Users/rebecca/code/npm/node_modules/jsprim",
+ "bugs": {
+ "url": "https://github.com/davepacheco/node-extsprintf/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "extended POSIX-style sprintf",
+ "engines": [
+ "node >=0.6.0"
+ ],
+ "homepage": "https://github.com/davepacheco/node-extsprintf#readme",
+ "license": "MIT",
+ "main": "./lib/extsprintf.js",
+ "name": "extsprintf",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/davepacheco/node-extsprintf.git"
+ },
+ "version": "1.3.0"
+}