account-dev
Version:
1,961 lines (1,633 loc) • 68.2 kB
JavaScript
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
require('lambdajs').expose(window);
var ALIEN_ID = "account";
var request = require("superagent");
var adda = require("divsense-adda-helper");
var alienBody = require("divsense-alien-body")( ALIEN_ID );
var init = adda.init;
var makeNode = adda.makeNode;
var setChild = adda.setChild;
var toArray = adda.toArray;
var cont = compose( //[[[1
toArray,
setChild( "__root__", "_welcome" ),
makeNode( "_welcome", {
t: "Welcome!",
u: {type:"text",},
k: {fontweight:"bold", color: "blue"}
}),
init
);
var signInForm = compose( //[[[1
toArray,
// setChild( "__root__", "_submit" ),
setChild( "__root__", "_password" ),
setChild( "__root__", "_username" ),
// makeNode( "_submit", {
// t: "Submit",
// u: {type:"command", command: "SIGNAL", fixed: "true"},
// k: {icon:"fa-check"}
// }),
makeNode( "_password", {
u: {type:"input", subtype:"password", fixed: "true", tag:"form", name:"password"},
k: {placeholder:"password",icon:"fa-circle-o"}
}),
makeNode( "_username", {
u: {type:"input", subtype:"text", fixed: "true", tag:"form",name:"username"},
k: {placeholder:"username",icon:"fa-circle-o"}
}),
init
);
var signInHead = function(){ //[[[1
return {
icon: "fa-sign-in",
text: "sign in",
data_attrs: [
["tag", "signin"],
["fixed", "true"],
["change", "content nodes dataset tag form"],
],
content: signInForm()
}
}
var handleHeadEvent = function( req, res, next ){ //[[[1
console.log( "ACCOUNT HANDLE HEAD EVENT", req );
var input = req.params.user_input;
if( input === "in" ){
res.content = {
head: signInHead()
}
}
else if( input === "out" ){
res.content = {
head:{
icon: "fa-sign-out",
text: "Bye, bye!",
data_attrs: [["fixed","true"]]
}
};
}
next( res );
}
var handleChannelSignal = function(req, res, next){ //[[[1
console.log("ACCOUNT SIGNAL", req );
if( req.method === "signal" ){
var tag = adda.getUnitData( "u", "tag", req.params.head );
if( tag === "signin" ){ // user tries to sign in
// get 'username' and 'password' elements
var form_elems = reduce( function(m,e){
var name = adda.getUnitData( "u", "name", e );
if( (name === "username" || name === "password" ) )
m[ name ] = e.t;
return m;
}, {}, req.params.content );
if( form_elems.username && form_elems.password ){
res.content = {
head:{
icon: "fa-home",
text: form_elems.username,
data_attrs: [
["tag", "home"],
["save", "content all"]
],
content: cont()
}
}
}
}
else{
// save in CoundDB
//
}
}
next( res );
}
//]]]1
alienBody.on("channel", handleChannelSignal );
alienBody.on("head", handleHeadEvent );
},{"divsense-adda-helper":2,"divsense-alien-body":3,"lambdajs":4,"superagent":14}],2:[function(require,module,exports){
// ADDA Helpers
//
var props = function( obj ){
return Object.keys( obj ).reduce(function(m,a){
m.push( [ a, obj[ a ] ] );
return m;
}, []);
}
var makeNode = function( id, params ){
return function(set){
set = set || {};
var s = set[ id ] = {};
if( params.t ) s.t = params.t;
if( params.u ) s.u = props( params.u );
if( params.k ) s.k = props( params.k );
return set;
}
}
var setChildNodes = function( parentId, cids, branchName ){
return function(set){
branchName = branchName || "children-mmap";
var node = set[ parentId ];
node.c = node.c || [];
node.c.push( [ branchName, cids] );
cids.forEach( function(id){ set[id].p = parentId });
return set;
}
}
var setChild = function( parentId, childId, branchName ){
return function(set){
branchName = branchName || "children-mmap";
var node = set[ parentId ];
node.c = node.c || [];
if( !node.c.length ){
node.c.push( [ branchName, []] );
}
node.c = node.c.map(function(a){
if( a[0] === branchName )
a[1].push( childId );
return a;
});
set[ childId ].p = parentId;
return set;
}
}
var init = makeNode("__root__", {});
var toArray = function( set, id, array ){
var node = set[ id ];
node.id = id;
delete node.p;
array.push( node );
return (node.c || []).reduce(function(acc,branch){
acc = branch[1].reduce(function(m,a){
m = toArray( set, a, m );
return m;
}, acc );
return acc;
}, array );
}
var getUnitData = function( level, dataAttr, node ){
return (node[ level ] || [] ).reduce(function(m,a){
if( a[0] === dataAttr ) m = a[1];
return m;
}, "");
}
exports.makeNode = makeNode;
exports.setChildNodes = setChildNodes;
exports.setChild = setChild;
exports.init = init;
exports.getUnitData = getUnitData;
exports.toArray = function( set ){
return toArray( set, "__root__", [] );
}
},{}],3:[function(require,module,exports){
'use strict';
var debugMode;
var cache = {};
var source = [
"head",
"channel",
];
var on = function( evt, fn ){
cache[evt] = cache[evt] || [];
cache[evt].push( fn );
return [evt,fn];
}
var post = function( evt, req, res, next ){
cache[evt] && cache[evt].forEach( function( sub ){
sub( req, res, next );
});
}
var emit = function( req, res, next ){
if( source.indexOf( req.source ) !== -1 ) {
debugMode && console.log( "ALIEN-BODY EVENT:", req.source, req.method );
post( req.source, req, res, next );
}
else{
debugMode && console.log( "ALIEN-BODY ERROR. INVALID METHOD:", req.source );
}
}
var getMessage = function( evt ){
try{
var req = JSON.parse( evt.data );
debugMode && console.log( "ALIEN-BODY. MSG FROM DIVSENSE:", req );
var res = {
id: req.id,
status: "ok",
content: {}
};
emit( req, res, function(res){
evt.source.postMessage( JSON.stringify( res ), evt.origin );
});
}
catch(e){
debugMode && console.log( "ALIEN-BODY ERROR. INVALID MESSAGE:", evt.data );
}
}
module.exports = function( id, debug ){
debugMode = debug || false;
debugMode && console.log( "ALIEN-BODY IS UP");
window.onload = function(){
var msg = { id: id, status: "alive" };
parent.postMessage( JSON.stringify(msg), "*" );
}
window.addEventListener("message", getMessage, false );
return {
on:on
}
}
},{}],4:[function(require,module,exports){
module.exports = require('./src/lambda.js');
},{"./src/lambda.js":13}],5:[function(require,module,exports){
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm/`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
var isFunction = require('lodash.isfunction');
/**
* Creates a function that is the composition of the provided functions,
* where each function consumes the return value of the function that follows.
* For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`.
* Each function is executed with the `this` binding of the composed function.
*
* @static
* @memberOf _
* @category Functions
* @param {...Function} [func] Functions to compose.
* @returns {Function} Returns the new composed function.
* @example
*
* var realNameMap = {
* 'pebbles': 'penelope'
* };
*
* var format = function(name) {
* name = realNameMap[name.toLowerCase()] || name;
* return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
* };
*
* var greet = function(formatted) {
* return 'Hiya ' + formatted + '!';
* };
*
* var welcome = _.compose(greet, format);
* welcome('pebbles');
* // => 'Hiya Penelope!'
*/
function compose() {
var funcs = arguments,
length = funcs.length;
while (length--) {
if (!isFunction(funcs[length])) {
throw new TypeError;
}
}
return function() {
var args = arguments,
length = funcs.length;
while (length--) {
args = [funcs[length].apply(this, args)];
}
return args[0];
};
}
module.exports = compose;
},{"lodash.isfunction":6}],6:[function(require,module,exports){
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm/`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
/**
* Checks if `value` is a function.
*
* @static
* @memberOf _
* @category Objects
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if the `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*/
function isFunction(value) {
return typeof value == 'function';
}
module.exports = isFunction;
},{}],7:[function(require,module,exports){
/**
* lodash 3.0.1 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
var createWrapper = require('lodash._createwrapper'),
isIterateeCall = require('lodash._isiterateecall');
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8;
/**
* Creates a `_.curry` or `_.curryRight` function.
*
* @private
* @param {boolean} flag The curry bit flag.
* @returns {Function} Returns the new curry function.
*/
function createCurry(flag) {
function curryFunc(func, arity, guard) {
if (guard && isIterateeCall(func, arity, guard)) {
arity = null;
}
var result = createWrapper(func, flag, null, null, null, null, null, arity);
result.placeholder = curryFunc.placeholder;
return result;
}
return curryFunc;
}
/**
* Creates a function that accepts one or more arguments of `func` that when
* called either invokes `func` returning its result, if all `func` arguments
* have been provided, or returns a function that accepts one or more of the
* remaining `func` arguments, and so on. The arity of `func` may be specified
* if `func.length` is not sufficient.
*
* The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
* may be used as a placeholder for provided arguments.
*
* **Note:** This method does not set the `length` property of curried functions.
*
* @static
* @memberOf _
* @category Function
* @param {Function} func The function to curry.
* @param {number} [arity=func.length] The arity of `func`.
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
* @returns {Function} Returns the new curried function.
* @example
*
* var abc = function(a, b, c) {
* return [a, b, c];
* };
*
* var curried = _.curry(abc);
*
* curried(1)(2)(3);
* // => [1, 2, 3]
*
* curried(1, 2)(3);
* // => [1, 2, 3]
*
* curried(1, 2, 3);
* // => [1, 2, 3]
*
* // using placeholders
* curried(1)(_, 3)(2);
* // => [1, 2, 3]
*/
var curry = createCurry(CURRY_FLAG);
// Assign default placeholders.
curry.placeholder = {};
module.exports = curry;
},{"lodash._createwrapper":8,"lodash._isiterateecall":12}],8:[function(require,module,exports){
(function (global){
/**
* lodash 3.0.4 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
var arrayCopy = require('lodash._arraycopy'),
baseCreate = require('lodash._basecreate'),
replaceHolders = require('lodash._replaceholders');
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
BIND_KEY_FLAG = 2,
CURRY_BOUND_FLAG = 4,
CURRY_FLAG = 8,
CURRY_RIGHT_FLAG = 16,
PARTIAL_FLAG = 32,
PARTIAL_RIGHT_FLAG = 64,
ARY_FLAG = 128;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
* of an array-like value.
*/
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
/**
* Creates an array that is the composition of partially applied arguments,
* placeholders, and provided arguments into a single array of arguments.
*
* @private
* @param {Array|Object} args The provided arguments.
* @param {Array} partials The arguments to prepend to those provided.
* @param {Array} holders The `partials` placeholder indexes.
* @returns {Array} Returns the new array of composed arguments.
*/
function composeArgs(args, partials, holders) {
var holdersLength = holders.length,
argsIndex = -1,
argsLength = nativeMax(args.length - holdersLength, 0),
leftIndex = -1,
leftLength = partials.length,
result = Array(argsLength + leftLength);
while (++leftIndex < leftLength) {
result[leftIndex] = partials[leftIndex];
}
while (++argsIndex < holdersLength) {
result[holders[argsIndex]] = args[argsIndex];
}
while (argsLength--) {
result[leftIndex++] = args[argsIndex++];
}
return result;
}
/**
* This function is like `composeArgs` except that the arguments composition
* is tailored for `_.partialRight`.
*
* @private
* @param {Array|Object} args The provided arguments.
* @param {Array} partials The arguments to append to those provided.
* @param {Array} holders The `partials` placeholder indexes.
* @returns {Array} Returns the new array of composed arguments.
*/
function composeArgsRight(args, partials, holders) {
var holdersIndex = -1,
holdersLength = holders.length,
argsIndex = -1,
argsLength = nativeMax(args.length - holdersLength, 0),
rightIndex = -1,
rightLength = partials.length,
result = Array(argsLength + rightLength);
while (++argsIndex < argsLength) {
result[argsIndex] = args[argsIndex];
}
var offset = argsIndex;
while (++rightIndex < rightLength) {
result[offset + rightIndex] = partials[rightIndex];
}
while (++holdersIndex < holdersLength) {
result[offset + holders[holdersIndex]] = args[argsIndex++];
}
return result;
}
/**
* Creates a function that wraps `func` and invokes it with the `this`
* binding of `thisArg`.
*
* @private
* @param {Function} func The function to bind.
* @param {*} [thisArg] The `this` binding of `func`.
* @returns {Function} Returns the new bound function.
*/
function createBindWrapper(func, thisArg) {
var Ctor = createCtorWrapper(func);
function wrapper() {
var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
return fn.apply(thisArg, arguments);
}
return wrapper;
}
/**
* Creates a function that produces an instance of `Ctor` regardless of
* whether it was invoked as part of a `new` expression or by `call` or `apply`.
*
* @private
* @param {Function} Ctor The constructor to wrap.
* @returns {Function} Returns the new wrapped function.
*/
function createCtorWrapper(Ctor) {
return function() {
var thisBinding = baseCreate(Ctor.prototype),
result = Ctor.apply(thisBinding, arguments);
// Mimic the constructor's `return` behavior.
// See https://es5.github.io/#x13.2.2 for more details.
return isObject(result) ? result : thisBinding;
};
}
/**
* Creates a function that wraps `func` and invokes it with optional `this`
* binding of, partial application, and currying.
*
* @private
* @param {Function|string} func The function or method name to reference.
* @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.
* @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to prepend to those provided to the new function.
* @param {Array} [holders] The `partials` placeholder indexes.
* @param {Array} [partialsRight] The arguments to append to those provided to the new function.
* @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
* @param {Array} [argPos] The argument positions of the new function.
* @param {number} [ary] The arity cap of `func`.
* @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
var isAry = bitmask & ARY_FLAG,
isBind = bitmask & BIND_FLAG,
isBindKey = bitmask & BIND_KEY_FLAG,
isCurry = bitmask & CURRY_FLAG,
isCurryBound = bitmask & CURRY_BOUND_FLAG,
isCurryRight = bitmask & CURRY_RIGHT_FLAG;
var Ctor = !isBindKey && createCtorWrapper(func),
key = func;
function wrapper() {
// Avoid `arguments` object use disqualifying optimizations by
// converting it to an array before providing it to other functions.
var length = arguments.length,
index = length,
args = Array(length);
while (index--) {
args[index] = arguments[index];
}
if (partials) {
args = composeArgs(args, partials, holders);
}
if (partialsRight) {
args = composeArgsRight(args, partialsRight, holdersRight);
}
if (isCurry || isCurryRight) {
var placeholder = wrapper.placeholder,
argsHolders = replaceHolders(args, placeholder);
length -= argsHolders.length;
if (length < arity) {
var newArgPos = argPos ? arrayCopy(argPos) : null,
newArity = nativeMax(arity - length, 0),
newsHolders = isCurry ? argsHolders : null,
newHoldersRight = isCurry ? null : argsHolders,
newPartials = isCurry ? args : null,
newPartialsRight = isCurry ? null : args;
bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
if (!isCurryBound) {
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
}
var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity);
result.placeholder = placeholder;
return result;
}
}
var thisBinding = isBind ? thisArg : this;
if (isBindKey) {
func = thisBinding[key];
}
if (argPos) {
args = reorder(args, argPos);
}
if (isAry && ary < args.length) {
args.length = ary;
}
var fn = (this && this !== global && this instanceof wrapper) ? (Ctor || createCtorWrapper(func)) : func;
return fn.apply(thisBinding, args);
}
return wrapper;
}
/**
* Creates a function that wraps `func` and invokes it with the optional `this`
* binding of `thisArg` and the `partials` prepended to those provided to
* the wrapper.
*
* @private
* @param {Function} func The function to partially apply arguments to.
* @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} partials The arguments to prepend to those provided to the new function.
* @returns {Function} Returns the new bound function.
*/
function createPartialWrapper(func, bitmask, thisArg, partials) {
var isBind = bitmask & BIND_FLAG,
Ctor = createCtorWrapper(func);
function wrapper() {
// Avoid `arguments` object use disqualifying optimizations by
// converting it to an array before providing it `func`.
var argsIndex = -1,
argsLength = arguments.length,
leftIndex = -1,
leftLength = partials.length,
args = Array(argsLength + leftLength);
while (++leftIndex < leftLength) {
args[leftIndex] = partials[leftIndex];
}
while (argsLength--) {
args[leftIndex++] = arguments[++argsIndex];
}
var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
return fn.apply(isBind ? thisArg : this, args);
}
return wrapper;
}
/**
* Creates a function that either curries or invokes `func` with optional
* `this` binding and partially applied arguments.
*
* @private
* @param {Function|string} func The function or method name to reference.
* @param {number} bitmask The bitmask of flags.
* The bitmask may be composed of the following flags:
* 1 - `_.bind`
* 2 - `_.bindKey`
* 4 - `_.curry` or `_.curryRight` of a bound function
* 8 - `_.curry`
* 16 - `_.curryRight`
* 32 - `_.partial`
* 64 - `_.partialRight`
* 128 - `_.rearg`
* 256 - `_.ary`
* @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to be partially applied.
* @param {Array} [holders] The `partials` placeholder indexes.
* @param {Array} [argPos] The argument positions of the new function.
* @param {number} [ary] The arity cap of `func`.
* @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
var isBindKey = bitmask & BIND_KEY_FLAG;
if (!isBindKey && typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
var length = partials ? partials.length : 0;
if (!length) {
bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
partials = holders = null;
}
length -= (holders ? holders.length : 0);
if (bitmask & PARTIAL_RIGHT_FLAG) {
var partialsRight = partials,
holdersRight = holders;
partials = holders = null;
}
var newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
newData[9] = arity == null
? (isBindKey ? 0 : func.length)
: (nativeMax(arity - length, 0) || 0);
if (bitmask == BIND_FLAG) {
var result = createBindWrapper(newData[0], newData[2]);
} else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {
result = createPartialWrapper.apply(undefined, newData);
} else {
result = createHybridWrapper.apply(undefined, newData);
}
return result;
}
/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
value = +value;
length = length == null ? MAX_SAFE_INTEGER : length;
return value > -1 && value % 1 == 0 && value < length;
}
/**
* Reorder `array` according to the specified indexes where the element at
* the first index is assigned as the first element, the element at
* the second index is assigned as the second element, and so on.
*
* @private
* @param {Array} array The array to reorder.
* @param {Array} indexes The arranged array indexes.
* @returns {Array} Returns `array`.
*/
function reorder(array, indexes) {
var arrLength = array.length,
length = nativeMin(indexes.length, arrLength),
oldArray = arrayCopy(array);
while (length--) {
var index = indexes[length];
array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
}
return array;
}
/**
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(1);
* // => false
*/
function isObject(value) {
// Avoid a V8 JIT bug in Chrome 19-20.
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
var type = typeof value;
return type == 'function' || (!!value && type == 'object');
}
module.exports = createWrapper;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"lodash._arraycopy":9,"lodash._basecreate":10,"lodash._replaceholders":11}],9:[function(require,module,exports){
/**
* lodash 3.0.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
/**
* Copies the values of `source` to `array`.
*
* @private
* @param {Array} source The array to copy values from.
* @param {Array} [array=[]] The array to copy values to.
* @returns {Array} Returns `array`.
*/
function arrayCopy(source, array) {
var index = -1,
length = source.length;
array || (array = Array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
}
module.exports = arrayCopy;
},{}],10:[function(require,module,exports){
(function (global){
/**
* lodash 3.0.1 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} prototype The object to inherit from.
* @returns {Object} Returns the new object.
*/
var baseCreate = (function() {
function Object() {}
return function(prototype) {
if (isObject(prototype)) {
Object.prototype = prototype;
var result = new Object;
Object.prototype = null;
}
return result || global.Object();
};
}());
/**
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(1);
* // => false
*/
function isObject(value) {
// Avoid a V8 JIT bug in Chrome 19-20.
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
var type = typeof value;
return type == 'function' || (!!value && type == 'object');
}
module.exports = baseCreate;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],11:[function(require,module,exports){
/**
* lodash 3.0.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
/** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__';
/**
* Replaces all `placeholder` elements in `array` with an internal placeholder
* and returns an array of their indexes.
*
* @private
* @param {Array} array The array to modify.
* @param {*} placeholder The placeholder to replace.
* @returns {Array} Returns the new array of placeholder indexes.
*/
function replaceHolders(array, placeholder) {
var index = -1,
length = array.length,
resIndex = -1,
result = [];
while (++index < length) {
if (array[index] === placeholder) {
array[index] = PLACEHOLDER;
result[++resIndex] = index;
}
}
return result;
}
module.exports = replaceHolders;
},{}],12:[function(require,module,exports){
/**
* lodash 3.0.7 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
/**
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
* of an array-like value.
*/
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
/**
* The base implementation of `_.property` without support for deep paths.
*
* @private
* @param {string} key The key of the property to get.
* @returns {Function} Returns the new function.
*/
function baseProperty(key) {
return function(object) {
return object == null ? undefined : object[key];
};
}
/**
* Gets the "length" property value of `object`.
*
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
* that affects Safari on at least iOS 8.1-8.3 ARM64.
*
* @private
* @param {Object} object The object to query.
* @returns {*} Returns the "length" value.
*/
var getLength = baseProperty('length');
/**
* Checks if `value` is array-like.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
*/
function isArrayLike(value) {
return value != null && isLength(getLength(value));
}
/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
value = +value;
length = length == null ? MAX_SAFE_INTEGER : length;
return value > -1 && value % 1 == 0 && value < length;
}
/**
* Checks if the provided arguments are from an iteratee call.
*
* @private
* @param {*} value The potential iteratee value argument.
* @param {*} index The potential iteratee index or key argument.
* @param {*} object The potential iteratee object argument.
* @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
*/
function isIterateeCall(value, index, object) {
if (!isObject(object)) {
return false;
}
var type = typeof index;
if (type == 'number'
? (isArrayLike(object) && isIndex(index, object.length))
: (type == 'string' && index in object)) {
var other = object[index];
return value === value ? (value === other) : (other !== other);
}
return false;
}
/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
*/
function isLength(value) {
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
/**
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(1);
* // => false
*/
function isObject(value) {
// Avoid a V8 JIT bug in Chrome 19-20.
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
var type = typeof value;
return type == 'function' || (!!value && type == 'object');
}
module.exports = isIterateeCall;
},{}],13:[function(require,module,exports){
var curry = require('lodash.curry');
var compose = require('lodash.compose');
// All methods from
// * Arrays
// * Numbers
// * Objects
// * Regexp
// * Strings
// * Date (coming soon)
// RULES:
// 1. The data comes last. E.g: str.method(arg) -> method(arg, str)
// 2. Everything is curried
// 3. Functions with optional arguments are split into two functions. One with _ at the end that takes the options. E.g: indexOf(x,str) & indexOf_(x,y,str)
// 4. Everything is pure in that it doesn't mutate arguments
_LambdaJS = {};
// UTILS
// =========================
_LambdaJS.get = curry(function( param, obj ){
return obj[param];
})
_LambdaJS.multiply = curry(function( x, y ) {
return x * y;
})
_LambdaJS.div = curry(function( x, y ) {
return x / y;
})
_LambdaJS.add = curry(function( x, y ) {
return x + y;
})
_LambdaJS.subtract = curry(function( x, y ) {
return x - y;
})
_LambdaJS.mod = curry(function(x,y) {
return x % y;
})
_LambdaJS.gt = curry(function( x, y ) {
return x > y;
})
_LambdaJS.gte = curry(function( x, y ) {
return x >= y;
})
_LambdaJS.lt = curry(function( x, y ) {
return x < y;
})
_LambdaJS.lte = curry(function( x, y ) {
return x <= y;
})
_LambdaJS.equal = curry(function( x, y ) {
return x === y;
})
_LambdaJS.eq = curry(function( x, y ) {
return x == y;
})
// STRINGS
// =========================
//+ charAt :: Int -> String -> String
_LambdaJS.charAt = curry(function( i, s ){
return s.charAt(i);
});
//+ charCodeAt :: Int -> String -> Int
_LambdaJS.charCodeAt = curry(function( i, s ){
return s.charCodeAt( i );
});
//+ indexOf :: a -> String -> Int
_LambdaJS.indexOf = curry(function( value, a ){
return a.indexOf( value );
});
//+ indexOf_ :: a -> Int -> String -> Int
_LambdaJS.indexOf_ = curry(function( value, len, a ){
return a.indexOf( value, len );
});
//+ lastIndexOf :: a -> [a] -> Int
_LambdaJS.lastIndexOf = curry(function( value, a ){
return a.lastIndexOf( value );
});
//+ match :: Regexp|String -> String -> [String]
_LambdaJS.match = curry(function( regexp, s ){
return s.match( regexp );
});
//+ replace :: Regexp|String -> String -> String -> String
_LambdaJS.replace = curry(function( a, b, s ){
return s.replace( a, b );
});
//+ search :: Regexp|String -> String -> Int
_LambdaJS.search = curry(function( regexp, s ){
return s.search( regexp );
});
//+ split :: String -> String -> [String]
_LambdaJS.split = curry(function( separator, s ){
return s.split( separator );
});
//+ split_ :: String -> Int -> String -> [String]
_LambdaJS.split_ = curry(function( separator, len, s ){
return s.split( separator, len );
});
//+ substring :: Int -> String -> String
_LambdaJS.substring = curry(function( start, s ){
return s.substring( start );
});
//+ substring_ :: Int -> Int -> String -> String
_LambdaJS.substring_ = curry(function( start, end, s ){
return s.substring( start, end );
});
//+ toLocaleLowerCase :: String -> String
_LambdaJS.toLocaleLowerCase = function( s ){
return s.toLocaleLowerCase();
}
//+ toLocaleUpperCase :: String -> String
_LambdaJS.toLocaleUpperCase = function( s ){
return s.toLocaleUpperCase();
}
//+ toLocaleString :: String -> String
_LambdaJS.toLocaleString = function( a ){
return a.toLocaleString();
}
//+ toLowerCase :: String -> String
_LambdaJS.toLowerCase = function( s ){
return s.toLowerCase();
}
//+ toUpperCase :: String -> String
_LambdaJS.toUpperCase = function( s ){
return s.toUpperCase();
}
//+ trim :: String -> String
_LambdaJS.trim = function( s ){
return s.trim();
}
// Arrays
// =========================
//+ every :: (a -> Boolean) -> [a] -> Boolean
_LambdaJS.every = curry(function( fn, xs ) {
return xs.every(fn);
});
//+ filter :: (a -> Boolean) -> [a] -> [a]
_LambdaJS.filter = curry(function(fn, xs) {
return xs.filter(fn);
});
//+ forEach :: (a -> undefined) -> [a] -> undefined
_LambdaJS.forEach = curry(function( fn, xs ) {
return xs.forEach(fn);
});
//+ indexOf :: a -> [a] -> Int
_LambdaJS.indexOf = curry(function( value, a ){
return a.indexOf( value );
});
//+ indexOf_ :: a -> Int -> [a] -> Int
_LambdaJS.indexOf_ = curry(function( value, len, a ){
return a.indexOf( value, len );
});
//+ join :: String -> [a] -> String
_LambdaJS.join = curry(function( separator, arr ){
return arr.join( separator );
});
//+ lastIndexOf :: a -> [a] -> Int
_LambdaJS.lastIndexOf = curry(function( value, a ){
return a.lastIndexOf( value );
});
//+ map :: (a -> b) -> [a] -> [b]
_LambdaJS.map = curry(function(fn, xs) {
return xs.map(fn);
});
//+ pop :: [a] -> [a]
_LambdaJS.pop = function( a ){
return a.slice(0,-1);
}
//+ push :: a -> [a] -> [a]
_LambdaJS.push = curry(function( value, a ){
// cloning the array
var b = a.slice(0);
b.push( value );
return b;
});
//+ reduce :: (b -> a -> b) -> b -> [a] -> b
_LambdaJS.reduce = curry(function(fn, acc, xs) {
return xs.reduce(fn, acc);
});
//+ reduceRight :: (b -> a -> b) -> b -> [a] -> b
_LambdaJS.reduceRight = curry(function(fn, acc, xs) {
return xs.reduceRight(fn, acc);
});
//+ reverse :: [a] -> [a]
_LambdaJS.reverse = function( a ){
return a.slice(0).reverse();
}
//+ shift :: [a] -> [a]
_LambdaJS.shift = function( arr ){
return arr.slice(1);
}
//+ some :: (a -> Boolean) -> [a] -> Boolean
_LambdaJS.some = curry(function( fn, xs ) {
return xs.some(fn);
});
//+ sort :: [a] -> [a]
_LambdaJS.sort = function( a ){
return a.slice(0).sort();
}
//+ splice :: Int -> Int -> [a] -> [a]
_LambdaJS.splice = curry(function( index, count, a ){
var b = a.slice(0);
b.splice( index, count );
return b;
});
//+ unshift :: a -> [a] -> [a]
_LambdaJS.unshift = curry(function( value, a ){
var b = a.slice(0);
b.unshift( value );
return b;
});
// REGEXPS
// =========================
//+ exec :: Regexp -> String -> [String]
_LambdaJS.exec = curry(function( r, str ){
return r.exec( str );
});
//+ test :: Regexp -> String -> Boolean
_LambdaJS.test = curry(function( r, str ){
return r.test( str );
});
// OBJECTS
// =========================
//+ String -> {} -> Boolean
_LambdaJS.hasOwnProperty = curry(function( prop, o ){
return o.hasOwnProperty( prop );
});
//+ isPrototypeOf :: {} -> Function -> Boolean
_LambdaJS.isPrototypeOf = curry(function( a, b ){
return b.prototype.isPrototypeOf( a );
});
// NUMBERS
// =========================
//+ toExponential :: Int -> Number -> String
_LambdaJS.toExponential = curry(function( fractionDigits, n ){
return n.toExponential( fractionDigits );
});
//+ toFixed :: Number -> Number -> String
_LambdaJS.toFixed = curry(function( digits, n ){
return n.toFixed( digits );
})
//+ toPrecision :: Number -> Number -> String
_LambdaJS.toPrecision = curry(function( precision, n ){
return n.toPrecision( precision );
});
// Shared
// =========================
//+ concat :: [[a]] -> [a]
_LambdaJS.concat = curry(function(x) {
var kind = (typeof x == "string") ? "" : []; // better way?
return kind.concat.apply(kind, arguments);
}, 2);
//+ slice :: Int -> [a]
_LambdaJS.slice = curry(function( begin, a ){
return a.slice( begin );
});
//+ slice_ :: Int -> Int -> [a]
_LambdaJS.slice_ = curry(function( begin, end, a ){
return a.slice( begin, end );
});
//+ toString :: a -> String
_LambdaJS.toString = function( s ){
return s.toString();
}
//+ valueOf :: a -> a
_LambdaJS.valueOf = function( a ){
return a.valueOf();
}
_LambdaJS.curry = curry;
_LambdaJS.compose = compose;
_LambdaJS.expose = function(env) {
var f;
for (f in _LambdaJS) {
if (f !== 'expose' && _LambdaJS.hasOwnProperty(f)) {
env[f] = _LambdaJS[f];
}
}
return _LambdaJS;
}
module.exports = _LambdaJS;
if(typeof window == "object") {
LambdaJS = _LambdaJS;
}
},{"lodash.compose":5,"lodash.curry":7}],14:[function(require,module,exports){
/**
* Module dependencies.
*/
var Emitter = require('emitter');
var reduce = require('reduce');
/**
* Root reference for iframes.
*/
var root = 'undefined' == typeof window
? (this || self)
: window;
/**
* Noop.
*/
function noop(){};
/**
* Check if `obj` is a host object,
* we don't want to serialize these :)
*
* TODO: future proof, move to compoent land
*
* @param {Object} obj
* @return {Boolean}
* @api private
*/
function isHost(obj) {
var str = {}.toString.call(obj);
switch (str) {
case '[object File]':
case '[object Blob]':
case '[object FormData]':
return true;
default:
return false;
}
}
/**
* Determine XHR.
*/
request.getXHR = function () {
if (root.XMLHttpRequest
&& (!root.location || 'file:' != root.location.protocol
|| !root.ActiveXObject)) {
return new XMLHttpRequest;
} else {
try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}
try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}
try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}
try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}
}
return false;
};
/**
* Removes leading and trailing whitespace, added to support IE.
*
* @param {String} s
* @return {String}
* @api private
*/
var trim = ''.trim
? function(s) { return s.trim(); }
: function(s) { return s.replace(/(^\s*|\s*$)/g, ''); };
/**
* Check if `obj` is an object.
*
* @param {Object} obj
* @return {Boolean}
* @api private
*/
function isObject(obj) {
return obj === Object(obj);
}
/**
* Serialize the given `obj`.
*
* @param {Object} obj
* @return {String}
* @api private
*/
function serialize(obj) {
if (!isObject(obj)) return obj;
var pairs = [];
for (var key in obj) {
if (null != obj[key]) {
pairs.push(encodeURIComponent(key)
+ '=' + encodeURIComponent(obj[key]));
}
}
return pairs.join('&');
}
/**
* Expose serialization method.
*/
request.serializeObject = serialize;
/**
* Parse the given x-www-form-urlencoded `str`.
*
* @param {String} str
* @return {Object}
* @api private
*/
function parseString(str) {
var obj = {};
var pairs = str.split('&');
var parts;
var pair;
for (var i = 0, len = pairs.length; i < len; ++i) {
pair = pairs[i];
parts = pair.split('=');
obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
}
return obj;
}
/**
* Expose parser.
*/
request.parseString = parseString;
/**
* Default MIME type map.
*
* superagent.types.xml = 'application/xml';
*
*/
request.types = {
html: 'text/html',
json: 'application/json',
xml: 'application/xml',
urlencoded: 'application/x-www-form-urlencoded',
'form': 'application/x-www-form-urlencoded',
'form-data': 'application/x-www-form-urlencoded'
};
/**
* Default serialization map.
*
* superagent.serialize['application/xml'] = function(obj){
* return 'generated xml here';
* };
*
*/
request.serialize = {
'application/x-www-form-urlencoded': serialize,
'application/json': JSON.stringify
};
/**
* Default parsers.
*
* superagent.parse['application/xml'] = function(str){
* return { object parsed from str };
* };
*
*/
request.parse = {
'application/x-www-form-urlencoded': parseString,
'application/json': JSON.parse
};
/**
* Parse the given header `str` into
* an object containing the mapped fields.
*
* @param {String} str
* @return {Object}
* @api private
*/
function parseHeader(str) {
var lines = str.split(/\r?\n/);
var fields = {};
var index;
var line;
var field;
var val;
lines.pop(); // trailing CRLF
for (var i = 0, len = lines.length; i < len; ++i) {
line = lines[i];
index = line.indexOf(':');
field = line.slice(0, index).toLowerCase();
val = trim(line.slice(index + 1));
fields[field] = val;
}
return fields;
}
/**
* Return the mime type for the given `str`.
*
* @param {String} str
* @return {String}
* @api private
*/
function type(str){
return str.split(/ *; */).shift();
};
/**
* Return header field parameters.
*
* @param {String} str
* @return {Object}
* @api private
*/
function params(str){
return reduce(str.split(/ *; */), function(obj, str){
var parts = str.split(/ *= */)
, key = parts.shift()
, val = parts.shift();
if (key && val) obj[key] = val;
return obj;
}, {});
};
/**
* Initialize a new `Response` with the given `xhr`.
*
* - set flags (.ok, .error, etc)
* - parse header
*
* Examples:
*
* Aliasing `superagent` as `request` is nice:
*
* request = superagent;
*
* We can use the promise-like API, or pass callbacks:
*
* request.get('/').end(function(res){});
* request.get('/', function(res){});
*
* Sending data can be chained:
*
* request
* .post('/user')
* .send({ name: 'tj' })
* .end(function(res){});
*
* Or passed to `.send()`:
*
* request
* .post('/user')
* .send({ name: 'tj' }, function(res){});
*
* Or passed to `.post()`:
*
* request
* .post('/user', { name: 'tj' })
* .end(function(res){});
*
* Or further reduced to a single call for simple cases:
*
* request
* .post('/user', { name: 'tj' }, function(res){});
*
* @param {XMLHTTPRequest} xhr
* @param {Object} options
* @api private
*/
function Response(req, options) {
options = options || {};
this.req = req;
this.xhr = this.req.xhr;
// responseText is accessible only if responseType is '' or 'text' and on older browsers
this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined')
? this.xhr.responseText
: null;
this.statusText = this.req.xhr.statusText;
this.setStatusProperties(this.xhr.status);
this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());
// getAllResponseHeaders sometimes falsely returns "" for CORS requests, but
// getResponseHeader still works. so we get content-type even if getting
// other headers fails.
this.header['content-type'] = this.xhr.getResponseHeader('content-type');
this.setHeaderProperties(this.header);
this.body = this.req.method != 'HEAD'
? this.parseBody(this.text ? this.text : this.xhr.response)
: null;
}
/**
* Get case-insensitive `field` value.
*
* @param {String} field
* @return {String}
* @api public
*/
Response.prototype.get = function(field){
return this.header[field.toLowerCase()];
};
/**
* Set header related properties:
*
* - `.type` the content type without params
*
* A response of "Content-Type: text/plain; charset=utf-8"
* will provide you with a `.type` of "text/plain".
*
* @param {Object} header
* @api private
*/
Response.prototype.setHeaderProperties = function(header){
// content-type
var ct = this.header['content-type'] || '';
this.type = type(ct);
// params
var obj = params(ct);
for (var key in obj) this[key] = obj[key];
};
/**
* Parse the given body `str`.
*
* Used for auto-parsing of bodies. Parsers
* are defined on the `superagent.parse` object.
*
* @param {String} str
* @return {Mixed}
* @api private
*/
Response.prototype.parseBody = function(str){
var parse = request.parse[this.type];
return parse && str && (str.length || str instanceof Object)
? parse(str)
: null;
};
/**
* Set flags such as `.ok` based on `status`.
*
* For example a 2xx response will give you a `.ok` of __true__
* whereas 5xx will be __false__ and `.error` will be __true__. The
* `.clientError` and `.serverError` are also available to be more
* specific, and `.statusType` is the class of error ranging from 1..5
* sometimes useful for mapping respond colors etc.
*
* "sugar" properties are also defined for common cases. Currently providing:
*
* - .noContent
* - .badRequest
* - .unauthorized
* - .notAcceptable
* - .notFound
*
* @param {Number} status
* @api private
*/
Response.prototype.setStatusProperties = function(status){
// handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request
if (status === 1223) {
status = 204;
}
var type = status / 100 | 0;
// status / class
this.status = status;
this.statusType = type;
// basics
this.info = 1 == type;
this.ok = 2 == type;
this.clientError = 4 == type;
this.serverError = 5 == type;
this.error = (4 == type || 5 == type)
? this.toError()
: false;
// sugar
this.accepted = 202 == status;
this.noContent = 204 == status;
this.badRequest = 400 == status;
this.unauthorized = 401 == status;
this.notAcceptable = 406 == status;
this.notFound = 404 == status;
this.forbidden = 403 == status;
};
/**
* Return an `Error` repre