reflux-core
Version:
A simple library for uni-directional dataflow application architecture inspired by ReactJS Flux
84 lines (72 loc) • 2.38 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.capitalize = capitalize;
exports.callbackName = callbackName;
exports.isObject = isObject;
exports.extend = extend;
exports.isFunction = isFunction;
exports.nextTick = nextTick;
exports.object = object;
exports.isArguments = isArguments;
exports.throwIf = throwIf;
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function callbackName(string, prefix) {
prefix = prefix || "on";
return prefix + exports.capitalize(string);
}
/*
* isObject, extend, isFunction, isArguments are taken from underscore/lodash in
* order to remove the dependency
*/
function isObject(obj) {
var type = typeof obj === "undefined" ? "undefined" : _typeof(obj);
return type === "function" || type === "object" && !!obj;
}
function extend(obj) {
if (!isObject(obj)) {
return obj;
}
var source, keys, prop;
for (var i = 1, length = arguments.length; i < length; i++) {
source = arguments[i];
keys = Object.keys(source);
for (var j = 0; j < keys.length; j++) {
prop = keys[j];
if (Object.getOwnPropertyDescriptor && Object.defineProperty) {
var propertyDescriptor = Object.getOwnPropertyDescriptor(source, prop);
Object.defineProperty(obj, prop, propertyDescriptor);
} else {
obj[prop] = source[prop];
}
}
}
return obj;
}
function isFunction(value) {
return typeof value === "function";
}
exports.EventEmitter = require("eventemitter3");
function nextTick(callback) {
setTimeout(callback, 0);
}
function object(keys, vals) {
var o = {},
i = 0;
for (; i < keys.length; i++) {
o[keys[i]] = vals[i];
}
return o;
}
function isArguments(value) {
return (typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && "callee" in value && typeof value.length === "number";
}
function throwIf(val, msg) {
if (val) {
throw Error(msg || val);
}
}
;