aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek')
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore21
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml7
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/CONTRIBUTING.md1
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE3
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/README.md572
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.pngbin37939 -> 0 bytes
-rwxr-xr-x[-rw-r--r--]deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js60
-rwxr-xr-x[-rw-r--r--]deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js351
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/package.json34
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js88
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js2513
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/ignore.txt0
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js1
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js1
-rw-r--r--deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js1
15 files changed, 244 insertions, 3409 deletions
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore
index 7e1574dc5c..adac8ad9c6 100644
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore
+++ b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore
@@ -1,18 +1,3 @@
-.idea
-*.iml
-npm-debug.log
-dump.rdb
-node_modules
-results.tap
-results.xml
-npm-shrinkwrap.json
-config.json
-.DS_Store
-*/.DS_Store
-*/*/.DS_Store
-._*
-*/._*
-*/*/._*
-coverage.*
-lib-cov
-complexity.md
+*
+!lib/**
+!.npmignore
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml
deleted file mode 100644
index 7a64dd2210..0000000000
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-language: node_js
-
-node_js:
- - 0.10
- - 4.0
-
-sudo: false
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/CONTRIBUTING.md b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/CONTRIBUTING.md
deleted file mode 100644
index 892836159b..0000000000
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/CONTRIBUTING.md
+++ /dev/null
@@ -1 +0,0 @@
-Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md).
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE
index 5530904255..133cbdd9ef 100644
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE
+++ b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE
@@ -1,4 +1,5 @@
-Copyright (c) 2011-2014, Walmart and other contributors.
+Copyright (c) 2011-2016, Project contributors
+Copyright (c) 2011-2014, Walmart
Copyright (c) 2011, Yahoo Inc.
All rights reserved.
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/README.md b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/README.md
index 92c4912c7e..ec7bc2538d 100644
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/README.md
+++ b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/README.md
@@ -4,581 +4,27 @@ Utility methods for the hapi ecosystem. This module is not intended to solve eve
[![Build Status](https://secure.travis-ci.org/hapijs/hoek.svg)](http://travis-ci.org/hapijs/hoek)
-Lead Maintainer: [Nathan LaFreniere](https://github.com/nlf)
-
-# Table of Contents
-
-* [Introduction](#introduction "Introduction")
-* [Object](#object "Object")
- * [clone](#cloneobj "clone")
- * [cloneWithShallow](#clonewithshallowobj-keys "cloneWithShallow")
- * [merge](#mergetarget-source-isnulloverride-ismergearrays "merge")
- * [applyToDefaults](#applytodefaultsdefaults-options-isnulloverride "applyToDefaults")
- * [applyToDefaultsWithShallow](#applytodefaultswithshallowdefaults-options-keys "applyToDefaultsWithShallow")
- * [deepEqual](#deepequala-b "deepEqual")
- * [unique](#uniquearray-key "unique")
- * [mapToObject](#maptoobjectarray-key "mapToObject")
- * [intersect](#intersectarray1-array2 "intersect")
- * [contain](#containref-values-options "contain")
- * [flatten](#flattenarray-target "flatten")
- * [reach](#reachobj-chain-options "reach")
- * [reachTemplate](#reachtemplateobj-template-options "reachTemplate")
- * [transform](#transformobj-transform-options "transform")
- * [shallow](#shallowobj "shallow")
- * [stringify](#stringifyobj "stringify")
-* [Timer](#timer "Timer")
-* [Bench](#bench "Bench")
-* [Binary Encoding/Decoding](#binary-encodingdecoding "Binary Encoding/Decoding")
- * [base64urlEncode](#base64urlencodevalue "binary64urlEncode")
- * [base64urlDecode](#base64urldecodevalue "binary64urlDecode")
-* [Escaping Characters](#escaping-characters "Escaping Characters")
- * [escapeHtml](#escapehtmlstring "escapeHtml")
- * [escapeHeaderAttribute](#escapeheaderattributeattribute "escapeHeaderAttribute")
- * [escapeRegex](#escaperegexstring "escapeRegex")
-* [Errors](#errors "Errors")
- * [assert](#assertcondition-message "assert")
- * [abort](#abortmessage "abort")
- * [displayStack](#displaystackslice "displayStack")
- * [callStack](#callstackslice "callStack")
-* [Function](#function "Function")
- * [nextTick](#nexttickfn "nextTick")
- * [once](#oncefn "once")
- * [ignore](#ignore "ignore")
-* [Miscellaneous](#miscellaneous "Miscellaneous")
- * [uniqueFilename](#uniquefilenamepath-extension "uniqueFilename")
- * [isAbsolutePath](#isabsolutepathpath-platform "isAbsolutePath")
- * [isInteger](#isintegervalue "isInteger")
+<a href="https://andyet.com"><img src="https://s3.amazonaws.com/static.andyet.com/images/%26yet-logo.svg" align="right" /></a>
+Lead Maintainer: [Nathan LaFreniere](https://github.com/nlf)
+**hoek** is sponsored by [&yet](https://andyet.com)
-# Introduction
+## Usage
The *Hoek* library contains some common functions used within the hapi ecosystem. It comes with useful methods for Arrays (clone, merge, applyToDefaults), Objects (removeKeys, copy), Asserting and more.
For example, to use Hoek to set configuration with default options:
```javascript
-var Hoek = require('hoek');
+const Hoek = require('hoek');
-var default = {url : "www.github.com", port : "8000", debug : true};
+const default = {url : "www.github.com", port : "8000", debug : true};
-var config = Hoek.applyToDefaults(default, {port : "3000", admin : true});
+const config = Hoek.applyToDefaults(default, {port : "3000", admin : true});
// In this case, config would be { url: 'www.github.com', port: '3000', debug: true, admin: true }
```
-Under each of the sections (such as Array), there are subsections which correspond to Hoek methods. Each subsection will explain how to use the corresponding method. In each js excerpt below, the `var Hoek = require('hoek');` is omitted for brevity.
-
-## Object
-
-Hoek provides several helpful methods for objects and arrays.
-
-### clone(obj)
-
-This method is used to clone an object or an array. A *deep copy* is made (duplicates everything, including values that are objects, as well as non-enumerable properties).
-
-```javascript
-
-var nestedObj = {
- w: /^something$/ig,
- x: {
- a: [1, 2, 3],
- b: 123456,
- c: new Date()
- },
- y: 'y',
- z: new Date()
- };
-
-var copy = Hoek.clone(nestedObj);
-
-copy.x.b = 100;
-
-console.log(copy.y); // results in 'y'
-console.log(nestedObj.x.b); // results in 123456
-console.log(copy.x.b); // results in 100
-```
-
-### cloneWithShallow(obj, keys)
-keys is an array of key names to shallow copy
-
-This method is also used to clone an object or array, however any keys listed in the `keys` array are shallow copied while those not listed are deep copied.
-
-```javascript
-
-var nestedObj = {
- w: /^something$/ig,
- x: {
- a: [1, 2, 3],
- b: 123456,
- c: new Date()
- },
- y: 'y',
- z: new Date()
- };
-
-var copy = Hoek.cloneWithShallow(nestedObj, ['x']);
-
-copy.x.b = 100;
-
-console.log(copy.y); // results in 'y'
-console.log(nestedObj.x.b); // results in 100
-console.log(copy.x.b); // results in 100
-```
-
-### merge(target, source, isNullOverride, isMergeArrays)
-isNullOverride, isMergeArrays default to true
-
-Merge all the properties of source into target, source wins in conflict, and by default null and undefined from source are applied.
-Merge is destructive where the target is modified. For non destructive merge, use `applyToDefaults`.
-
-
-```javascript
-
-var target = {a: 1, b : 2};
-var source = {a: 0, c: 5};
-var source2 = {a: null, c: 5};
-
-Hoek.merge(target, source); // results in {a: 0, b: 2, c: 5}
-Hoek.merge(target, source2); // results in {a: null, b: 2, c: 5}
-Hoek.merge(target, source2, false); // results in {a: 1, b: 2, c: 5}
-
-var targetArray = [1, 2, 3];
-var sourceArray = [4, 5];
-
-Hoek.merge(targetArray, sourceArray); // results in [1, 2, 3, 4, 5]
-Hoek.merge(targetArray, sourceArray, true, false); // results in [4, 5]
-```
-
-### applyToDefaults(defaults, options, isNullOverride)
-isNullOverride defaults to false
-
-Apply options to a copy of the defaults
-
-```javascript
-
-var defaults = { host: "localhost", port: 8000 };
-var options = { port: 8080 };
-
-var config = Hoek.applyToDefaults(defaults, options); // results in { host: "localhost", port: 8080 }
-```
-
-Apply options with a null value to a copy of the defaults
-
-```javascript
-
-var defaults = { host: "localhost", port: 8000 };
-var options = { host: null, port: 8080 };
-
-var config = Hoek.applyToDefaults(defaults, options, true); // results in { host: null, port: 8080 }
-```
-
-### applyToDefaultsWithShallow(defaults, options, keys)
-keys is an array of key names to shallow copy
-
-Apply options to a copy of the defaults. Keys specified in the last parameter are shallow copied from options instead of merged.
-
-```javascript
-
-var defaults = {
- server: {
- host: "localhost",
- port: 8000
- },
- name: 'example'
- };
-
-var options = { server: { port: 8080 } };
-
-var config = Hoek.applyToDefaultsWithShallow(defaults, options, ['server']); // results in { server: { port: 8080 }, name: 'example' }
-```
-
-### deepEqual(b, a, [options])
-
-Performs a deep comparison of the two values including support for circular dependencies, prototype, and properties. To skip prototype comparisons, use `options.prototype = false`
-
-```javascript
-Hoek.deepEqual({ a: [1, 2], b: 'string', c: { d: true } }, { a: [1, 2], b: 'string', c: { d: true } }); //results in true
-Hoek.deepEqual(Object.create(null), {}, { prototype: false }); //results in true
-Hoek.deepEqual(Object.create(null), {}); //results in false
-```
-
-### unique(array, key)
-
-Remove duplicate items from Array
-
-```javascript
-
-var array = [1, 2, 2, 3, 3, 4, 5, 6];
-
-var newArray = Hoek.unique(array); // results in [1,2,3,4,5,6]
-
-array = [{id: 1}, {id: 1}, {id: 2}];
-
-newArray = Hoek.unique(array, "id"); // results in [{id: 1}, {id: 2}]
-```
-
-### mapToObject(array, key)
-
-Convert an Array into an Object
-
-```javascript
-
-var array = [1,2,3];
-var newObject = Hoek.mapToObject(array); // results in [{"1": true}, {"2": true}, {"3": true}]
-
-array = [{id: 1}, {id: 2}];
-newObject = Hoek.mapToObject(array, "id"); // results in [{"id": 1}, {"id": 2}]
-```
-
-### intersect(array1, array2)
-
-Find the common unique items in two arrays
-
-```javascript
-
-var array1 = [1, 2, 3];
-var array2 = [1, 4, 5];
-
-var newArray = Hoek.intersect(array1, array2); // results in [1]
-```
-
-### contain(ref, values, [options])
-
-Tests if the reference value contains the provided values where:
-- `ref` - the reference string, array, or object.
-- `values` - a single or array of values to find within the `ref` value. If `ref` is an object, `values` can be a key name,
- an array of key names, or an object with key-value pairs to compare.
-- `options` - an optional object with the following optional settings:
- - `deep` - if `true`, performed a deep comparison of the values.
- - `once` - if `true`, allows only one occurrence of each value.
- - `only` - if `true`, does not allow values not explicitly listed.
- - `part` - if `true`, allows partial match of the values (at least one must always match).
-
-Note: comparing a string to overlapping values will result in failed comparison (e.g. `contain('abc', ['ab', 'bc'])`).
-Also, if an object key's value does not match the provided value, `false` is returned even when `part` is specified.
-
-```javascript
-Hoek.contain('aaa', 'a', { only: true }); // true
-Hoek.contain([{ a: 1 }], [{ a: 1 }], { deep: true }); // true
-Hoek.contain([1, 2, 2], [1, 2], { once: true }); // false
-Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1, d: 4 }, { part: true }); // true
-```
-
-### flatten(array, [target])
-
-Flatten an array
-
-```javascript
-
-var array = [1, [2, 3]];
-
-var flattenedArray = Hoek.flatten(array); // results in [1, 2, 3]
-
-array = [1, [2, 3]];
-target = [4, [5]];
-
-flattenedArray = Hoek.flatten(array, target); // results in [4, [5], 1, 2, 3]
-```
-
-### reach(obj, chain, [options])
-
-Converts an object key chain string to reference
-
-- `options` - optional settings
- - `separator` - string to split chain path on, defaults to '.'
- - `default` - value to return if the path or value is not present, default is `undefined`
- - `strict` - if `true`, will throw an error on missing member, default is `false`
- - `functions` - if `true` allow traversing functions for properties. `false` will throw an error if a function is part of the chain.
-
-A chain including negative numbers will work like negative indices on an
-array.
-
-If chain is `null`, `undefined` or `false`, the object itself will be returned.
-
-```javascript
-
-var chain = 'a.b.c';
-var obj = {a : {b : { c : 1}}};
-
-Hoek.reach(obj, chain); // returns 1
-
-var chain = 'a.b.-1';
-var obj = {a : {b : [2,3,6]}};
-
-Hoek.reach(obj, chain); // returns 6
-```
-
-### reachTemplate(obj, template, [options])
-
-Replaces string parameters (`{name}`) with their corresponding object key values by applying the
-(`reach()`)[#reachobj-chain-options] method where:
-
-- `obj` - the context object used for key lookup.
-- `template` - a string containing `{}` parameters.
-- `options` - optional (`reach()`)[#reachobj-chain-options] options.
-
-```javascript
-
-var chain = 'a.b.c';
-var obj = {a : {b : { c : 1}}};
-
-Hoek.reachTemplate(obj, '1+{a.b.c}=2'); // returns '1+1=2'
-```
-
-### transform(obj, transform, [options])
-
-Transforms an existing object into a new one based on the supplied `obj` and `transform` map. `options` are the same as the `reach` options. The first argument can also be an array of objects. In that case the method will return an array of transformed objects.
-
-```javascript
-var source = {
- address: {
- one: '123 main street',
- two: 'PO Box 1234'
- },
- title: 'Warehouse',
- state: 'CA'
-};
-
-var result = Hoek.transform(source, {
- 'person.address.lineOne': 'address.one',
- 'person.address.lineTwo': 'address.two',
- 'title': 'title',
- 'person.address.region': 'state'
-});
-// Results in
-// {
-// person: {
-// address: {
-// lineOne: '123 main street',
-// lineTwo: 'PO Box 1234',
-// region: 'CA'
-// }
-// },
-// title: 'Warehouse'
-// }
-```
-
-### shallow(obj)
-
-Performs a shallow copy by copying the references of all the top level children where:
-- `obj` - the object to be copied.
-
-```javascript
-var shallow = Hoek.shallow({ a: { b: 1 } });
-```
-
-### stringify(obj)
-
-Converts an object to string using the built-in `JSON.stringify()` method with the difference that any errors are caught
-and reported back in the form of the returned string. Used as a shortcut for displaying information to the console (e.g. in
-error message) without the need to worry about invalid conversion.
-
-```javascript
-var a = {};
-a.b = a;
-Hoek.stringify(a); // Returns '[Cannot display object: Converting circular structure to JSON]'
-```
-
-# Timer
-
-A Timer object. Initializing a new timer object sets the ts to the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
-
-```javascript
-
-var timerObj = new Hoek.Timer();
-console.log("Time is now: " + timerObj.ts);
-console.log("Elapsed time from initialization: " + timerObj.elapsed() + 'milliseconds');
-```
-
-
-# Bench
-
-Same as Timer with the exception that `ts` stores the internal node clock which is not related to `Date.now()` and cannot be used to display
-human-readable timestamps. More accurate for benchmarking or internal timers.
-
-# Binary Encoding/Decoding
-
-### base64urlEncode(value)
-
-Encodes value in Base64 or URL encoding
-
-### base64urlDecode(value)
-
-Decodes data in Base64 or URL encoding.
-# Escaping Characters
-
-Hoek provides convenient methods for escaping html characters. The escaped characters are as followed:
-
-```javascript
-
-internals.htmlEscaped = {
- '&': '&amp;',
- '<': '&lt;',
- '>': '&gt;',
- '"': '&quot;',
- "'": '&#x27;',
- '`': '&#x60;'
-};
-```
-
-### escapeHtml(string)
-
-```javascript
-
-var string = '<html> hey </html>';
-var escapedString = Hoek.escapeHtml(string); // returns &lt;html&gt; hey &lt;/html&gt;
-```
-
-### escapeHeaderAttribute(attribute)
-
-Escape attribute value for use in HTTP header
-
-```javascript
-
-var a = Hoek.escapeHeaderAttribute('I said "go w\\o me"'); //returns I said \"go w\\o me\"
-```
-
-
-### escapeRegex(string)
-
-Escape string for Regex construction
-
-```javascript
-
-var a = Hoek.escapeRegex('4^f$s.4*5+-_?%=#!:@|~\\/`"(>)[<]d{}s,'); // returns 4\^f\$s\.4\*5\+\-_\?%\=#\!\:@\|~\\\/`"\(>\)\[<\]d\{\}s\,
-```
-
-# Errors
-
-### assert(condition, message)
-
-```javascript
-
-var a = 1, b = 2;
+## Documentation
-Hoek.assert(a === b, 'a should equal b'); // Throws 'a should equal b'
-```
-
-Note that you may also pass an already created Error object as the second parameter, and `assert` will throw that object.
-
-```javascript
-
-var a = 1, b = 2;
-
-Hoek.assert(a === b, new Error('a should equal b')); // Throws the given error object
-```
-
-### abort(message)
-
-First checks if `process.env.NODE_ENV === 'test'`, and if so, throws error message. Otherwise,
-displays most recent stack and then exits process.
-
-
-
-### displayStack(slice)
-
-Displays the trace stack
-
-```javascript
-
-var stack = Hoek.displayStack();
-console.log(stack); // returns something like:
-
-[ 'null (/Users/user/Desktop/hoek/test.js:4:18)',
- 'Module._compile (module.js:449:26)',
- 'Module._extensions..js (module.js:467:10)',
- 'Module.load (module.js:356:32)',
- 'Module._load (module.js:312:12)',
- 'Module.runMain (module.js:492:10)',
- 'startup.processNextTick.process._tickCallback (node.js:244:9)' ]
-```
-
-### callStack(slice)
-
-Returns a trace stack array.
-
-```javascript
-
-var stack = Hoek.callStack();
-console.log(stack); // returns something like:
-
-[ [ '/Users/user/Desktop/hoek/test.js', 4, 18, null, false ],
- [ 'module.js', 449, 26, 'Module._compile', false ],
- [ 'module.js', 467, 10, 'Module._extensions..js', false ],
- [ 'module.js', 356, 32, 'Module.load', false ],
- [ 'module.js', 312, 12, 'Module._load', false ],
- [ 'module.js', 492, 10, 'Module.runMain', false ],
- [ 'node.js',
- 244,
- 9,
- 'startup.processNextTick.process._tickCallback',
- false ] ]
-```
-
-## Function
-
-### nextTick(fn)
-
-Returns a new function that wraps `fn` in `process.nextTick`.
-
-```javascript
-
-var myFn = function () {
- console.log('Do this later');
-};
-
-var nextFn = Hoek.nextTick(myFn);
-
-nextFn();
-console.log('Do this first');
-
-// Results in:
-//
-// Do this first
-// Do this later
-```
-
-### once(fn)
-
-Returns a new function that can be run multiple times, but makes sure `fn` is only run once.
-
-```javascript
-
-var myFn = function () {
- console.log('Ran myFn');
-};
-
-var onceFn = Hoek.once(myFn);
-onceFn(); // results in "Ran myFn"
-onceFn(); // results in undefined
-```
-
-### ignore
-
-A simple no-op function. It does nothing at all.
-
-## Miscellaneous
-
-### uniqueFilename(path, extension)
-`path` to prepend with the randomly generated file name. `extension` is the optional file extension, defaults to `''`.
-
-Returns a randomly generated file name at the specified `path`. The result is a fully resolved path to a file.
-
-```javascript
-var result = Hoek.uniqueFilename('./test/modules', 'txt'); // results in "full/path/test/modules/{random}.txt"
-```
-
-### isAbsolutePath(path, [platform])
-
-Determines whether `path` is an absolute path. Returns `true` or `false`.
-
-- `path` - A file path to test for whether it is absolute or not.
-- `platform` - An optional parameter used for specifying the platform. Defaults to `process.platform`.
-
-### isInteger(value)
-
-Check `value` to see if it is an integer. Returns true/false.
-
-```javascript
-var result = Hoek.isInteger('23')
-```
+[**API Reference**](API.md)
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png
deleted file mode 100644
index 6ccfcb12be..0000000000
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png
+++ /dev/null
Binary files differ
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js
index 9ecde6666b..28d90ba479 100644..100755
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js
+++ b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js
@@ -1,6 +1,8 @@
+'use strict';
+
// Declare internals
-var internals = {};
+const internals = {};
exports.escapeJavaScript = function (input) {
@@ -9,11 +11,11 @@ exports.escapeJavaScript = function (input) {
return '';
}
- var escaped = '';
+ let escaped = '';
- for (var i = 0, il = input.length; i < il; ++i) {
+ for (let i = 0; i < input.length; ++i) {
- var charCode = input.charCodeAt(i);
+ const charCode = input.charCodeAt(i);
if (internals.isSafe(charCode)) {
escaped += input[i];
@@ -33,11 +35,11 @@ exports.escapeHtml = function (input) {
return '';
}
- var escaped = '';
+ let escaped = '';
- for (var i = 0, il = input.length; i < il; ++i) {
+ for (let i = 0; i < input.length; ++i) {
- var charCode = input.charCodeAt(i);
+ const charCode = input.charCodeAt(i);
if (internals.isSafe(charCode)) {
escaped += input[i];
@@ -51,20 +53,54 @@ exports.escapeHtml = function (input) {
};
+exports.escapeJson = function (input) {
+
+ if (!input) {
+ return '';
+ }
+
+ const lessThan = 0x3C;
+ const greaterThan = 0x3E;
+ const andSymbol = 0x26;
+ const lineSeperator = 0x2028;
+
+ // replace method
+ let charCode;
+ return input.replace(/[<>&\u2028\u2029]/g, (match) => {
+
+ charCode = match.charCodeAt(0);
+
+ if (charCode === lessThan) {
+ return '\\u003c';
+ }
+ else if (charCode === greaterThan) {
+ return '\\u003e';
+ }
+ else if (charCode === andSymbol) {
+ return '\\u0026';
+ }
+ else if (charCode === lineSeperator) {
+ return '\\u2028';
+ }
+ return '\\u2029';
+ });
+};
+
+
internals.escapeJavaScriptChar = function (charCode) {
if (charCode >= 256) {
return '\\u' + internals.padLeft('' + charCode, 4);
}
- var hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex');
+ const hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex');
return '\\x' + internals.padLeft(hexValue, 2);
};
internals.escapeHtmlChar = function (charCode) {
- var namedEscape = internals.namedHtml[charCode];
+ const namedEscape = internals.namedHtml[charCode];
if (typeof namedEscape !== 'undefined') {
return namedEscape;
}
@@ -73,7 +109,7 @@ internals.escapeHtmlChar = function (charCode) {
return '&#' + charCode + ';';
}
- var hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex');
+ const hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex');
return '&#x' + internals.padLeft(hexValue, 2) + ';';
};
@@ -110,9 +146,9 @@ internals.namedHtml = {
internals.safeCharCodes = (function () {
- var safe = {};
+ const safe = {};
- for (var i = 32; i < 123; ++i) {
+ for (let i = 32; i < 123; ++i) {
if ((i >= 97) || // a-z
(i >= 65 && i <= 90) || // A-Z
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js
index 9a5ffe18f4..8c3273eb01 100644..100755
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js
+++ b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js
@@ -1,14 +1,16 @@
+'use strict';
+
// Load modules
-var Crypto = require('crypto');
-var Path = require('path');
-var Util = require('util');
-var Escape = require('./escape');
+const Crypto = require('crypto');
+const Path = require('path');
+const Util = require('util');
+const Escape = require('./escape');
// Declare internals
-var internals = {};
+const internals = {};
// Clone object or array
@@ -21,15 +23,15 @@ exports.clone = function (obj, seen) {
return obj;
}
- seen = seen || { orig: [], copy: [] };
+ seen = seen || new Map();
- var lookup = seen.orig.indexOf(obj);
- if (lookup !== -1) {
- return seen.copy[lookup];
+ const lookup = seen.get(obj);
+ if (lookup) {
+ return lookup;
}
- var newObj;
- var cloneDeep = false;
+ let newObj;
+ let cloneDeep = false;
if (!Array.isArray(obj)) {
if (Buffer.isBuffer(obj)) {
@@ -42,7 +44,7 @@ exports.clone = function (obj, seen) {
newObj = new RegExp(obj);
}
else {
- var proto = Object.getPrototypeOf(obj);
+ const proto = Object.getPrototypeOf(obj);
if (proto &&
proto.isImmutable) {
@@ -59,14 +61,13 @@ exports.clone = function (obj, seen) {
cloneDeep = true;
}
- seen.orig.push(obj);
- seen.copy.push(newObj);
+ seen.set(obj, newObj);
if (cloneDeep) {
- var keys = Object.getOwnPropertyNames(obj);
- for (var i = 0, il = keys.length; i < il; ++i) {
- var key = keys[i];
- var descriptor = Object.getOwnPropertyDescriptor(obj, key);
+ const keys = Object.getOwnPropertyNames(obj);
+ for (let i = 0; i < keys.length; ++i) {
+ const key = keys[i];
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
if (descriptor &&
(descriptor.get ||
descriptor.set)) {
@@ -84,9 +85,11 @@ exports.clone = function (obj, seen) {
// Merge all the properties of source into target, source wins in conflict, and by default null and undefined from source are applied
+
/*eslint-disable */
exports.merge = function (target, source, isNullOverride /* = true */, isMergeArrays /* = true */) {
/*eslint-enable */
+
exports.assert(target && typeof target === 'object', 'Invalid target value: must be an object');
exports.assert(source === null || source === undefined || typeof source === 'object', 'Invalid source value: must be null, undefined, or an object');
@@ -100,23 +103,23 @@ exports.merge = function (target, source, isNullOverride /* = true */, isMergeAr
target.length = 0; // Must not change target assignment
}
- for (var i = 0, il = source.length; i < il; ++i) {
+ for (let i = 0; i < source.length; ++i) {
target.push(exports.clone(source[i]));
}
return target;
}
- var keys = Object.keys(source);
- for (var k = 0, kl = keys.length; k < kl; ++k) {
- var key = keys[k];
- var value = source[key];
+ const keys = Object.keys(source);
+ for (let i = 0; i < keys.length; ++i) {
+ const key = keys[i];
+ const value = source[key];
if (value &&
typeof value === 'object') {
if (!target[key] ||
typeof target[key] !== 'object' ||
- (Array.isArray(target[key]) ^ Array.isArray(value)) ||
+ (Array.isArray(target[key]) !== Array.isArray(value)) ||
value instanceof Date ||
Buffer.isBuffer(value) ||
value instanceof RegExp) {
@@ -154,7 +157,7 @@ exports.applyToDefaults = function (defaults, options, isNullOverride) {
return null;
}
- var copy = exports.clone(defaults);
+ const copy = exports.clone(defaults);
if (options === true) { // If options is set to true, use defaults
return copy;
@@ -174,8 +177,8 @@ exports.cloneWithShallow = function (source, keys) {
return source;
}
- var storage = internals.store(source, keys); // Move shallow copy items to storage
- var copy = exports.clone(source); // Deep copy the rest
+ const storage = internals.store(source, keys); // Move shallow copy items to storage
+ const copy = exports.clone(source); // Deep copy the rest
internals.restore(copy, source, storage); // Shallow copy the stored items and restore
return copy;
};
@@ -183,10 +186,10 @@ exports.cloneWithShallow = function (source, keys) {
internals.store = function (source, keys) {
- var storage = {};
- for (var i = 0, il = keys.length; i < il; ++i) {
- var key = keys[i];
- var value = exports.reach(source, key);
+ const storage = {};
+ for (let i = 0; i < keys.length; ++i) {
+ const key = keys[i];
+ const value = exports.reach(source, key);
if (value !== undefined) {
storage[key] = value;
internals.reachSet(source, key, undefined);
@@ -199,9 +202,9 @@ internals.store = function (source, keys) {
internals.restore = function (copy, source, storage) {
- var keys = Object.keys(storage);
- for (var i = 0, il = keys.length; i < il; ++i) {
- var key = keys[i];
+ const keys = Object.keys(storage);
+ for (let i = 0; i < keys.length; ++i) {
+ const key = keys[i];
internals.reachSet(copy, key, storage[key]);
internals.reachSet(source, key, storage[key]);
}
@@ -210,11 +213,11 @@ internals.restore = function (copy, source, storage) {
internals.reachSet = function (obj, key, value) {
- var path = key.split('.');
- var ref = obj;
- for (var i = 0, il = path.length; i < il; ++i) {
- var segment = path[i];
- if (i + 1 === il) {
+ const path = key.split('.');
+ let ref = obj;
+ for (let i = 0; i < path.length; ++i) {
+ const segment = path[i];
+ if (i + 1 === path.length) {
ref[segment] = value;
}
@@ -235,13 +238,13 @@ exports.applyToDefaultsWithShallow = function (defaults, options, keys) {
return null;
}
- var copy = exports.cloneWithShallow(defaults, keys);
+ const copy = exports.cloneWithShallow(defaults, keys);
if (options === true) { // If options is set to true, use defaults
return copy;
}
- var storage = internals.store(options, keys); // Move shallow copy items to storage
+ const storage = internals.store(options, keys); // Move shallow copy items to storage
exports.merge(copy, options, false, false); // Deep copy the rest
internals.restore(copy, options, storage); // Shallow copy the stored items and restore
return copy;
@@ -254,7 +257,7 @@ exports.deepEqual = function (obj, ref, options, seen) {
options = options || { prototype: true };
- var type = typeof obj;
+ const type = typeof obj;
if (type !== typeof ref) {
return false;
@@ -287,11 +290,11 @@ exports.deepEqual = function (obj, ref, options, seen) {
return false;
}
- for (var i = 0, il = obj.length; i < il; ++i) {
+ for (let i = 0; i < obj.length; ++i) {
if (options.part) {
- var found = false;
- for (var r = 0, rl = ref.length; r < rl; ++r) {
- if (exports.deepEqual(obj[i], ref[r], options, seen)) {
+ let found = false;
+ for (let j = 0; j < ref.length; ++j) {
+ if (exports.deepEqual(obj[i], ref[j], options)) {
found = true;
break;
}
@@ -300,7 +303,7 @@ exports.deepEqual = function (obj, ref, options, seen) {
return found;
}
- if (!exports.deepEqual(obj[i], ref[i], options, seen)) {
+ if (!exports.deepEqual(obj[i], ref[i], options)) {
return false;
}
}
@@ -317,8 +320,8 @@ exports.deepEqual = function (obj, ref, options, seen) {
return false;
}
- for (var j = 0, jl = obj.length; j < jl; ++j) {
- if (obj[j] !== ref[j]) {
+ for (let i = 0; i < obj.length; ++i) {
+ if (obj[i] !== ref[i]) {
return false;
}
}
@@ -340,15 +343,15 @@ exports.deepEqual = function (obj, ref, options, seen) {
}
}
- var keys = Object.getOwnPropertyNames(obj);
+ const keys = Object.getOwnPropertyNames(obj);
if (!options.part && keys.length !== Object.getOwnPropertyNames(ref).length) {
return false;
}
- for (var k = 0, kl = keys.length; k < kl; ++k) {
- var key = keys[k];
- var descriptor = Object.getOwnPropertyDescriptor(obj, key);
+ for (let i = 0; i < keys.length; ++i) {
+ const key = keys[i];
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
if (descriptor.get) {
if (!exports.deepEqual(descriptor, Object.getOwnPropertyDescriptor(ref, key), options, seen)) {
return false;
@@ -365,18 +368,23 @@ exports.deepEqual = function (obj, ref, options, seen) {
// Remove duplicate items from array
-exports.unique = function (array, key) {
+exports.unique = (array, key) => {
- var index = {};
- var result = [];
+ let result;
+ if (key) {
+ result = [];
+ const index = new Set();
+ array.forEach((item) => {
- for (var i = 0, il = array.length; i < il; ++i) {
- var id = (key ? array[i][key] : array[i]);
- if (index[id] !== true) {
-
- result.push(array[i]);
- index[id] = true;
- }
+ const identifier = item[key];
+ if (!index.has(identifier)) {
+ index.add(identifier);
+ result.push(item);
+ }
+ });
+ }
+ else {
+ result = Array.from(new Set(array));
}
return result;
@@ -391,8 +399,8 @@ exports.mapToObject = function (array, key) {
return null;
}
- var obj = {};
- for (var i = 0, il = array.length; i < il; ++i) {
+ const obj = {};
+ for (let i = 0; i < array.length; ++i) {
if (key) {
if (array[i][key]) {
obj[array[i][key]] = true;
@@ -415,10 +423,10 @@ exports.intersect = function (array1, array2, justFirst) {
return [];
}
- var common = [];
- var hash = (Array.isArray(array1) ? exports.mapToObject(array1) : array1);
- var found = {};
- for (var i = 0, il = array2.length; i < il; ++i) {
+ const common = [];
+ const hash = (Array.isArray(array1) ? exports.mapToObject(array1) : array1);
+ const found = {};
+ for (let i = 0; i < array2.length; ++i) {
if (hash[array2[i]] && !found[array2[i]]) {
if (justFirst) {
return array2[i];
@@ -444,7 +452,7 @@ exports.contain = function (ref, values, options) {
object -> object (key:value)
*/
- var valuePairs = null;
+ let valuePairs = null;
if (typeof ref === 'object' &&
typeof values === 'object' &&
!Array.isArray(ref) &&
@@ -463,11 +471,13 @@ exports.contain = function (ref, values, options) {
exports.assert(typeof ref === 'string' || typeof ref === 'object', 'Reference must be string or an object');
exports.assert(values.length, 'Values array cannot be empty');
- var compare, compareFlags;
+ let compare;
+ let compareFlags;
if (options.deep) {
compare = exports.deepEqual;
- var hasOnly = options.hasOwnProperty('only'), hasPart = options.hasOwnProperty('part');
+ const hasOnly = options.hasOwnProperty('only');
+ const hasPart = options.hasOwnProperty('part');
compareFlags = {
prototype: hasOnly ? options.only : hasPart ? !options.part : false,
@@ -475,30 +485,27 @@ exports.contain = function (ref, values, options) {
};
}
else {
- compare = function (a, b) {
-
- return a === b;
- };
+ compare = (a, b) => a === b;
}
- var misses = false;
- var matches = new Array(values.length);
- for (var i = 0, il = matches.length; i < il; ++i) {
+ let misses = false;
+ const matches = new Array(values.length);
+ for (let i = 0; i < matches.length; ++i) {
matches[i] = 0;
}
if (typeof ref === 'string') {
- var pattern = '(';
- for (i = 0, il = values.length; i < il; ++i) {
- var value = values[i];
+ let pattern = '(';
+ for (let i = 0; i < values.length; ++i) {
+ const value = values[i];
exports.assert(typeof value === 'string', 'Cannot compare string reference to non-string value');
pattern += (i ? '|' : '') + exports.escapeRegex(value);
}
- var regex = new RegExp(pattern + ')', 'g');
- var leftovers = ref.replace(regex, function ($0, $1) {
+ const regex = new RegExp(pattern + ')', 'g');
+ const leftovers = ref.replace(regex, ($0, $1) => {
- var index = values.indexOf($1);
+ const index = values.indexOf($1);
++matches[index];
return ''; // Remove from string
});
@@ -506,8 +513,9 @@ exports.contain = function (ref, values, options) {
misses = !!leftovers;
}
else if (Array.isArray(ref)) {
- for (i = 0, il = ref.length; i < il; ++i) {
- for (var j = 0, jl = values.length, matched = false; j < jl && matched === false; ++j) {
+ for (let i = 0; i < ref.length; ++i) {
+ let matched = false;
+ for (let j = 0; j < values.length && matched === false; ++j) {
matched = compare(values[j], ref[i], compareFlags) && j;
}
@@ -520,10 +528,10 @@ exports.contain = function (ref, values, options) {
}
}
else {
- var keys = Object.keys(ref);
- for (i = 0, il = keys.length; i < il; ++i) {
- var key = keys[i];
- var pos = values.indexOf(key);
+ const keys = Object.getOwnPropertyNames(ref);
+ for (let i = 0; i < keys.length; ++i) {
+ const key = keys[i];
+ const pos = values.indexOf(key);
if (pos !== -1) {
if (valuePairs &&
!compare(valuePairs[key], ref[key], compareFlags)) {
@@ -539,8 +547,8 @@ exports.contain = function (ref, values, options) {
}
}
- var result = false;
- for (i = 0, il = matches.length; i < il; ++i) {
+ let result = false;
+ for (let i = 0; i < matches.length; ++i) {
result = result || !!matches[i];
if ((options.once && matches[i] > 1) ||
(!options.part && !matches[i])) {
@@ -563,9 +571,9 @@ exports.contain = function (ref, values, options) {
exports.flatten = function (array, target) {
- var result = target || [];
+ const result = target || [];
- for (var i = 0, il = array.length; i < il; ++i) {
+ for (let i = 0; i < array.length; ++i) {
if (Array.isArray(array[i])) {
exports.flatten(array[i], result);
}
@@ -594,20 +602,20 @@ exports.reach = function (obj, chain, options) {
options = { separator: options };
}
- var path = chain.split(options.separator || '.');
- var ref = obj;
- for (var i = 0, il = path.length; i < il; ++i) {
- var key = path[i];
+ const path = chain.split(options.separator || '.');
+ let ref = obj;
+ for (let i = 0; i < path.length; ++i) {
+ let key = path[i];
if (key[0] === '-' && Array.isArray(ref)) {
key = key.slice(1, key.length);
key = ref.length - key;
}
if (!ref ||
- !ref.hasOwnProperty(key) ||
+ !((typeof ref === 'object' || typeof ref === 'function') && key in ref) ||
(typeof ref !== 'object' && options.functions === false)) { // Only object and function can have properties
- exports.assert(!options.strict || i + 1 === il, 'Missing segment', key, 'in reach path ', chain);
+ exports.assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);
exports.assert(typeof ref === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);
ref = options.default;
break;
@@ -622,9 +630,9 @@ exports.reach = function (obj, chain, options) {
exports.reachTemplate = function (obj, template, options) {
- return template.replace(/{([^}]+)}/g, function ($0, chain) {
+ return template.replace(/{([^}]+)}/g, ($0, chain) => {
- var value = exports.reach(obj, chain, options);
+ const value = exports.reach(obj, chain, options);
return (value === undefined || value === null ? '' : value);
});
};
@@ -632,9 +640,9 @@ exports.reachTemplate = function (obj, template, options) {
exports.formatStack = function (stack) {
- var trace = [];
- for (var i = 0, il = stack.length; i < il; ++i) {
- var item = stack[i];
+ const trace = [];
+ for (let i = 0; i < stack.length; ++i) {
+ const item = stack[i];
trace.push([item.getFileName(), item.getLineNumber(), item.getColumnNumber(), item.getFunctionName(), item.isConstructor()]);
}
@@ -644,10 +652,10 @@ exports.formatStack = function (stack) {
exports.formatTrace = function (trace) {
- var display = [];
+ const display = [];
- for (var i = 0, il = trace.length; i < il; ++i) {
- var row = trace[i];
+ for (let i = 0; i < trace.length; ++i) {
+ const row = trace[i];
display.push((row[4] ? 'new ' : '') + row[3] + ' (' + row[0] + ':' + row[1] + ':' + row[2] + ')');
}
@@ -659,31 +667,27 @@ exports.callStack = function (slice) {
// http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
- var v8 = Error.prepareStackTrace;
- Error.prepareStackTrace = function (err, stack) {
+ const v8 = Error.prepareStackTrace;
+ Error.prepareStackTrace = function (_, stack) {
return stack;
};
- var capture = {};
- Error.captureStackTrace(capture, arguments.callee); /*eslint no-caller:0 */
- var stack = capture.stack;
+ const capture = {};
+ Error.captureStackTrace(capture, this); // arguments.callee is not supported in strict mode so we use this and slice the trace of this off the result
+ const stack = capture.stack;
Error.prepareStackTrace = v8;
- var trace = exports.formatStack(stack);
-
- if (slice) {
- return trace.slice(slice);
- }
+ const trace = exports.formatStack(stack);
- return trace;
+ return trace.slice(1 + slice);
};
exports.displayStack = function (slice) {
- var trace = exports.callStack(slice === undefined ? 1 : slice + 1);
+ const trace = exports.callStack(slice === undefined ? 1 : slice + 1);
return exports.formatTrace(trace);
};
@@ -698,7 +702,7 @@ exports.abort = function (message, hideStack) {
throw new Error(message || 'Unknown error');
}
- var stack = '';
+ let stack = '';
if (!hideStack) {
stack = exports.displayStack(1).join('\n\t');
}
@@ -717,17 +721,18 @@ exports.assert = function (condition /*, msg1, msg2, msg3 */) {
throw arguments[1];
}
- var msgs = [];
- for (var i = 1, il = arguments.length; i < il; ++i) {
+ let msgs = [];
+ for (let i = 1; i < arguments.length; ++i) {
if (arguments[i] !== '') {
msgs.push(arguments[i]); // Avoids Array.slice arguments leak, allowing for V8 optimizations
}
}
- msgs = msgs.map(function (msg) {
+ msgs = msgs.map((msg) => {
return typeof msg === 'string' ? msg : msg instanceof Error ? msg.message : exports.stringify(msg);
});
+
throw new Error(msgs.join(' ') || 'Unknown error');
};
@@ -772,7 +777,7 @@ exports.Bench.prototype.elapsed = function () {
exports.Bench.now = function () {
- var ts = process.hrtime();
+ const ts = process.hrtime();
return (ts[0] * 1e3) + (ts[1] / 1e6);
};
@@ -790,7 +795,8 @@ exports.escapeRegex = function (string) {
exports.base64urlEncode = function (value, encoding) {
- var buf = (Buffer.isBuffer(value) ? value : new Buffer(value, encoding || 'binary'));
+ exports.assert(typeof value === 'string' || Buffer.isBuffer(value), 'value must be string or buffer');
+ const buf = (Buffer.isBuffer(value) ? value : new Buffer(value, encoding || 'binary'));
return buf.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
};
@@ -799,19 +805,18 @@ exports.base64urlEncode = function (value, encoding) {
exports.base64urlDecode = function (value, encoding) {
- if (value &&
- !/^[\w\-]*$/.test(value)) {
+ if (typeof value !== 'string') {
- return new Error('Invalid character');
+ return new Error('Value not a string');
}
- try {
- var buf = new Buffer(value, 'base64');
- return (encoding === 'buffer' ? buf : buf.toString(encoding || 'binary'));
- }
- catch (err) {
- return err;
+ if (!/^[\w\-]*$/.test(value)) {
+
+ return new Error('Invalid character');
}
+
+ const buf = new Buffer(value, 'base64');
+ return (encoding === 'buffer' ? buf : buf.toString(encoding || 'binary'));
};
@@ -838,13 +843,17 @@ exports.escapeJavaScript = function (string) {
return Escape.escapeJavaScript(string);
};
+exports.escapeJson = function (string) {
+
+ return Escape.escapeJson(string);
+};
exports.nextTick = function (callback) {
return function () {
- var args = arguments;
- process.nextTick(function () {
+ const args = arguments;
+ process.nextTick(() => {
callback.apply(null, args);
});
@@ -858,8 +867,8 @@ exports.once = function (method) {
return method;
}
- var once = false;
- var wrapped = function () {
+ let once = false;
+ const wrapped = function () {
if (!once) {
once = true;
@@ -873,36 +882,7 @@ exports.once = function (method) {
};
-exports.isAbsolutePath = function (path, platform) {
-
- if (!path) {
- return false;
- }
-
- if (Path.isAbsolute) { // node >= 0.11
- return Path.isAbsolute(path);
- }
-
- platform = platform || process.platform;
-
- // Unix
-
- if (platform !== 'win32') {
- return path[0] === '/';
- }
-
- // Windows
-
- return !!/^(?:[a-zA-Z]:[\\\/])|(?:[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/])/.test(path); // C:\ or \\something\something
-};
-
-
-exports.isInteger = function (value) {
-
- return (typeof value === 'number' &&
- parseFloat(value) === parseInt(value, 10) &&
- !isNaN(value));
-};
+exports.isInteger = Number.isSafeInteger;
exports.ignore = function () { };
@@ -917,27 +897,28 @@ exports.format = Util.format;
exports.transform = function (source, transform, options) {
exports.assert(source === null || source === undefined || typeof source === 'object' || Array.isArray(source), 'Invalid source object: must be null, undefined, an object, or an array');
+ const separator = (typeof options === 'object' && options !== null) ? (options.separator || '.') : '.';
if (Array.isArray(source)) {
- var results = [];
- for (var i = 0, il = source.length; i < il; ++i) {
+ const results = [];
+ for (let i = 0; i < source.length; ++i) {
results.push(exports.transform(source[i], transform, options));
}
return results;
}
- var result = {};
- var keys = Object.keys(transform);
+ const result = {};
+ const keys = Object.keys(transform);
- for (var k = 0, kl = keys.length; k < kl; ++k) {
- var key = keys[k];
- var path = key.split('.');
- var sourcePath = transform[key];
+ for (let i = 0; i < keys.length; ++i) {
+ const key = keys[i];
+ const path = key.split(separator);
+ const sourcePath = transform[key];
exports.assert(typeof sourcePath === 'string', 'All mappings must be "." delineated strings');
- var segment;
- var res = result;
+ let segment;
+ let res = result;
while (path.length > 1) {
segment = path.shift();
@@ -964,7 +945,7 @@ exports.uniqueFilename = function (path, extension) {
}
path = Path.resolve(path);
- var name = [Date.now(), process.pid, Crypto.randomBytes(8).toString('hex')].join('-') + extension;
+ const name = [Date.now(), process.pid, Crypto.randomBytes(8).toString('hex')].join('-') + extension;
return Path.join(path, name);
};
@@ -982,10 +963,10 @@ exports.stringify = function () {
exports.shallow = function (source) {
- var target = {};
- var keys = Object.keys(source);
- for (var i = 0, il = keys.length; i < il; ++i) {
- var key = keys[i];
+ const target = {};
+ const keys = Object.keys(source);
+ for (let i = 0; i < keys.length; ++i) {
+ const key = keys[i];
target[key] = source[key];
}
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/package.json b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/package.json
index cb73c26da5..6d59b75583 100644
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/package.json
+++ b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/package.json
@@ -1,30 +1,30 @@
{
- "_from": "hoek@2.x.x",
- "_id": "hoek@2.16.3",
- "_integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=",
+ "_from": "hoek@4.x.x",
+ "_id": "hoek@4.2.0",
+ "_inBundle": false,
+ "_integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==",
"_location": "/request/hawk/hoek",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
- "raw": "hoek@2.x.x",
+ "raw": "hoek@4.x.x",
"name": "hoek",
"escapedName": "hoek",
- "rawSpec": "2.x.x",
+ "rawSpec": "4.x.x",
"saveSpec": null,
- "fetchSpec": "2.x.x"
+ "fetchSpec": "4.x.x"
},
"_requiredBy": [
"/request/hawk",
"/request/hawk/boom",
+ "/request/hawk/cryptiles/boom",
"/request/hawk/sntp"
],
- "_resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
- "_shasum": "20bb7403d3cea398e91dc4710a8ff1b8274a25ed",
- "_shrinkwrap": null,
- "_spec": "hoek@2.x.x",
- "_where": "/Users/zkat/Documents/code/npm/node_modules/request/node_modules/hawk",
- "bin": null,
+ "_resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz",
+ "_shasum": "72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d",
+ "_spec": "hoek@4.x.x",
+ "_where": "/Users/rebecca/code/npm/node_modules/request/node_modules/hawk",
"bugs": {
"url": "https://github.com/hapijs/hoek/issues"
},
@@ -33,11 +33,11 @@
"deprecated": false,
"description": "General purpose node utilities",
"devDependencies": {
- "code": "1.x.x",
- "lab": "5.x.x"
+ "code": "4.x.x",
+ "lab": "13.x.x"
},
"engines": {
- "node": ">=0.10.40"
+ "node": ">=4.0.0"
},
"homepage": "https://github.com/hapijs/hoek#readme",
"keywords": [
@@ -46,8 +46,6 @@
"license": "BSD-3-Clause",
"main": "lib/index.js",
"name": "hoek",
- "optionalDependencies": {},
- "peerDependencies": {},
"repository": {
"type": "git",
"url": "git://github.com/hapijs/hoek.git"
@@ -56,5 +54,5 @@
"test": "lab -a code -t 100 -L",
"test-cov-html": "lab -a code -t 100 -L -r html -o coverage.html"
},
- "version": "2.16.3"
+ "version": "4.2.0"
}
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js
deleted file mode 100644
index a5d048f7bc..0000000000
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js
+++ /dev/null
@@ -1,88 +0,0 @@
-// Load modules
-
-var Code = require('code');
-var Hoek = require('../lib');
-var Lab = require('lab');
-
-
-// Declare internals
-
-var internals = {};
-
-
-// Test shortcuts
-
-var lab = exports.lab = Lab.script();
-var describe = lab.experiment;
-var it = lab.test;
-var expect = Code.expect;
-
-
-describe('escapeJavaScript()', function () {
-
- it('encodes / characters', function (done) {
-
- var encoded = Hoek.escapeJavaScript('<script>alert(1)</script>');
- expect(encoded).to.equal('\\x3cscript\\x3ealert\\x281\\x29\\x3c\\x2fscript\\x3e');
- done();
- });
-
- it('encodes \' characters', function (done) {
-
- var encoded = Hoek.escapeJavaScript('something(\'param\')');
- expect(encoded).to.equal('something\\x28\\x27param\\x27\\x29');
- done();
- });
-
- it('encodes large unicode characters with the correct padding', function (done) {
-
- var encoded = Hoek.escapeJavaScript(String.fromCharCode(500) + String.fromCharCode(1000));
- expect(encoded).to.equal('\\u0500\\u1000');
- done();
- });
-
- it('doesn\'t throw an exception when passed null', function (done) {
-
- var encoded = Hoek.escapeJavaScript(null);
- expect(encoded).to.equal('');
- done();
- });
-});
-
-describe('escapeHtml()', function () {
-
- it('encodes / characters', function (done) {
-
- var encoded = Hoek.escapeHtml('<script>alert(1)</script>');
- expect(encoded).to.equal('&lt;script&gt;alert&#x28;1&#x29;&lt;&#x2f;script&gt;');
- done();
- });
-
- it('encodes < and > as named characters', function (done) {
-
- var encoded = Hoek.escapeHtml('<script><>');
- expect(encoded).to.equal('&lt;script&gt;&lt;&gt;');
- done();
- });
-
- it('encodes large unicode characters', function (done) {
-
- var encoded = Hoek.escapeHtml(String.fromCharCode(500) + String.fromCharCode(1000));
- expect(encoded).to.equal('&#500;&#1000;');
- done();
- });
-
- it('doesn\'t throw an exception when passed null', function (done) {
-
- var encoded = Hoek.escapeHtml(null);
- expect(encoded).to.equal('');
- done();
- });
-
- it('encodes {} characters', function (done) {
-
- var encoded = Hoek.escapeHtml('{}');
- expect(encoded).to.equal('&#x7b;&#x7d;');
- done();
- });
-});
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js
deleted file mode 100644
index 1e8ef620f3..0000000000
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js
+++ /dev/null
@@ -1,2513 +0,0 @@
-// Load modules
-
-var Fs = require('fs');
-var Path = require('path');
-var Code = require('code');
-var Hoek = require('../lib');
-var Lab = require('lab');
-
-
-// Declare internals
-
-var internals = {};
-
-
-// Test shortcuts
-
-var lab = exports.lab = Lab.script();
-var describe = lab.experiment;
-var it = lab.test;
-var expect = Code.expect;
-
-
-var nestedObj = {
- v: [7, 8, 9],
- w: /^something$/igm,
- x: {
- a: [1, 2, 3],
- b: 123456,
- c: new Date(),
- d: /hi/igm,
- e: /hello/
- },
- y: 'y',
- z: new Date(1378775452757)
-};
-
-var dupsArray = [nestedObj, { z: 'z' }, nestedObj];
-var reducedDupsArray = [nestedObj, { z: 'z' }];
-
-describe('clone()', function () {
-
- it('clones a nested object', function (done) {
-
- var a = nestedObj;
- var b = Hoek.clone(a);
-
- expect(a).to.deep.equal(b);
- expect(a.z.getTime()).to.equal(b.z.getTime());
- done();
- });
-
- it('clones a null object', function (done) {
-
- var b = Hoek.clone(null);
-
- expect(b).to.equal(null);
- done();
- });
-
- it('should not convert undefined properties to null', function (done) {
-
- var obj = { something: undefined };
- var b = Hoek.clone(obj);
-
- expect(typeof b.something).to.equal('undefined');
- done();
- });
-
- it('should not throw on circular reference', function (done) {
-
- var a = {};
- a.x = a;
-
- var test = function () {
-
- var b = Hoek.clone(a);
- };
-
- expect(test).to.not.throw();
- done();
- });
-
- it('clones circular reference', function (done) {
-
- var x = {
- 'z': new Date()
- };
- x.y = x;
-
- var b = Hoek.clone(x);
- expect(Object.keys(b.y)).to.deep.equal(Object.keys(x));
- expect(b.z).to.not.equal(x.z);
- expect(b.y).to.not.equal(x.y);
- expect(b.y.z).to.not.equal(x.y.z);
- expect(b.y).to.equal(b);
- expect(b.y.y.y.y).to.equal(b);
- done();
- });
-
- it('clones an object with a null prototype', function (done) {
-
- var obj = Object.create(null);
- var b = Hoek.clone(obj);
-
- expect(b).to.deep.equal(obj);
- done();
- });
-
- it('clones deeply nested object', function (done) {
-
- var a = {
- x: {
- y: {
- a: [1, 2, 3],
- b: 123456,
- c: new Date(),
- d: /hi/igm,
- e: /hello/
- }
- }
- };
-
- var b = Hoek.clone(a);
-
- expect(a).to.deep.equal(b);
- expect(a.x.y.c.getTime()).to.equal(b.x.y.c.getTime());
- done();
- });
-
- it('clones arrays', function (done) {
-
- var a = [1, 2, 3];
-
- var b = Hoek.clone(a);
-
- expect(a).to.deep.equal(b);
- done();
- });
-
- it('performs actual copy for shallow keys (no pass by reference)', function (done) {
-
- var x = Hoek.clone(nestedObj);
- var y = Hoek.clone(nestedObj);
-
- // Date
- expect(x.z).to.not.equal(nestedObj.z);
- expect(x.z).to.not.equal(y.z);
-
- // Regex
- expect(x.w).to.not.equal(nestedObj.w);
- expect(x.w).to.not.equal(y.w);
-
- // Array
- expect(x.v).to.not.equal(nestedObj.v);
- expect(x.v).to.not.equal(y.v);
-
- // Immutable(s)
- x.y = 5;
- expect(x.y).to.not.equal(nestedObj.y);
- expect(x.y).to.not.equal(y.y);
-
- done();
- });
-
- it('performs actual copy for deep keys (no pass by reference)', function (done) {
-
- var x = Hoek.clone(nestedObj);
- var y = Hoek.clone(nestedObj);
-
- expect(x.x.c).to.not.equal(nestedObj.x.c);
- expect(x.x.c).to.not.equal(y.x.c);
-
- expect(x.x.c.getTime()).to.equal(nestedObj.x.c.getTime());
- expect(x.x.c.getTime()).to.equal(y.x.c.getTime());
- done();
- });
-
- it('copies functions with properties', function (done) {
-
- var a = {
- x: function () {
-
- return 1;
- },
- y: {}
- };
- a.x.z = 'string in function';
- a.x.v = function () {
-
- return 2;
- };
- a.y.u = a.x;
-
- var b = Hoek.clone(a);
- expect(b.x()).to.equal(1);
- expect(b.x.v()).to.equal(2);
- expect(b.y.u).to.equal(b.x);
- expect(b.x.z).to.equal('string in function');
- done();
- });
-
- it('should copy a buffer', function (done) {
-
- var tls = {
- key: new Buffer([1, 2, 3, 4, 5]),
- cert: new Buffer([1, 2, 3, 4, 5, 6, 10])
- };
-
- var copiedTls = Hoek.clone(tls);
- expect(Buffer.isBuffer(copiedTls.key)).to.equal(true);
- expect(JSON.stringify(copiedTls.key)).to.equal(JSON.stringify(tls.key));
- expect(Buffer.isBuffer(copiedTls.cert)).to.equal(true);
- expect(JSON.stringify(copiedTls.cert)).to.equal(JSON.stringify(tls.cert));
- done();
- });
-
- it('clones an object with a prototype', function (done) {
-
- var Obj = function () {
-
- this.a = 5;
- };
-
- Obj.prototype.b = function () {
-
- return 'c';
- };
-
- var a = new Obj();
- var b = Hoek.clone(a);
-
- expect(b.a).to.equal(5);
- expect(b.b()).to.equal('c');
- expect(a).to.deep.equal(b);
- done();
- });
-
- it('reuses cloned Date object', function (done) {
-
- var obj = {
- a: new Date()
- };
-
- obj.b = obj.a;
-
- var copy = Hoek.clone(obj);
- expect(copy.a).to.equal(copy.b);
- done();
- });
-
- it('shallow copies an object with a prototype and isImmutable flag', function (done) {
-
- var Obj = function () {
-
- this.value = 5;
- };
-
- Obj.prototype.b = function () {
-
- return 'c';
- };
-
- Obj.prototype.isImmutable = true;
-
- var obj = {
- a: new Obj()
- };
-
- var copy = Hoek.clone(obj);
-
- expect(obj.a.value).to.equal(5);
- expect(copy.a.value).to.equal(5);
- expect(copy.a.b()).to.equal('c');
- expect(obj.a).to.equal(copy.a);
- done();
- });
-
- it('clones an object with property getter without executing it', function (done) {
-
- var obj = {};
- var value = 1;
- var execCount = 0;
-
- Object.defineProperty(obj, 'test', {
- enumerable: true,
- configurable: true,
- get: function () {
-
- ++execCount;
- return value;
- }
- });
-
- var copy = Hoek.clone(obj);
- expect(execCount).to.equal(0);
- expect(copy.test).to.equal(1);
- expect(execCount).to.equal(1);
- done();
- });
-
- it('clones an object with property getter and setter', function (done) {
-
- var obj = {
- _test: 0
- };
-
- Object.defineProperty(obj, 'test', {
- enumerable: true,
- configurable: true,
- get: function () {
-
- return this._test;
- },
- set: function (value) {
-
- this._test = value - 1;
- }
- });
-
- var copy = Hoek.clone(obj);
- expect(copy.test).to.equal(0);
- copy.test = 5;
- expect(copy.test).to.equal(4);
- done();
- });
-
- it('clones an object with only property setter', function (done) {
-
- var obj = {
- _test: 0
- };
-
- Object.defineProperty(obj, 'test', {
- enumerable: true,
- configurable: true,
- set: function (value) {
-
- this._test = value - 1;
- }
- });
-
- var copy = Hoek.clone(obj);
- expect(copy._test).to.equal(0);
- copy.test = 5;
- expect(copy._test).to.equal(4);
- done();
- });
-
- it('clones an object with non-enumerable properties', function (done) {
-
- var obj = {
- _test: 0
- };
-
- Object.defineProperty(obj, 'test', {
- enumerable: false,
- configurable: true,
- set: function (value) {
-
- this._test = value - 1;
- }
- });
-
- var copy = Hoek.clone(obj);
- expect(copy._test).to.equal(0);
- copy.test = 5;
- expect(copy._test).to.equal(4);
- done();
- });
-
- it('clones an object where getOwnPropertyDescriptor returns undefined', function (done) {
-
- var oldGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
- var obj = { a: 'b' };
- Object.getOwnPropertyDescriptor = function () {
-
- return undefined;
- };
-
- var copy = Hoek.clone(obj);
- Object.getOwnPropertyDescriptor = oldGetOwnPropertyDescriptor;
- expect(copy).to.deep.equal(obj);
- done();
- });
-});
-
-describe('merge()', function () {
-
- it('deep copies source items', function (done) {
-
- var target = {
- b: 3,
- d: []
- };
-
- var source = {
- c: {
- d: 1
- },
- d: [{ e: 1 }]
- };
-
- Hoek.merge(target, source);
- expect(target.c).to.not.equal(source.c);
- expect(target.c).to.deep.equal(source.c);
- expect(target.d).to.not.equal(source.d);
- expect(target.d[0]).to.not.equal(source.d[0]);
- expect(target.d).to.deep.equal(source.d);
- done();
- });
-
- it('merges array over an object', function (done) {
-
- var a = {
- x: ['n', 'm']
- };
-
- var b = {
- x: {
- n: '1',
- m: '2'
- }
- };
-
- Hoek.merge(b, a);
- expect(a.x[0]).to.equal('n');
- expect(a.x.n).to.not.exist();
- done();
- });
-
- it('merges object over an array', function (done) {
-
- var a = {
- x: ['n', 'm']
- };
-
- var b = {
- x: {
- n: '1',
- m: '2'
- }
- };
-
- Hoek.merge(a, b);
- expect(a.x.n).to.equal('1');
- expect(a.x[0]).to.not.exist();
- done();
- });
-
- it('does not throw if source is null', function (done) {
-
- var a = {};
- var b = null;
- var c = null;
-
- expect(function () {
-
- c = Hoek.merge(a, b);
- }).to.not.throw();
-
- expect(c).to.equal(a);
- done();
- });
-
- it('does not throw if source is undefined', function (done) {
-
- var a = {};
- var b;
- var c = null;
-
- expect(function () {
-
- c = Hoek.merge(a, b);
- }).to.not.throw();
-
- expect(c).to.equal(a);
- done();
- });
-
- it('throws if source is not an object', function (done) {
-
- expect(function () {
-
- var a = {};
- var b = 0;
-
- Hoek.merge(a, b);
- }).to.throw('Invalid source value: must be null, undefined, or an object');
- done();
- });
-
- it('throws if target is not an object', function (done) {
-
- expect(function () {
-
- var a = 0;
- var b = {};
-
- Hoek.merge(a, b);
- }).to.throw('Invalid target value: must be an object');
- done();
- });
-
- it('throws if target is not an array and source is', function (done) {
-
- expect(function () {
-
- var a = {};
- var b = [1, 2];
-
- Hoek.merge(a, b);
- }).to.throw('Cannot merge array onto an object');
- done();
- });
-
- it('returns the same object when merging arrays', function (done) {
-
- var a = [];
- var b = [1, 2];
-
- expect(Hoek.merge(a, b)).to.equal(a);
- done();
- });
-
- it('combines an empty object with a non-empty object', function (done) {
-
- var a = {};
- var b = nestedObj;
-
- var c = Hoek.merge(a, b);
- expect(a).to.deep.equal(b);
- expect(c).to.deep.equal(b);
- done();
- });
-
- it('overrides values in target', function (done) {
-
- var a = { x: 1, y: 2, z: 3, v: 5, t: 'test', m: 'abc' };
- var b = { x: null, z: 4, v: 0, t: { u: 6 }, m: '123' };
-
- var c = Hoek.merge(a, b);
- expect(c.x).to.equal(null);
- expect(c.y).to.equal(2);
- expect(c.z).to.equal(4);
- expect(c.v).to.equal(0);
- expect(c.m).to.equal('123');
- expect(c.t).to.deep.equal({ u: 6 });
- done();
- });
-
- it('overrides values in target (flip)', function (done) {
-
- var a = { x: 1, y: 2, z: 3, v: 5, t: 'test', m: 'abc' };
- var b = { x: null, z: 4, v: 0, t: { u: 6 }, m: '123' };
-
- var d = Hoek.merge(b, a);
- expect(d.x).to.equal(1);
- expect(d.y).to.equal(2);
- expect(d.z).to.equal(3);
- expect(d.v).to.equal(5);
- expect(d.m).to.equal('abc');
- expect(d.t).to.deep.equal('test');
- done();
- });
-
- it('retains Date properties', function (done) {
-
- var a = { x: new Date(1378776452757) };
-
- var b = Hoek.merge({}, a);
- expect(a.x.getTime()).to.equal(b.x.getTime());
- done();
- });
-
- it('retains Date properties when merging keys', function (done) {
-
- var a = { x: new Date(1378776452757) };
-
- var b = Hoek.merge({ x: {} }, a);
- expect(a.x.getTime()).to.equal(b.x.getTime());
- done();
- });
-
- it('overrides Buffer', function (done) {
-
- var a = { x: new Buffer('abc') };
-
- var b = Hoek.merge({ x: {} }, a);
- expect(a.x.toString()).to.equal('abc');
- done();
- });
-});
-
-describe('applyToDefaults()', function () {
-
- var defaults = {
- a: 1,
- b: 2,
- c: {
- d: 3,
- e: [5, 6]
- },
- f: 6,
- g: 'test'
- };
-
- it('throws when target is null', function (done) {
-
- expect(function () {
-
- Hoek.applyToDefaults(null, {});
- }).to.throw('Invalid defaults value: must be an object');
- done();
- });
-
- it('returns null if options is false', function (done) {
-
- var result = Hoek.applyToDefaults(defaults, false);
- expect(result).to.equal(null);
- done();
- });
-
- it('returns null if options is null', function (done) {
-
- var result = Hoek.applyToDefaults(defaults, null);
- expect(result).to.equal(null);
- done();
- });
-
- it('returns null if options is undefined', function (done) {
-
- var result = Hoek.applyToDefaults(defaults, undefined);
- expect(result).to.equal(null);
- done();
- });
-
- it('returns a copy of defaults if options is true', function (done) {
-
- var result = Hoek.applyToDefaults(defaults, true);
- expect(result).to.deep.equal(defaults);
- done();
- });
-
- it('applies object to defaults', function (done) {
-
- var obj = {
- a: null,
- c: {
- e: [4]
- },
- f: 0,
- g: {
- h: 5
- }
- };
-
- var result = Hoek.applyToDefaults(defaults, obj);
- expect(result.c.e).to.deep.equal([4]);
- expect(result.a).to.equal(1);
- expect(result.b).to.equal(2);
- expect(result.f).to.equal(0);
- expect(result.g).to.deep.equal({ h: 5 });
- done();
- });
-
- it('applies object to defaults with null', function (done) {
-
- var obj = {
- a: null,
- c: {
- e: [4]
- },
- f: 0,
- g: {
- h: 5
- }
- };
-
- var result = Hoek.applyToDefaults(defaults, obj, true);
- expect(result.c.e).to.deep.equal([4]);
- expect(result.a).to.equal(null);
- expect(result.b).to.equal(2);
- expect(result.f).to.equal(0);
- expect(result.g).to.deep.equal({ h: 5 });
- done();
- });
-});
-
-describe('cloneWithShallow()', function () {
-
- it('deep clones except for listed keys', function (done) {
-
- var source = {
- a: {
- b: 5
- },
- c: {
- d: 6
- }
- };
-
- var copy = Hoek.cloneWithShallow(source, ['c']);
- expect(copy).to.deep.equal(source);
- expect(copy).to.not.equal(source);
- expect(copy.a).to.not.equal(source.a);
- expect(copy.b).to.equal(source.b);
- done();
- });
-
- it('returns immutable value', function (done) {
-
- expect(Hoek.cloneWithShallow(5)).to.equal(5);
- done();
- });
-
- it('returns null value', function (done) {
-
- expect(Hoek.cloneWithShallow(null)).to.equal(null);
- done();
- });
-
- it('returns undefined value', function (done) {
-
- expect(Hoek.cloneWithShallow(undefined)).to.equal(undefined);
- done();
- });
-
- it('deep clones except for listed keys (including missing keys)', function (done) {
-
- var source = {
- a: {
- b: 5
- },
- c: {
- d: 6
- }
- };
-
- var copy = Hoek.cloneWithShallow(source, ['c', 'v']);
- expect(copy).to.deep.equal(source);
- expect(copy).to.not.equal(source);
- expect(copy.a).to.not.equal(source.a);
- expect(copy.b).to.equal(source.b);
- done();
- });
-});
-
-describe('applyToDefaultsWithShallow()', function () {
-
- it('shallow copies the listed keys from options without merging', function (done) {
-
- var defaults = {
- a: {
- b: 5,
- e: 3
- },
- c: {
- d: 7,
- g: 1
- }
- };
-
- var options = {
- a: {
- b: 4
- },
- c: {
- d: 6,
- f: 7
- }
- };
-
- var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['a']);
- expect(merged).to.deep.equal({ a: { b: 4 }, c: { d: 6, g: 1, f: 7 } });
- expect(merged.a).to.equal(options.a);
- expect(merged.a).to.not.equal(defaults.a);
- expect(merged.c).to.not.equal(options.c);
- expect(merged.c).to.not.equal(defaults.c);
- done();
- });
-
- it('shallow copies the nested keys (override)', function (done) {
-
- var defaults = {
- a: {
- b: 5
- },
- c: {
- d: 7,
- g: 1
- }
- };
-
- var options = {
- a: {
- b: 4
- },
- c: {
- d: 6,
- g: {
- h: 8
- }
- }
- };
-
- var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['c.g']);
- expect(merged).to.deep.equal({ a: { b: 4 }, c: { d: 6, g: { h: 8 } } });
- expect(merged.c.g).to.equal(options.c.g);
- done();
- });
-
- it('shallow copies the nested keys (missing)', function (done) {
-
- var defaults = {
- a: {
- b: 5
- }
- };
-
- var options = {
- a: {
- b: 4
- },
- c: {
- g: {
- h: 8
- }
- }
- };
-
- var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['c.g']);
- expect(merged).to.deep.equal({ a: { b: 4 }, c: { g: { h: 8 } } });
- expect(merged.c.g).to.equal(options.c.g);
- done();
- });
-
- it('shallow copies the nested keys (override)', function (done) {
-
- var defaults = {
- a: {
- b: 5
- },
- c: {
- g: {
- d: 7
- }
- }
- };
-
- var options = {
- a: {
- b: 4
- },
- c: {
- g: {
- h: 8
- }
- }
- };
-
- var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['c.g']);
- expect(merged).to.deep.equal({ a: { b: 4 }, c: { g: { h: 8 } } });
- expect(merged.c.g).to.equal(options.c.g);
- done();
- });
-
- it('shallow copies the nested keys (deeper)', function (done) {
-
- var defaults = {
- a: {
- b: 5
- }
- };
-
- var options = {
- a: {
- b: 4
- },
- c: {
- g: {
- r: {
- h: 8
- }
- }
- }
- };
-
- var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['c.g.r']);
- expect(merged).to.deep.equal({ a: { b: 4 }, c: { g: { r: { h: 8 } } } });
- expect(merged.c.g.r).to.equal(options.c.g.r);
- done();
- });
-
- it('shallow copies the nested keys (not present)', function (done) {
-
- var defaults = {
- a: {
- b: 5
- }
- };
-
- var options = {
- a: {
- b: 4
- },
- c: {
- g: {
- r: {
- h: 8
- }
- }
- }
- };
-
- var merged = Hoek.applyToDefaultsWithShallow(defaults, options, ['x.y']);
- expect(merged).to.deep.equal({ a: { b: 4 }, c: { g: { r: { h: 8 } } } });
- done();
- });
-
- it('shallow copies the listed keys in the defaults', function (done) {
-
- var defaults = {
- a: {
- b: 1
- }
- };
-
- var merged = Hoek.applyToDefaultsWithShallow(defaults, {}, ['a']);
- expect(merged.a).to.equal(defaults.a);
- done();
- });
-
- it('shallow copies the listed keys in the defaults (true)', function (done) {
-
- var defaults = {
- a: {
- b: 1
- }
- };
-
- var merged = Hoek.applyToDefaultsWithShallow(defaults, true, ['a']);
- expect(merged.a).to.equal(defaults.a);
- done();
- });
-
- it('returns null on false', function (done) {
-
- var defaults = {
- a: {
- b: 1
- }
- };
-
- var merged = Hoek.applyToDefaultsWithShallow(defaults, false, ['a']);
- expect(merged).to.equal(null);
- done();
- });
-
- it('throws on missing defaults', function (done) {
-
- expect(function () {
-
- Hoek.applyToDefaultsWithShallow(null, {}, ['a']);
- }).to.throw('Invalid defaults value: must be an object');
- done();
- });
-
- it('throws on invalid defaults', function (done) {
-
- expect(function () {
-
- Hoek.applyToDefaultsWithShallow('abc', {}, ['a']);
- }).to.throw('Invalid defaults value: must be an object');
- done();
- });
-
- it('throws on invalid options', function (done) {
-
- expect(function () {
-
- Hoek.applyToDefaultsWithShallow({}, 'abc', ['a']);
- }).to.throw('Invalid options value: must be true, falsy or an object');
- done();
- });
-
- it('throws on missing keys', function (done) {
-
- expect(function () {
-
- Hoek.applyToDefaultsWithShallow({}, true);
- }).to.throw('Invalid keys');
- done();
- });
-
- it('throws on invalid keys', function (done) {
-
- expect(function () {
-
- Hoek.applyToDefaultsWithShallow({}, true, 'a');
- }).to.throw('Invalid keys');
- done();
- });
-});
-
-describe('deepEqual()', function () {
-
- it('compares simple values', function (done) {
-
- expect(Hoek.deepEqual('x', 'x')).to.be.true();
- expect(Hoek.deepEqual('x', 'y')).to.be.false();
- expect(Hoek.deepEqual('x1', 'x')).to.be.false();
- expect(Hoek.deepEqual(-0, +0)).to.be.false();
- expect(Hoek.deepEqual(-0, -0)).to.be.true();
- expect(Hoek.deepEqual(+0, +0)).to.be.true();
- expect(Hoek.deepEqual(+0, -0)).to.be.false();
- expect(Hoek.deepEqual(1, 1)).to.be.true();
- expect(Hoek.deepEqual(0, 0)).to.be.true();
- expect(Hoek.deepEqual(-1, 1)).to.be.false();
- expect(Hoek.deepEqual(NaN, 0)).to.be.false();
- expect(Hoek.deepEqual(NaN, NaN)).to.be.true();
- done();
- });
-
- it('compares different types', function (done) {
-
- expect(Hoek.deepEqual([], 5)).to.be.false();
- expect(Hoek.deepEqual(5, [])).to.be.false();
- expect(Hoek.deepEqual({}, null)).to.be.false();
- expect(Hoek.deepEqual(null, {})).to.be.false();
- expect(Hoek.deepEqual('abc', {})).to.be.false();
- expect(Hoek.deepEqual({}, 'abc')).to.be.false();
- done();
- });
-
- it('compares empty structures', function (done) {
-
- expect(Hoek.deepEqual([], [])).to.be.true();
- expect(Hoek.deepEqual({}, {})).to.be.true();
- expect(Hoek.deepEqual([], {})).to.be.false();
- done();
- });
-
- it('compares empty arguments object', function (done) {
-
- var compare = function () {
-
- expect(Hoek.deepEqual([], arguments)).to.be.false();
- };
-
- compare();
- done();
- });
-
- it('compares empty arguments objects', function (done) {
-
- var compare = function () {
-
- var arg1 = arguments;
-
- var inner = function () {
-
- expect(Hoek.deepEqual(arg1, arguments)).to.be.false(); // callee is not the same
- };
-
- inner();
- };
-
- compare();
- done();
- });
-
- it('compares dates', function (done) {
-
- expect(Hoek.deepEqual(new Date(2015, 1, 1), new Date(2015, 1, 1))).to.be.true();
- expect(Hoek.deepEqual(new Date(100), new Date(101))).to.be.false();
- expect(Hoek.deepEqual(new Date(), {})).to.be.false();
- done();
- });
-
- it('compares regular expressions', function (done) {
-
- expect(Hoek.deepEqual(/\s/, new RegExp('\\\s'))).to.be.true();
- expect(Hoek.deepEqual(/\s/g, /\s/g)).to.be.true();
- expect(Hoek.deepEqual(/a/, {})).to.be.false();
- expect(Hoek.deepEqual(/\s/g, /\s/i)).to.be.false();
- expect(Hoek.deepEqual(/a/g, /b/g)).to.be.false();
- done();
- });
-
- it('compares arrays', function (done) {
-
- expect(Hoek.deepEqual([[1]], [[1]])).to.be.true();
- expect(Hoek.deepEqual([1, 2, 3], [1, 2, 3])).to.be.true();
- expect(Hoek.deepEqual([1, 2, 3], [1, 3, 2])).to.be.false();
- expect(Hoek.deepEqual([1, 2, 3], [1, 2])).to.be.false();
- expect(Hoek.deepEqual([1], [1])).to.be.true();
- done();
- });
-
- it('compares buffers', function (done) {
-
- expect(Hoek.deepEqual(new Buffer([1, 2, 3]), new Buffer([1, 2, 3]))).to.be.true();
- expect(Hoek.deepEqual(new Buffer([1, 2, 3]), new Buffer([1, 3, 2]))).to.be.false();
- expect(Hoek.deepEqual(new Buffer([1, 2, 3]), new Buffer([1, 2]))).to.be.false();
- expect(Hoek.deepEqual(new Buffer([1, 2, 3]), {})).to.be.false();
- expect(Hoek.deepEqual(new Buffer([1, 2, 3]), [1, 2, 3])).to.be.false();
- done();
- });
-
- it('compares objects', function (done) {
-
- expect(Hoek.deepEqual({ a: 1, b: 2, c: 3 }, { a: 1, b: 2, c: 3 })).to.be.true();
- expect(Hoek.deepEqual({ foo: 'bar' }, { foo: 'baz' })).to.be.false();
- expect(Hoek.deepEqual({ foo: { bar: 'foo' } }, { foo: { bar: 'baz' } })).to.be.false();
- done();
- });
-
- it('handles circular dependency', function (done) {
-
- var a = {};
- a.x = a;
-
- var b = Hoek.clone(a);
- expect(Hoek.deepEqual(a, b)).to.be.true();
- done();
- });
-
- it('compares an object with property getter without executing it', function (done) {
-
- var obj = {};
- var value = 1;
- var execCount = 0;
-
- Object.defineProperty(obj, 'test', {
- enumerable: true,
- configurable: true,
- get: function () {
-
- ++execCount;
- return value;
- }
- });
-
- var copy = Hoek.clone(obj);
- expect(Hoek.deepEqual(obj, copy)).to.be.true();
- expect(execCount).to.equal(0);
- expect(copy.test).to.equal(1);
- expect(execCount).to.equal(1);
- done();
- });
-
- it('compares objects with property getters', function (done) {
-
- var obj = {};
- Object.defineProperty(obj, 'test', {
- enumerable: true,
- configurable: true,
- get: function () {
-
- return 1;
- }
- });
-
- var ref = {};
- Object.defineProperty(ref, 'test', {
- enumerable: true,
- configurable: true,
- get: function () {
-
- return 2;
- }
- });
-
- expect(Hoek.deepEqual(obj, ref)).to.be.false();
- done();
- });
-
- it('compares object prototypes', function (done) {
-
- var Obj = function () {
-
- this.a = 5;
- };
-
- Obj.prototype.b = function () {
-
- return this.a;
- };
-
- var Ref = function () {
-
- this.a = 5;
- };
-
- Ref.prototype.b = function () {
-
- return this.a;
- };
-
- expect(Hoek.deepEqual(new Obj(), new Ref())).to.be.false();
- expect(Hoek.deepEqual(new Obj(), new Obj())).to.be.true();
- expect(Hoek.deepEqual(new Ref(), new Ref())).to.be.true();
- done();
- });
-
- it('compares plain objects', function (done) {
-
- var a = Object.create(null);
- var b = Object.create(null);
-
- a.b = 'c';
- b.b = 'c';
-
- expect(Hoek.deepEqual(a, b)).to.be.true();
- expect(Hoek.deepEqual(a, { b: 'c' })).to.be.false();
- done();
- });
-
- it('compares an object with an empty object', function (done) {
-
- var a = { a: 1, b: 2 };
-
- expect(Hoek.deepEqual({}, a)).to.be.false();
- expect(Hoek.deepEqual(a, {})).to.be.false();
- done();
- });
-
- it('compares an object ignoring the prototype', function (done) {
-
- var a = Object.create(null);
- var b = {};
-
- expect(Hoek.deepEqual(a, b, { prototype: false })).to.be.true();
- done();
- });
-
- it('compares an object ignoring the prototype recursively', function (done) {
-
- var a = [Object.create(null)];
- var b = [{}];
-
- expect(Hoek.deepEqual(a, b, { prototype: false })).to.be.true();
- done();
- });
-});
-
-describe('unique()', function () {
-
- it('ensures uniqueness within array of objects based on subkey', function (done) {
-
- var a = Hoek.unique(dupsArray, 'x');
- expect(a).to.deep.equal(reducedDupsArray);
- done();
- });
-
- it('removes duplicated without key', function (done) {
-
- expect(Hoek.unique([1, 2, 3, 4, 2, 1, 5])).to.deep.equal([1, 2, 3, 4, 5]);
- done();
- });
-});
-
-describe('mapToObject()', function () {
-
- it('returns null on null array', function (done) {
-
- var a = Hoek.mapToObject(null);
- expect(a).to.equal(null);
- done();
- });
-
- it('converts basic array to existential object', function (done) {
-
- var keys = [1, 2, 3, 4];
- var a = Hoek.mapToObject(keys);
- for (var i in keys) {
- expect(a[keys[i]]).to.equal(true);
- }
- done();
- });
-
- it('converts array of objects to existential object', function (done) {
-
- var keys = [{ x: 1 }, { x: 2 }, { x: 3 }, { y: 4 }];
- var subkey = 'x';
- var a = Hoek.mapToObject(keys, subkey);
- expect(a).to.deep.equal({ 1: true, 2: true, 3: true });
- done();
- });
-});
-
-describe('intersect()', function () {
-
- it('returns the common objects of two arrays', function (done) {
-
- var array1 = [1, 2, 3, 4, 4, 5, 5];
- var array2 = [5, 4, 5, 6, 7];
- var common = Hoek.intersect(array1, array2);
- expect(common.length).to.equal(2);
- done();
- });
-
- it('returns just the first common object of two arrays', function (done) {
-
- var array1 = [1, 2, 3, 4, 4, 5, 5];
- var array2 = [5, 4, 5, 6, 7];
- var common = Hoek.intersect(array1, array2, true);
- expect(common).to.equal(5);
- done();
- });
-
- it('returns null when no common and returning just the first common object of two arrays', function (done) {
-
- var array1 = [1, 2, 3, 4, 4, 5, 5];
- var array2 = [6, 7];
- var common = Hoek.intersect(array1, array2, true);
- expect(common).to.equal(null);
- done();
- });
-
- it('returns an empty array if either input is null', function (done) {
-
- expect(Hoek.intersect([1], null).length).to.equal(0);
- expect(Hoek.intersect(null, [1]).length).to.equal(0);
- done();
- });
-
- it('returns the common objects of object and array', function (done) {
-
- var array1 = [1, 2, 3, 4, 4, 5, 5];
- var array2 = [5, 4, 5, 6, 7];
- var common = Hoek.intersect(Hoek.mapToObject(array1), array2);
- expect(common.length).to.equal(2);
- done();
- });
-});
-
-describe('contain()', function () {
-
- it('tests strings', function (done) {
-
- expect(Hoek.contain('abc', 'ab')).to.be.true();
- expect(Hoek.contain('abc', 'abc', { only: true })).to.be.true();
- expect(Hoek.contain('aaa', 'a', { only: true })).to.be.true();
- expect(Hoek.contain('abc', 'b', { once: true })).to.be.true();
- expect(Hoek.contain('abc', ['a', 'c'])).to.be.true();
- expect(Hoek.contain('abc', ['a', 'd'], { part: true })).to.be.true();
-
- expect(Hoek.contain('abc', 'ac')).to.be.false();
- expect(Hoek.contain('abcd', 'abc', { only: true })).to.be.false();
- expect(Hoek.contain('aab', 'a', { only: true })).to.be.false();
- expect(Hoek.contain('abb', 'b', { once: true })).to.be.false();
- expect(Hoek.contain('abc', ['a', 'd'])).to.be.false();
- expect(Hoek.contain('abc', ['ab', 'bc'])).to.be.false(); // Overlapping values not supported
- done();
- });
-
- it('tests arrays', function (done) {
-
- expect(Hoek.contain([1, 2, 3], 1)).to.be.true();
- expect(Hoek.contain([{ a: 1 }], { a: 1 }, { deep: true })).to.be.true();
- expect(Hoek.contain([1, 2, 3], [1, 2])).to.be.true();
- expect(Hoek.contain([{ a: 1 }], [{ a: 1 }], { deep: true })).to.be.true();
- expect(Hoek.contain([1, 1, 2], [1, 2], { only: true })).to.be.true();
- expect(Hoek.contain([1, 2], [1, 2], { once: true })).to.be.true();
- expect(Hoek.contain([1, 2, 3], [1, 4], { part: true })).to.be.true();
- expect(Hoek.contain([[1], [2]], [[1]], { deep: true })).to.be.true();
-
- expect(Hoek.contain([1, 2, 3], 4)).to.be.false();
- expect(Hoek.contain([{ a: 1 }], { a: 2 }, { deep: true })).to.be.false();
- expect(Hoek.contain([{ a: 1 }], { a: 1 })).to.be.false();
- expect(Hoek.contain([1, 2, 3], [4, 5])).to.be.false();
- expect(Hoek.contain([[3], [2]], [[1]])).to.be.false();
- expect(Hoek.contain([[1], [2]], [[1]])).to.be.false();
- expect(Hoek.contain([{ a: 1 }], [{ a: 2 }], { deep: true })).to.be.false();
- expect(Hoek.contain([1, 3, 2], [1, 2], { only: true })).to.be.false();
- expect(Hoek.contain([1, 2, 2], [1, 2], { once: true })).to.be.false();
- expect(Hoek.contain([0, 2, 3], [1, 4], { part: true })).to.be.false();
- done();
- });
-
- it('tests objects', function (done) {
-
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, 'a')).to.be.true();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, ['a', 'c'])).to.be.true();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, ['a', 'b', 'c'], { only: true })).to.be.true();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1 })).to.be.true();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1, c: 3 })).to.be.true();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1, d: 4 }, { part: true })).to.be.true();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1, b: 2, c: 3 }, { only: true })).to.be.true();
- expect(Hoek.contain({ a: [1], b: [2], c: [3] }, { a: [1], c: [3] }, { deep: true })).to.be.true();
- expect(Hoek.contain({ a: [{ b: 1 }, { c: 2 }, { d: 3, e: 4 }] }, { a: [{ b: 1 }, { d: 3 }] }, { deep: true })).to.be.true();
- expect(Hoek.contain({ a: [{ b: 1 }, { c: 2 }, { d: 3, e: 4 }] }, { a: [{ b: 1 }, { d: 3 }] }, { deep: true, part: true })).to.be.true();
- expect(Hoek.contain({ a: [{ b: 1 }, { c: 2 }, { d: 3, e: 4 }] }, { a: [{ b: 1 }, { d: 3 }] }, { deep: true, part: false })).to.be.false();
- expect(Hoek.contain({ a: [{ b: 1 }, { c: 2 }, { d: 3, e: 4 }] }, { a: [{ b: 1 }, { d: 3 }] }, { deep: true, only: true })).to.be.false();
- expect(Hoek.contain({ a: [{ b: 1 }, { c: 2 }, { d: 3, e: 4 }] }, { a: [{ b: 1 }, { d: 3 }] }, { deep: true, only: false })).to.be.true();
-
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, 'd')).to.be.false();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, ['a', 'd'])).to.be.false();
- expect(Hoek.contain({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'b', 'c'], { only: true })).to.be.false();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 2 })).to.be.false();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 2, b: 2 }, { part: true })).to.be.false(); // part does not ignore bad value
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1, d: 3 })).to.be.false();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1, d: 4 })).to.be.false();
- expect(Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 }, { only: true })).to.be.false();
- expect(Hoek.contain({ a: [1], b: [2], c: [3] }, { a: [1], c: [3] })).to.be.false();
- expect(Hoek.contain({ a: { b: { c: 1, d: 2 } } }, { a: { b: { c: 1 } } })).to.be.false();
- expect(Hoek.contain({ a: { b: { c: 1, d: 2 } } }, { a: { b: { c: 1 } } }, { deep: true })).to.be.true();
- expect(Hoek.contain({ a: { b: { c: 1, d: 2 } } }, { a: { b: { c: 1 } } }, { deep: true, only: true })).to.be.false();
- expect(Hoek.contain({ a: { b: { c: 1, d: 2 } } }, { a: { b: { c: 1 } } }, { deep: true, only: false })).to.be.true();
- expect(Hoek.contain({ a: { b: { c: 1, d: 2 } } }, { a: { b: { c: 1 } } }, { deep: true, part: true })).to.be.true();
- expect(Hoek.contain({ a: { b: { c: 1, d: 2 } } }, { a: { b: { c: 1 } } }, { deep: true, part: false })).to.be.false();
-
- // Getter check
- var Foo = function (bar) {
-
- this.bar = bar;
- };
-
- Object.defineProperty(Foo.prototype, 'baz', {
- enumerable: true,
- get: function () {
-
- return this.bar;
- }
- });
-
- expect(Hoek.contain({ a: new Foo('b') }, { a: new Foo('b') }, { deep: true })).to.be.true();
- expect(Hoek.contain({ a: new Foo('b') }, { a: new Foo('b') }, { deep: true, part: true })).to.be.true();
- expect(Hoek.contain({ a: new Foo('b') }, { a: { baz: 'b' } }, { deep: true })).to.be.true();
- expect(Hoek.contain({ a: new Foo('b') }, { a: { baz: 'b' } }, { deep: true, only: true })).to.be.false();
- expect(Hoek.contain({ a: new Foo('b') }, { a: { baz: 'b' } }, { deep: true, part: false })).to.be.false();
- expect(Hoek.contain({ a: new Foo('b') }, { a: { baz: 'b' } }, { deep: true, part: true })).to.be.true();
-
- done();
- });
-});
-
-describe('flatten()', function () {
-
- it('returns a flat array', function (done) {
-
- var result = Hoek.flatten([1, 2, [3, 4, [5, 6], [7], 8], [9], [10, [11, 12]], 13]);
- expect(result.length).to.equal(13);
- expect(result).to.deep.equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]);
- done();
- });
-});
-
-describe('reach()', function () {
-
- var obj = {
- a: {
- b: {
- c: {
- d: 1,
- e: 2
- },
- f: 'hello'
- },
- g: {
- h: 3
- }
- },
- i: function () { },
- j: null,
- k: [4, 8, 9, 1]
- };
-
- obj.i.x = 5;
-
- it('returns object itself', function (done) {
-
- expect(Hoek.reach(obj, null)).to.equal(obj);
- expect(Hoek.reach(obj, false)).to.equal(obj);
- expect(Hoek.reach(obj)).to.equal(obj);
- done();
- });
-
- it('returns first value of array', function (done) {
-
- expect(Hoek.reach(obj, 'k.0')).to.equal(4);
- done();
- });
-
- it('returns last value of array using negative index', function (done) {
-
- expect(Hoek.reach(obj, 'k.-2')).to.equal(9);
- done();
- });
-
- it('returns a valid member', function (done) {
-
- expect(Hoek.reach(obj, 'a.b.c.d')).to.equal(1);
- done();
- });
-
- it('returns a valid member with separator override', function (done) {
-
- expect(Hoek.reach(obj, 'a/b/c/d', '/')).to.equal(1);
- done();
- });
-
- it('returns undefined on null object', function (done) {
-
- expect(Hoek.reach(null, 'a.b.c.d')).to.equal(undefined);
- done();
- });
-
- it('returns undefined on missing object member', function (done) {
-
- expect(Hoek.reach(obj, 'a.b.c.d.x')).to.equal(undefined);
- done();
- });
-
- it('returns undefined on missing function member', function (done) {
-
- expect(Hoek.reach(obj, 'i.y', { functions: true })).to.equal(undefined);
- done();
- });
-
- it('throws on missing member in strict mode', function (done) {
-
- expect(function () {
-
- Hoek.reach(obj, 'a.b.c.o.x', { strict: true });
- }).to.throw('Missing segment o in reach path a.b.c.o.x');
-
- done();
- });
-
- it('returns undefined on invalid member', function (done) {
-
- expect(Hoek.reach(obj, 'a.b.c.d-.x')).to.equal(undefined);
- done();
- });
-
- it('returns function member', function (done) {
-
- expect(typeof Hoek.reach(obj, 'i')).to.equal('function');
- done();
- });
-
- it('returns function property', function (done) {
-
- expect(Hoek.reach(obj, 'i.x')).to.equal(5);
- done();
- });
-
- it('returns null', function (done) {
-
- expect(Hoek.reach(obj, 'j')).to.equal(null);
- done();
- });
-
- it('throws on function property when functions not allowed', function (done) {
-
- expect(function () {
-
- Hoek.reach(obj, 'i.x', { functions: false });
- }).to.throw('Invalid segment x in reach path i.x');
-
- done();
- });
-
- it('will return a default value if property is not found', function (done) {
-
- expect(Hoek.reach(obj, 'a.b.q', { default: 'defaultValue' })).to.equal('defaultValue');
- done();
- });
-
- it('will return a default value if path is not found', function (done) {
-
- expect(Hoek.reach(obj, 'q', { default: 'defaultValue' })).to.equal('defaultValue');
- done();
- });
-
- it('allows a falsey value to be used as the default value', function (done) {
-
- expect(Hoek.reach(obj, 'q', { default: '' })).to.equal('');
- done();
- });
-});
-
-describe('reachTemplate()', function () {
-
- it('applies object to template', function (done) {
-
- var obj = {
- a: {
- b: {
- c: {
- d: 1
- }
- }
- },
- j: null,
- k: [4, 8, 9, 1]
- };
-
- var template = '{k.0}:{k.-2}:{a.b.c.d}:{x.y}:{j}';
-
- expect(Hoek.reachTemplate(obj, template)).to.equal('4:9:1::');
- done();
- });
-
- it('applies object to template (options)', function (done) {
-
- var obj = {
- a: {
- b: {
- c: {
- d: 1
- }
- }
- },
- j: null,
- k: [4, 8, 9, 1]
- };
-
- var template = '{k/0}:{k/-2}:{a/b/c/d}:{x/y}:{j}';
-
- expect(Hoek.reachTemplate(obj, template, '/')).to.equal('4:9:1::');
- done();
- });
-});
-
-describe('callStack()', function () {
-
- it('returns the full call stack', function (done) {
-
- var stack = Hoek.callStack();
- expect(stack[0][0]).to.contain('index.js');
- expect(stack[0][2]).to.equal(26);
- done();
- });
-});
-
-describe('displayStack ()', function () {
-
- it('returns the full call stack for display', function (done) {
-
- var stack = Hoek.displayStack();
- expect(stack[0]).to.contain(Path.normalize('/test/index.js') + ':');
- done();
- });
-
- it('includes constructor functions correctly', function (done) {
-
- var Something = function (next) {
-
- next();
- };
-
- var something = new Something(function () {
-
- var stack = Hoek.displayStack();
- expect(stack[1]).to.contain('new Something');
- done();
- });
- });
-});
-
-describe('abort()', function () {
-
- it('exits process when not in test mode', function (done) {
-
- var env = process.env.NODE_ENV;
- var write = process.stdout.write;
- var exit = process.exit;
-
- process.env.NODE_ENV = 'nottatest';
- process.stdout.write = function () { };
- process.exit = function (state) {
-
- process.exit = exit;
- process.env.NODE_ENV = env;
- process.stdout.write = write;
-
- expect(state).to.equal(1);
- done();
- };
-
- Hoek.abort('Boom');
- });
-
- it('throws when not in test mode and abortThrow is true', function (done) {
-
- var env = process.env.NODE_ENV;
- process.env.NODE_ENV = 'nottatest';
- Hoek.abortThrow = true;
-
- var fn = function () {
-
- Hoek.abort('my error message');
- };
-
- expect(fn).to.throw('my error message');
- Hoek.abortThrow = false;
- process.env.NODE_ENV = env;
-
- done();
- });
-
- it('respects hideStack argument', function (done) {
-
- var env = process.env.NODE_ENV;
- var write = process.stdout.write;
- var exit = process.exit;
- var output = '';
-
- process.exit = function () { };
- process.env.NODE_ENV = '';
- process.stdout.write = function (message) {
-
- output = message;
- };
-
- Hoek.abort('my error message', true);
-
- process.env.NODE_ENV = env;
- process.stdout.write = write;
- process.exit = exit;
-
- expect(output).to.equal('ABORT: my error message\n\t\n');
-
- done();
- });
-
- it('throws in test mode', function (done) {
-
- var env = process.env.NODE_ENV;
- process.env.NODE_ENV = 'test';
-
- expect(function () {
-
- Hoek.abort('my error message', true);
- }).to.throw('my error message');
-
- process.env.NODE_ENV = env;
- done();
- });
-
- it('throws in test mode with default message', function (done) {
-
- var env = process.env.NODE_ENV;
- process.env.NODE_ENV = 'test';
-
- expect(function () {
-
- Hoek.abort('', true);
- }).to.throw('Unknown error');
-
- process.env.NODE_ENV = env;
- done();
- });
-
- it('defaults to showing stack', function (done) {
-
- var env = process.env.NODE_ENV;
- var write = process.stdout.write;
- var exit = process.exit;
- var output = '';
-
- process.exit = function () { };
- process.env.NODE_ENV = '';
- process.stdout.write = function (message) {
-
- output = message;
- };
-
- Hoek.abort('my error message');
-
- process.env.NODE_ENV = env;
- process.stdout.write = write;
- process.exit = exit;
-
- expect(output).to.contain('index.js');
-
- done();
- });
-});
-
-describe('assert()', function () {
-
- it('throws an Error when using assert in a test', function (done) {
-
- var fn = function () {
-
- Hoek.assert(false, 'my error message');
- };
-
- expect(fn).to.throw('my error message');
- done();
- });
-
- it('throws an Error when using assert in a test with no message', function (done) {
-
- var fn = function () {
-
- Hoek.assert(false);
- };
-
- expect(fn).to.throw('Unknown error');
- done();
- });
-
- it('throws an Error when using assert in a test with multipart message', function (done) {
-
- var fn = function () {
-
- Hoek.assert(false, 'This', 'is', 'my message');
- };
-
- expect(fn).to.throw('This is my message');
- done();
- });
-
- it('throws an Error when using assert in a test with multipart message (empty)', function (done) {
-
- var fn = function () {
-
- Hoek.assert(false, 'This', 'is', '', 'my message');
- };
-
- expect(fn).to.throw('This is my message');
- done();
- });
-
- it('throws an Error when using assert in a test with object message', function (done) {
-
- var fn = function () {
-
- Hoek.assert(false, 'This', 'is', { spinal: 'tap' });
- };
-
- expect(fn).to.throw('This is {"spinal":"tap"}');
- done();
- });
-
- it('throws an Error when using assert in a test with multipart string and error messages', function (done) {
-
- var fn = function () {
-
- Hoek.assert(false, 'This', 'is', new Error('spinal'), new Error('tap'));
- };
-
- expect(fn).to.throw('This is spinal tap');
- done();
- });
-
- it('throws an Error when using assert in a test with error object message', function (done) {
-
- var fn = function () {
-
- Hoek.assert(false, new Error('This is spinal tap'));
- };
-
- expect(fn).to.throw('This is spinal tap');
- done();
- });
-
- it('throws the same Error that is passed to it if there is only one error passed', function (done) {
-
- var error = new Error('ruh roh');
- var error2 = new Error('ruh roh');
-
- var fn = function () {
-
- Hoek.assert(false, error);
- };
-
- try {
- fn();
- } catch (err) {
- expect(error).to.equal(error); // should be the same reference
- expect(error).to.not.equal(error2); // error with the same message should not match
- }
-
- done();
- });
-});
-
-describe('Timer', function () {
-
- it('returns time elapsed', function (done) {
-
- var timer = new Hoek.Timer();
- setTimeout(function () {
-
- expect(timer.elapsed()).to.be.above(9);
- done();
- }, 12);
- });
-});
-
-describe('Bench', function () {
-
- it('returns time elapsed', function (done) {
-
- var timer = new Hoek.Bench();
- setTimeout(function () {
-
- expect(timer.elapsed()).to.be.above(9);
- done();
- }, 12);
- });
-});
-
-describe('escapeRegex()', function () {
-
- it('escapes all special regular expression characters', function (done) {
-
- var a = Hoek.escapeRegex('4^f$s.4*5+-_?%=#!:@|~\\/`"(>)[<]d{}s,');
- expect(a).to.equal('4\\^f\\$s\\.4\\*5\\+\\-_\\?%\\=#\\!\\:@\\|~\\\\\\/`"\\(>\\)\\[<\\]d\\{\\}s\\,');
- done();
- });
-});
-
-describe('Base64Url', function () {
-
- var base64str = 'AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0-P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn-AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq-wsbKztLW2t7i5uru8vb6_wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t_g4eLj5OXm5-jp6uvs7e7v8PHy8_T19vf4-fr7_P3-_w';
- var str = unescape('%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20%21%22%23%24%25%26%27%28%29*+%2C-./0123456789%3A%3B%3C%3D%3E%3F@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7E%7F%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF');
-
- describe('base64urlEncode()', function () {
-
- it('should base64 URL-safe a string', function (done) {
-
- expect(Hoek.base64urlEncode(str)).to.equal(base64str);
- done();
- });
-
- it('encodes a buffer', function (done) {
-
- expect(Hoek.base64urlEncode(new Buffer(str, 'binary'))).to.equal(base64str);
- done();
- });
-
- it('should base64 URL-safe a hex string', function (done) {
-
- var buffer = new Buffer(str, 'binary');
- expect(Hoek.base64urlEncode(buffer.toString('hex'), 'hex')).to.equal(base64str);
- done();
- });
-
- it('works on larger input strings', function (done) {
-
- var input = Fs.readFileSync(Path.join(__dirname, 'index.js')).toString();
- var encoded = Hoek.base64urlEncode(input);
-
- expect(encoded).to.not.contain('+');
- expect(encoded).to.not.contain('/');
-
- var decoded = Hoek.base64urlDecode(encoded);
-
- expect(decoded).to.equal(input);
- done();
- });
- });
-
- describe('base64urlDecode()', function () {
-
- it('should un-base64 URL-safe a string', function (done) {
-
- expect(Hoek.base64urlDecode(base64str)).to.equal(str);
- done();
- });
-
- it('should un-base64 URL-safe a string into hex', function (done) {
-
- expect(Hoek.base64urlDecode(base64str, 'hex')).to.equal(new Buffer(str, 'binary').toString('hex'));
- done();
- });
-
- it('should un-base64 URL-safe a string and return a buffer', function (done) {
-
- var buf = Hoek.base64urlDecode(base64str, 'buffer');
- expect(buf instanceof Buffer).to.equal(true);
- expect(buf.toString('binary')).to.equal(str);
- done();
- });
-
- it('returns error on undefined input', function (done) {
-
- expect(Hoek.base64urlDecode().message).to.exist();
- done();
- });
-
- it('returns error on invalid input', function (done) {
-
- expect(Hoek.base64urlDecode('*').message).to.exist();
- done();
- });
- });
-});
-
-describe('escapeHeaderAttribute()', function () {
-
- it('should not alter ascii values', function (done) {
-
- var a = Hoek.escapeHeaderAttribute('My Value');
- expect(a).to.equal('My Value');
- done();
- });
-
- it('escapes all special HTTP header attribute characters', function (done) {
-
- var a = Hoek.escapeHeaderAttribute('I said go!!!#"' + String.fromCharCode(92));
- expect(a).to.equal('I said go!!!#\\"\\\\');
- done();
- });
-
- it('throws on large unicode characters', function (done) {
-
- var fn = function () {
-
- Hoek.escapeHeaderAttribute('this is a test' + String.fromCharCode(500) + String.fromCharCode(300));
- };
-
- expect(fn).to.throw(Error);
- done();
- });
-
- it('throws on CRLF to prevent response splitting', function (done) {
-
- var fn = function () {
-
- Hoek.escapeHeaderAttribute('this is a test\r\n');
- };
-
- expect(fn).to.throw(Error);
- done();
- });
-});
-
-describe('escapeHtml()', function () {
-
- it('escapes all special HTML characters', function (done) {
-
- var a = Hoek.escapeHtml('&<>"\'`');
- expect(a).to.equal('&amp;&lt;&gt;&quot;&#x27;&#x60;');
- done();
- });
-
- it('returns empty string on falsy input', function (done) {
-
- var a = Hoek.escapeHtml('');
- expect(a).to.equal('');
- done();
- });
-
- it('returns unchanged string on no reserved input', function (done) {
-
- var a = Hoek.escapeHtml('abc');
- expect(a).to.equal('abc');
- done();
- });
-});
-
-describe('nextTick()', function () {
-
- it('calls the provided callback on nextTick', function (done) {
-
- var a = 0;
-
- var inc = function (step, next) {
-
- a += step;
- next();
- };
-
- var ticked = Hoek.nextTick(inc);
-
- ticked(5, function () {
-
- expect(a).to.equal(6);
- done();
- });
-
- expect(a).to.equal(0);
- inc(1, function () {
-
- expect(a).to.equal(1);
- });
- });
-});
-
-describe('once()', function () {
-
- it('allows function to only execute once', function (done) {
-
- var gen = 0;
- var add = function (x) {
-
- gen += x;
- };
-
- add(5);
- expect(gen).to.equal(5);
- add = Hoek.once(add);
- add(5);
- expect(gen).to.equal(10);
- add(5);
- expect(gen).to.equal(10);
- done();
- });
-
- it('double once wraps one time', function (done) {
-
- var method = function () { };
- method = Hoek.once(method);
- method.x = 1;
- method = Hoek.once(method);
- expect(method.x).to.equal(1);
- done();
- });
-});
-
-describe('isAbsoltePath()', function () {
-
- it('identifies if path is absolute on Unix without node support', { parallel: false }, function (done) {
-
- var orig = Path.isAbsolute;
- Path.isAbsolute = undefined;
-
- expect(Hoek.isAbsolutePath('')).to.equal(false);
- expect(Hoek.isAbsolutePath('a')).to.equal(false);
- expect(Hoek.isAbsolutePath('./a')).to.equal(false);
- expect(Hoek.isAbsolutePath('/a')).to.equal(true);
- expect(Hoek.isAbsolutePath('/')).to.equal(true);
-
- Path.isAbsolute = orig;
-
- done();
- });
-
- it('identifies if path is absolute with fake node support', { parallel: false }, function (done) {
-
- var orig = Path.isAbsolute;
- Path.isAbsolute = function (path) {
-
- return path[0] === '/';
- };
-
- expect(Hoek.isAbsolutePath('', 'linux')).to.equal(false);
- expect(Hoek.isAbsolutePath('a', 'linux')).to.equal(false);
- expect(Hoek.isAbsolutePath('./a', 'linux')).to.equal(false);
- expect(Hoek.isAbsolutePath('/a', 'linux')).to.equal(true);
- expect(Hoek.isAbsolutePath('/', 'linux')).to.equal(true);
-
- Path.isAbsolute = orig;
-
- done();
- });
-
- it('identifies if path is absolute on Windows without node support', { parallel: false }, function (done) {
-
- var orig = Path.isAbsolute;
- Path.isAbsolute = undefined;
-
- expect(Hoek.isAbsolutePath('//server/file', 'win32')).to.equal(true);
- expect(Hoek.isAbsolutePath('//server/file', 'win32')).to.equal(true);
- expect(Hoek.isAbsolutePath('\\\\server\\file', 'win32')).to.equal(true);
- expect(Hoek.isAbsolutePath('C:/Users/', 'win32')).to.equal(true);
- expect(Hoek.isAbsolutePath('C:\\Users\\', 'win32')).to.equal(true);
- expect(Hoek.isAbsolutePath('C:cwd/another', 'win32')).to.equal(false);
- expect(Hoek.isAbsolutePath('C:cwd\\another', 'win32')).to.equal(false);
- expect(Hoek.isAbsolutePath('directory/directory', 'win32')).to.equal(false);
- expect(Hoek.isAbsolutePath('directory\\directory', 'win32')).to.equal(false);
-
- Path.isAbsolute = orig;
-
- done();
- });
-});
-
-describe('isInteger()', function () {
-
- it('validates integers', function (done) {
-
- expect(Hoek.isInteger(0)).to.equal(true);
- expect(Hoek.isInteger(1)).to.equal(true);
- expect(Hoek.isInteger(1394035612500)).to.equal(true);
- expect(Hoek.isInteger('0')).to.equal(false);
- expect(Hoek.isInteger(1.0)).to.equal(true);
- expect(Hoek.isInteger(1.1)).to.equal(false);
- done();
- });
-});
-
-describe('ignore()', function () {
-
- it('exists', function (done) {
-
- expect(Hoek.ignore).to.exist();
- expect(typeof Hoek.ignore).to.equal('function');
- done();
- });
-});
-
-describe('inherits()', function () {
-
- it('exists', function (done) {
-
- expect(Hoek.inherits).to.exist();
- expect(typeof Hoek.inherits).to.equal('function');
- done();
- });
-});
-
-describe('format()', function () {
-
- it('exists', function (done) {
-
- expect(Hoek.format).to.exist();
- expect(typeof Hoek.format).to.equal('function');
- done();
- });
-
- it('is a reference to Util.format', function (done) {
-
- expect(Hoek.format('hello %s', 'world')).to.equal('hello world');
- done();
- });
-});
-
-describe('transform()', function () {
-
- var source = {
- address: {
- one: '123 main street',
- two: 'PO Box 1234'
- },
- zip: {
- code: 3321232,
- province: null
- },
- title: 'Warehouse',
- state: 'CA'
- };
-
- var sourcesArray = [{
- address: {
- one: '123 main street',
- two: 'PO Box 1234'
- },
- zip: {
- code: 3321232,
- province: null
- },
- title: 'Warehouse',
- state: 'CA'
- }, {
- address: {
- one: '456 market street',
- two: 'PO Box 5678'
- },
- zip: {
- code: 9876,
- province: null
- },
- title: 'Garage',
- state: 'NY'
- }];
-
- it('transforms an object based on the input object', function (done) {
-
- var result = Hoek.transform(source, {
- 'person.address.lineOne': 'address.one',
- 'person.address.lineTwo': 'address.two',
- 'title': 'title',
- 'person.address.region': 'state',
- 'person.address.zip': 'zip.code',
- 'person.address.location': 'zip.province'
- });
-
- expect(result).to.deep.equal({
- person: {
- address: {
- lineOne: '123 main street',
- lineTwo: 'PO Box 1234',
- region: 'CA',
- zip: 3321232,
- location: null
- }
- },
- title: 'Warehouse'
- });
-
- done();
- });
-
- it('transforms an array of objects based on the input object', function (done) {
-
- var result = Hoek.transform(sourcesArray, {
- 'person.address.lineOne': 'address.one',
- 'person.address.lineTwo': 'address.two',
- 'title': 'title',
- 'person.address.region': 'state',
- 'person.address.zip': 'zip.code',
- 'person.address.location': 'zip.province'
- });
-
- expect(result).to.deep.equal([
- {
- person: {
- address: {
- lineOne: '123 main street',
- lineTwo: 'PO Box 1234',
- region: 'CA',
- zip: 3321232,
- location: null
- }
- },
- title: 'Warehouse'
- },
- {
- person: {
- address: {
- lineOne: '456 market street',
- lineTwo: 'PO Box 5678',
- region: 'NY',
- zip: 9876,
- location: null
- }
- },
- title: 'Garage'
- }
- ]);
-
- done();
- });
-
- it('uses the reach options passed into it', function (done) {
-
- var schema = {
- 'person.address.lineOne': 'address-one',
- 'person.address.lineTwo': 'address-two',
- 'title': 'title',
- 'person.address.region': 'state',
- 'person.prefix': 'person-title',
- 'person.zip': 'zip-code'
- };
- var options = {
- separator: '-',
- default: 'unknown'
- };
- var result = Hoek.transform(source, schema, options);
-
- expect(result).to.deep.equal({
- person: {
- address: {
- lineOne: '123 main street',
- lineTwo: 'PO Box 1234',
- region: 'CA'
- },
- prefix: 'unknown',
- zip: 3321232
- },
- title: 'Warehouse'
- });
-
- done();
- });
-
- it('works to create shallow objects', function (done) {
-
- var result = Hoek.transform(source, {
- lineOne: 'address.one',
- lineTwo: 'address.two',
- title: 'title',
- region: 'state',
- province: 'zip.province'
- });
-
- expect(result).to.deep.equal({
- lineOne: '123 main street',
- lineTwo: 'PO Box 1234',
- title: 'Warehouse',
- region: 'CA',
- province: null
- });
-
- done();
- });
-
- it('only allows strings in the map', function (done) {
-
- expect(function () {
-
- var result = Hoek.transform(source, {
- lineOne: {}
- });
- }).to.throw('All mappings must be "." delineated strings');
-
- done();
- });
-
- it('throws an error on invalid arguments', function (done) {
-
- expect(function () {
-
- var result = Hoek.transform(NaN, {});
- }).to.throw('Invalid source object: must be null, undefined, an object, or an array');
-
- done();
- });
-
- it('is safe to pass null', function (done) {
-
- var result = Hoek.transform(null, {});
- expect(result).to.deep.equal({});
-
- done();
- });
-
- it('is safe to pass undefined', function (done) {
-
- var result = Hoek.transform(undefined, {});
- expect(result).to.deep.equal({});
-
- done();
- });
-});
-
-describe('uniqueFilename()', function () {
-
- it('generates a random file path', function (done) {
-
- var result = Hoek.uniqueFilename('./test/modules');
-
- expect(result).to.exist();
- expect(result).to.be.a.string();
- expect(result).to.contain('test/modules');
- done();
- });
-
- it('is random enough to use in fast loops', function (done) {
-
- var results = [];
-
- for (var i = 0; i < 10; ++i) {
- results[i] = Hoek.uniqueFilename('./test/modules');
- }
-
- var filter = results.filter(function (item, index, array) {
-
- return array.indexOf(item) === index;
- });
-
- expect(filter.length).to.equal(10);
- expect(results.length).to.equal(10);
- done();
-
- });
-
- it('combines the random elements with a supplied character', function (done) {
-
- var result = Hoek.uniqueFilename('./test', 'txt');
-
- expect(result).to.contain('test/');
- expect(result).to.contain('.txt');
-
- done();
- });
-
- it('accepts extensions with a "." in it', function (done) {
-
- var result = Hoek.uniqueFilename('./test', '.mp3');
-
- expect(result).to.contain('test/');
- expect(result).to.contain('.mp3');
-
- done();
- });
-});
-
-describe('stringify()', function (done) {
-
- it('converts object to string', function (done) {
-
- var obj = { a: 1 };
- expect(Hoek.stringify(obj)).to.equal('{"a":1}');
- done();
- });
-
- it('returns error in result string', function (done) {
-
- var obj = { a: 1 };
- obj.b = obj;
- expect(Hoek.stringify(obj)).to.equal('[Cannot display object: Converting circular structure to JSON]');
- done();
- });
-});
-
-describe('shallow()', function (done) {
-
- it('shallow copies an object', function (done) {
-
- var obj = {
- a: 5,
- b: {
- c: 6
- }
- };
-
- var shallow = Hoek.shallow(obj);
- expect(shallow).to.not.equal(obj);
- expect(shallow).to.deep.equal(obj);
- expect(shallow.b).to.equal(obj.b);
- done();
- });
-});
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/ignore.txt b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/ignore.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/ignore.txt
+++ /dev/null
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js
deleted file mode 100644
index fa4e06abe0..0000000000
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js
+++ /dev/null
@@ -1 +0,0 @@
-exports.x = 1;
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js
deleted file mode 100644
index 88e9166e86..0000000000
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js
+++ /dev/null
@@ -1 +0,0 @@
-exports.y = 2;
diff --git a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js b/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js
deleted file mode 100644
index 670e724a6e..0000000000
--- a/deps/npm/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js
+++ /dev/null
@@ -1 +0,0 @@
-exports.z = 3;