code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function ucs2encode(array) {
return map(array, function(value) {
var output = '';
if (value > 0xFFFF) {
value -= 0x10000;
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
value = 0xDC00 | value & 0x3FF;
}
output += stringFromCharCode(value);
return output;
}).join('');
} | Creates a string based on an array of numeric code points.
@see `punycode.ucs2.decode`
@memberOf punycode.ucs2
@name encode
@param {Array} codePoints The array of numeric code points.
@returns {String} The new Unicode string (UCS-2). | ucs2encode | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function basicToDigit(codePoint) {
if (codePoint - 48 < 10) {
return codePoint - 22;
}
if (codePoint - 65 < 26) {
return codePoint - 65;
}
if (codePoint - 97 < 26) {
return codePoint - 97;
}
return base;
} | Converts a basic code point into a digit/integer.
@see `digitToBasic()`
@private
@param {Number} codePoint The basic numeric code point value.
@returns {Number} The numeric value of a basic code point (for use in
representing integers) in the range `0` to `base - 1`, or `base` if
the code point does not represent a val... | basicToDigit | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function digitToBasic(digit, flag) {
// 0..25 map to ASCII a..z or A..Z
// 26..35 map to ASCII 0..9
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
} | Converts a digit/integer into a basic code point.
@see `basicToDigit()`
@private
@param {Number} digit The numeric value of a basic code point.
@returns {Number} The basic code point whose value (when used for
representing integers) is `digit`, which needs to be in the range
`0` to `base - 1`. If `flag` is non-zero, th... | digitToBasic | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function adapt(delta, numPoints, firstTime) {
var k = 0;
delta = firstTime ? floor(delta / damp) : delta >> 1;
delta += floor(delta / numPoints);
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
delta = floor(delta / baseMinusTMin);
}
return floor(k + (baseMinusTMin + 1) * de... | Bias adaptation function as per section 3.4 of RFC 3492.
https://tools.ietf.org/html/rfc3492#section-3.4
@private | adapt | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function decode(input) {
// Don't use UCS-2
var output = [],
inputLength = input.length,
out,
i = 0,
n = initialN,
bias = initialBias,
basic,
j,
index,
oldi,
w,
k,
digit,
t,
/** Cached calculation results */
baseMinusT;
// ... | Converts a Punycode string of ASCII-only symbols to a string of Unicode
symbols.
@memberOf punycode
@param {String} input The Punycode string of ASCII-only symbols.
@returns {String} The resulting string of Unicode symbols. | decode | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function encode(input) {
var n,
delta,
handledCPCount,
basicLength,
bias,
j,
m,
q,
k,
t,
currentValue,
output = [],
/** `inputLength` will hold the number of code points in `input`. */
inputLength,
/** Cached calculation results */
... | Converts a string of Unicode symbols (e.g. a domain name label) to a
Punycode string of ASCII-only symbols.
@memberOf punycode
@param {String} input The string of Unicode symbols.
@returns {String} The resulting Punycode string of ASCII-only symbols. | encode | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function toUnicode(input) {
return mapDomain(input, function(string) {
return regexPunycode.test(string)
? decode(string.slice(4).toLowerCase())
: string;
});
} | Converts a Punycode string representing a domain name or an email address
to Unicode. Only the Punycoded parts of the input will be converted, i.e.
it doesn't matter if you call it on a string that has already been
converted to Unicode.
@memberOf punycode
@param {String} input The Punycoded domain name or email address... | toUnicode | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function toASCII(input) {
return mapDomain(input, function(string) {
return regexNonASCII.test(string)
? 'xn--' + encode(string)
: string;
});
} | Converts a Unicode string representing a domain name or an email address to
Punycode. Only the non-ASCII parts of the domain name will be converted,
i.e. it doesn't matter if you call it with a domain that's already in
ASCII.
@memberOf punycode
@param {String} input The domain name or email address to convert, as a
Uni... | toASCII | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function deprecate (fn, msg) {
if (config('noDeprecation')) {
return fn;
}
var warned = false;
function deprecated() {
if (!warned) {
if (config('throwDeprecation')) {
throw new Error(msg);
} else if (config('traceDeprecation')) {
console.trace(msg);
} else {
c... | Mark that a method should not be used.
Returns a modified function which warns once by default.
If `localStorage.noDeprecation = true` is set, then it is a no-op.
If `localStorage.throwDeprecation = true` is set, then deprecated functions
will throw an Error when invoked.
If `localStorage.traceDeprecation = true` is... | deprecate | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function deprecated() {
if (!warned) {
if (config('throwDeprecation')) {
throw new Error(msg);
} else if (config('traceDeprecation')) {
console.trace(msg);
} else {
console.warn(msg);
}
warned = true;
}
return fn.apply(this, arguments);
} | Mark that a method should not be used.
Returns a modified function which warns once by default.
If `localStorage.noDeprecation = true` is set, then it is a no-op.
If `localStorage.throwDeprecation = true` is set, then deprecated functions
will throw an Error when invoked.
If `localStorage.traceDeprecation = true` is... | deprecated | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function config (name) {
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
try {
if (!global.localStorage) return false;
} catch (_) {
return false;
}
var val = global.localStorage[name];
if (null == val) return false;
return String(val).toLowerCase() === 'true';
} | Checks `localStorage` for boolean values for the given `name`.
@param {String} name
@returns {Boolean}
@api private | config | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function parseAuthOptions (opts) {
var matches
if (opts.auth) {
matches = opts.auth.match(/^(.+):(.+)$/)
if (matches) {
opts.username = matches[1]
opts.password = matches[2]
} else {
opts.username = opts.auth
}
}
} | Parse the auth attribute and merge username and password in the options object.
@param {Object} [opts] option object | parseAuthOptions | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function connect (brokerUrl, opts) {
if ((typeof brokerUrl === 'object') && !opts) {
opts = brokerUrl
brokerUrl = null
}
opts = opts || {}
if (brokerUrl) {
opts = xtend(url.parse(brokerUrl, true), opts)
if (opts.protocol === null) {
throw new Error('Missing protocol')
}
opts.prot... | connect - connect to an MQTT broker.
@param {String} [brokerUrl] - url of the broker, optional
@param {Object} opts - see MqttClient#constructor | connect | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function wrapper (client) {
if (opts.servers) {
if (!client._reconnectCount || client._reconnectCount === opts.servers.length) {
client._reconnectCount = 0
}
opts.host = opts.servers[client._reconnectCount].host
opts.port = opts.servers[client._reconnectCount].port
opts.hostna... | connect - connect to an MQTT broker.
@param {String} [brokerUrl] - url of the broker, optional
@param {Object} opts - see MqttClient#constructor | wrapper | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function inspect(obj, opts) {
// default options
var ctx = {
seen: [],
stylize: stylizeNoColor
};
// legacy...
if (arguments.length >= 3) ctx.depth = arguments[2];
if (arguments.length >= 4) ctx.colors = arguments[3];
if (isBoolean(opts)) {
// legacy...
ctx.showHidden = opts;
} else if (... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | inspect | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function stylizeWithColor(str, styleType) {
var style = inspect.styles[styleType];
if (style) {
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
'\u001b[' + inspect.colors[style][1] + 'm';
} else {
return str;
}
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | stylizeWithColor | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function stylizeNoColor(str, styleType) {
return str;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | stylizeNoColor | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function arrayToHash(array) {
var hash = {};
array.forEach(function(val, idx) {
hash[val] = true;
});
return hash;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | arrayToHash | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function formatValue(ctx, value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (ctx.customInspect &&
value &&
isFunction(value.inspect) &&
// Filter out the util module, it's inspect function is special
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatValue | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function formatPrimitive(ctx, value) {
if (isUndefined(value))
return ctx.stylize('undefined', 'undefined');
if (isString(value)) {
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatPrimitive | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function formatError(value) {
return '[' + Error.prototype.toString.call(value) + ']';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatError | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
if (hasOwnProperty(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
output.push('');
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatArray | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
var name, str, desc;
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
if (desc.get) {
if (desc.set) {
str = ctx.stylize('[Getter/Setter]', 'special');
} else {
str = ctx.stylize('[Getter]',... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatProperty | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) numLinesEst++;
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
}, 0);
if (length > 60) {
return braces[0] +
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | reduceToSingleString | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isArray(ar) {
return Array.isArray(ar);
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isArray | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isBoolean(arg) {
return typeof arg === 'boolean';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isBoolean | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isNull(arg) {
return arg === null;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isNull | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isNullOrUndefined(arg) {
return arg == null;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isNullOrUndefined | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isNumber(arg) {
return typeof arg === 'number';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isNumber | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isString(arg) {
return typeof arg === 'string';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isString | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isSymbol(arg) {
return typeof arg === 'symbol';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isSymbol | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isUndefined(arg) {
return arg === void 0;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isUndefined | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isRegExp(re) {
return isObject(re) && objectToString(re) === '[object RegExp]';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isRegExp | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isObject | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isDate(d) {
return isObject(d) && objectToString(d) === '[object Date]';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isDate | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isError(e) {
return isObject(e) &&
(objectToString(e) === '[object Error]' || e instanceof Error);
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isError | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isFunction(arg) {
return typeof arg === 'function';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isFunction | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function isPrimitive(arg) {
return arg === null ||
typeof arg === 'boolean' ||
typeof arg === 'number' ||
typeof arg === 'string' ||
typeof arg === 'symbol' || // ES6 symbol
typeof arg === 'undefined';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isPrimitive | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function objectToString(o) {
return Object.prototype.toString.call(o);
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | objectToString | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function pad(n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | pad | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function timestamp() {
var d = new Date();
var time = [pad(d.getHours()),
pad(d.getMinutes()),
pad(d.getSeconds())].join(':');
return [d.getDate(), months[d.getMonth()], time].join(' ');
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | timestamp | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
} | Inherit the prototype methods from one constructor into another.
The Function.prototype.inherits from lang.js rewritten as a standalone
function (not on Function.prototype). NOTE: If this file is to be loaded
during bootstrapping this function needs to be rewritten using some native
functions as prototype setup using ... | hasOwnProperty | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/mqttClient.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/mqttClient.js | MIT |
function prepareMoveTransition (frags) {
var transition =
transitionEndEvent && // css transition supported?
frags && frags.length && // has frags to be moved?
frags[0].node.__v_trans // has transitions?
if (transition) {
var node = frags[0].node
var moveClass = trans... | Check if move transitions are needed, and if so,
record the bounding client rects for each item.
@param {Array<Fragment>|undefined} frags
@return {Boolean|undefined} | prepareMoveTransition | javascript | vuejs/vue-animated-list | vue-animated-list.js | https://github.com/vuejs/vue-animated-list/blob/master/vue-animated-list.js | MIT |
function applyMoveTransition (frags) {
frags.forEach(function (frag) {
frag._newPos = frag.node.getBoundingClientRect()
})
frags.forEach(function (frag) {
var node = frag.node
var oldPos = frag._oldPos
if (!oldPos) return
if (!frag.moved) {
// transiti... | Apply move transitions.
Calculate new target positions after the move, then apply the
FLIP technique to trigger CSS transforms.
@param {Array<Fragment>} frags | applyMoveTransition | javascript | vuejs/vue-animated-list | vue-animated-list.js | https://github.com/vuejs/vue-animated-list/blob/master/vue-animated-list.js | MIT |
countObjProps = function (obj) {
var k, l = 0;
for (k in obj) {
if (obj.hasOwnProperty(k)) {
l++;
}
}
return l;
} | @name Hyphenator-docLanguages
@description
An object holding all languages used in the document. This is filled by
{@link Hyphenator-gatherDocumentInfos}
@type {Object}
@private | countObjProps | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
createElem = function (tagname, context) {
context = context || contextWindow;
if (document.createElementNS) {
return context.document.createElementNS('http://www.w3.org/1999/xhtml', tagname);
} else if (document.createElement) {
return context.document.createElement(tagname);
}
} | @name Hyphenator-onHyphenationDone
@description
A method to be called, when the last element has been hyphenated or the hyphenation has been
removed from the last element.
@see Hyphenator.config
@type {function()}
@private | createElem | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
onError = function (e) {
window.alert("Hyphenator.js says:\n\nAn Error ocurred:\n" + e.message);
} | @name Hyphenator-selectorFunction
@description
A function that has to return a HTMLNodeList of Elements to be hyphenated.
By default it uses the classname ('hyphenate') to select the elements.
@see Hyphenator.config
@type {function()}
@private | onError | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
selectorFunction = function () {
var tmp, el = [], i, l;
if (document.getElementsByClassName) {
el = contextWindow.document.getElementsByClassName(hyphenateClass);
} else {
tmp = contextWindow.document.getElementsByTagName('*');
l = tmp.length;
for (i = 0; i < l; i++)
{
if (tmp[i].className.ind... | @name Hyphenator-selectorFunction
@description
A function that has to return a HTMLNodeList of Elements to be hyphenated.
By default it uses the classname ('hyphenate') to select the elements.
@see Hyphenator.config
@type {function()}
@private | selectorFunction | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
getLang = function (el, fallback) {
if (!!el.getAttribute('lang')) {
return el.getAttribute('lang').toLowerCase();
}
// The following doesn't work in IE due to a bug when getAttribute('xml:lang') in a table
/*if (!!el.getAttribute('xml:lang')) {
return el.getAttribute('xml:lang').substring(0, 2);
}*/
... | @name Hyphenator-getLang
@description
Gets the language of an element. If no language is set, it may use the {@link Hyphenator-mainLanguage}.
@param {Object} el The first parameter is an DOM-Element-Object
@param {boolean} fallback The second parameter is a boolean to tell if the function should return the {@link Hyphe... | getLang | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
autoSetMainLanguage = function (w) {
w = w || contextWindow;
var el = w.document.getElementsByTagName('html')[0],
m = w.document.getElementsByTagName('meta'),
i, text, e, ul;
mainLanguage = getLang(el, false);
if (!mainLanguage) {
for (i = 0; i < m.length; i++) {
//<meta http-equiv = "content-langu... | @name Hyphenator-autoSetMainLanguage
@description
Retrieves the language of the document from the DOM.
The function looks in the following places:
<ul>
<li>lang-attribute in the html-tag</li>
<li><meta http-equiv = "content-language" content = "xy" /></li>
<li><meta name = "DC.Language" content = "xy" /></l... | autoSetMainLanguage | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
gatherDocumentInfos = function () {
var elToProcess, tmp, i = 0,
process = function (el, hide, lang) {
var n, i = 0, hyphenatorSettings = {};
if (hide && intermediateState === 'hidden') {
if (!!el.getAttribute('style')) {
hyphenatorSettings.hasOwnStyle = true;
} else {
hyphenatorSettings.has... | @name Hyphenator-gatherDocumentInfos
@description
This method runs through the DOM and executes the process()-function on:
- every node returned by the {@link Hyphenator-selectorFunction}.
The process()-function copies the element to the elements-variable, sets its visibility
to intermediateState, retrieves its languag... | gatherDocumentInfos | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
process = function (el, hide, lang) {
var n, i = 0, hyphenatorSettings = {};
if (hide && intermediateState === 'hidden') {
if (!!el.getAttribute('style')) {
hyphenatorSettings.hasOwnStyle = true;
} else {
hyphenatorSettings.hasOwnStyle = false;
}
hyphenatorSettings.isHidden = true;
... | @name Hyphenator-gatherDocumentInfos
@description
This method runs through the DOM and executes the process()-function on:
- every node returned by the {@link Hyphenator-selectorFunction}.
The process()-function copies the element to the elements-variable, sets its visibility
to intermediateState, retrieves its languag... | process | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
convertPatterns = function (lang) {
var plen, anfang, ende, pats, pat, key, tmp = {};
pats = Hyphenator.languages[lang].patterns;
for (plen in pats) {
if (pats.hasOwnProperty(plen)) {
plen = parseInt(plen, 10);
anfang = 0;
ende = plen;
while (!!(pat = pats[plen].substring(anfang, ende))) {
... | @name Hyphenator-convertPatterns
@description
Converts the patterns from string '_a6' to object '_a':'_a6'.
The result is stored in the {@link Hyphenator-patterns}-object.
@private
@param {string} lang the language whose patterns shall be converted | convertPatterns | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
convertExceptionsToObject = function (exc) {
var w = exc.split(', '),
r = {},
i, l, key;
for (i = 0, l = w.length; i < l; i++) {
key = w[i].replace(/-/g, '');
if (!r.hasOwnProperty(key)) {
r[key] = w[i];
}
}
return r;
} | @name Hyphenator-convertExceptionsToObject
@description
Converts a list of comma seprated exceptions to an object:
'Fortran,Hy-phen-a-tion' -> {'Fortran':'Fortran','Hyphenation':'Hy-phen-a-tion'}
@private
@param {string} exc a comma separated string of exceptions (without spaces) | convertExceptionsToObject | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
loadPatterns = function (lang) {
var url, xhr, head, script;
if (supportedLang[lang] && !Hyphenator.languages[lang]) {
url = basePath + 'patterns/' + supportedLang[lang];
} else {
return;
}
if (isLocal && !isBookmarklet) {
//check if 'url' is available:
xhr = null;
if (typeof XMLHttpReque... | @name Hyphenator-loadPatterns
@description
Adds a <script>-Tag to the DOM to load an externeal .js-file containing patterns and settings for the given language.
If the given language is not in the {@link Hyphenator-supportedLang}-Object it returns.
One may ask why we are not using AJAX to load the patterns. The X... | loadPatterns | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
prepareLanguagesObj = function (lang) {
var lo = Hyphenator.languages[lang], wrd;
if (!lo.prepared) {
if (enableCache) {
lo.cache = {};
//Export
lo['cache'] = lo.cache;
}
if (enableReducedPatternSet) {
lo.redPatSet = {};
}
//add exceptions from the pattern file to the local 'exceptio... | @name Hyphenator-prepareLanguagesObj
@description
Adds a cache to each language and converts the exceptions-list to an object.
If storage is active the object is stored there.
@private
@param {string} lang the language ob the lang-obj | prepareLanguagesObj | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
prepare = function (callback) {
var lang, interval, tmp1, tmp2;
if (!enableRemoteLoading) {
for (lang in Hyphenator.languages) {
if (Hyphenator.languages.hasOwnProperty(lang)) {
prepareLanguagesObj(lang);
}
}
state = 2;
callback();
return;
}
// get all languages that are used and pre... | @name Hyphenator-prepare
@description
This funtion prepares the Hyphenator-Object: If RemoteLoading is turned off, it assumes
that the patternfiles are loaded, all conversions are made and the callback is called.
If storage is active the object is retrieved there.
If RemoteLoading is on (default), it loads the pattern ... | prepare | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
toggleBox = function () {
var myBox, bdy, myIdAttribute, myTextNode, myClassAttribute,
text = (Hyphenator.doHyphenation ? 'Hy-phen-a-tion' : 'Hyphenation');
if (!!(myBox = contextWindow.document.getElementById('HyphenatorToggleBox'))) {
myBox.firstChild.data = text;
} else {
bdy = contextWindow.document.g... | @name Hyphenator-switchToggleBox
@description
Creates or hides the toggleBox: a small button to turn off/on hyphenation on a page.
@param {boolean} s true when hyphenation is on, false when it's off
@see Hyphenator.config
@private | toggleBox | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
hyphenateURL = function (url) {
return url.replace(/([:\/\.\?#&_,;!@]+)/gi, '$&' + urlhyphen);
} | @name Hyphenator-removeHyphenationFromElement
@description
Removes all hyphens from the element. If there are other elements, the function is
called recursively.
Removing hyphens is usefull if you like to copy text. Some browsers are buggy when the copy hyphenated texts.
@param {Object} el The element where to remove h... | hyphenateURL | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
removeHyphenationFromElement = function (el) {
var h, i = 0, n;
switch (hyphen) {
case '|':
h = '\\|';
break;
case '+':
h = '\\+';
break;
case '*':
h = '\\*';
break;
default:
h = hyphen;
}
while (!!(n = el.childNodes[i++])) {
if (n.nodeType === 3) {
n.data = n.data.replace(ne... | @name Hyphenator-removeHyphenationFromElement
@description
Removes all hyphens from the element. If there are other elements, the function is
called recursively.
Removing hyphens is usefull if you like to copy text. Some browsers are buggy when the copy hyphenated texts.
@param {Object} el The element where to remove h... | removeHyphenationFromElement | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
hyphenateElement = function (el) {
var hyphenatorSettings = Expando.getDataForElem(el),
lang = hyphenatorSettings.language, hyphenate, n, i,
controlOrphans = function (part) {
var h, r;
switch (hyphen) {
case '|':
h = '\\|';
break;
case '+':
h = '\\+';
break;
case '*':
... | @name Hyphenator-hyphenateElement
@description
Takes the content of the given element and - if there's text - replaces the words
by hyphenated words. If there's another element, the function is called recursively.
When all words are hyphenated, the visibility of the element is set to 'visible'.
@param {Object} el The e... | hyphenateElement | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
controlOrphans = function (part) {
var h, r;
switch (hyphen) {
case '|':
h = '\\|';
break;
case '+':
h = '\\+';
break;
case '*':
h = '\\*';
break;
default:
h = hyphen;
}
if (orphanControl >= 2) {
//remove hyphen points from last word
r = part.... | @name Hyphenator-hyphenateElement
@description
Takes the content of the given element and - if there's text - replaces the words
by hyphenated words. If there's another element, the function is called recursively.
When all words are hyphenated, the visibility of the element is set to 'visible'.
@param {Object} el The e... | controlOrphans | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
hyphenateDocument = function () {
function bind(fun, arg) {
return function () {
return fun(arg);
};
}
var i = 0, el;
while (!!(el = elements[i++])) {
if (el.ownerDocument.location.href === contextWindow.location.href) {
window.setTimeout(bind(hyphenateElement, el), 0);
}
}
} | @name Hyphenator-removeHyphenationFromDocument
@description
Does what it says ;-)
@private | hyphenateDocument | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
function bind(fun, arg) {
return function () {
return fun(arg);
};
} | @name Hyphenator-removeHyphenationFromDocument
@description
Does what it says ;-)
@private | bind | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
removeHyphenationFromDocument = function () {
var i = 0, el;
while (!!(el = elements[i++])) {
removeHyphenationFromElement(el);
}
state = 4;
} | @name Hyphenator-createStorage
@description
inits the private var storage depending of the setting in storageType
and the supported features of the system.
@private | removeHyphenationFromDocument | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
createStorage = function () {
try {
if (storageType !== 'none' &&
typeof(window.localStorage) !== 'undefined' &&
typeof(window.sessionStorage) !== 'undefined' &&
typeof(window.JSON.stringify) !== 'undefined' &&
typeof(window.JSON.parse) !== 'undefined') {
switch (storageType) {
case 'sessio... | @name Hyphenator-createStorage
@description
inits the private var storage depending of the setting in storageType
and the supported features of the system.
@private | createStorage | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
storeConfiguration = function () {
if (!storage) {
return;
}
var settings = {
'STORED': true,
'classname': hyphenateClass,
'donthyphenateclassname': dontHyphenateClass,
'minwordlength': min,
'hyphenchar': hyphen,
'urlhyphenchar': urlhyphen,
'togglebox': toggleBox,
'displaytogglebox': di... | @name Hyphenator-storeConfiguration
@description
Stores the current config-options in DOM-Storage
@private | storeConfiguration | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
restoreConfiguration = function () {
var settings;
if (storage.getItem('Hyphenator_config')) {
settings = window.JSON.parse(storage.getItem('Hyphenator_config'));
Hyphenator.config(settings);
}
} | @name Hyphenator.version
@memberOf Hyphenator
@description
String containing the actual version of Hyphenator.js
[major release].[minor releas].[bugfix release]
major release: new API, new Features, big changes
minor release: new languages, improvements
@public | restoreConfiguration | javascript | cmod/bibliotype | js/Hyphenator.js | https://github.com/cmod/bibliotype/blob/master/js/Hyphenator.js | MIT |
function createMeterValue(value): UnitValue {
return {
unit: 'm',
value,
};
} | The `type` keyword indicates that this is a
flow specific declaration. These declarations
are not part of the distributed code! | createMeterValue | javascript | ryyppy/flow-guide | tutorial/00-basics/05-recap.js | https://github.com/ryyppy/flow-guide/blob/master/tutorial/00-basics/05-recap.js | MIT |
function guessParamType(value): UnitValue {
return {
unit: 'km',
value,
};
} | The `type` keyword indicates that this is a
flow specific declaration. These declarations
are not part of the distributed code! | guessParamType | javascript | ryyppy/flow-guide | tutorial/00-basics/05-recap.js | https://github.com/ryyppy/flow-guide/blob/master/tutorial/00-basics/05-recap.js | MIT |
renderData = () => {
switch (showAs) {
case 'list': return this._renderList(data);
case 'grid': return this._renderGrid(data);
default: return null;
}
} | We define the structure of our props,
which will usually be done during runtime
via React.PropTypes | renderData | javascript | ryyppy/flow-guide | tutorial/01-react/00-intro.js | https://github.com/ryyppy/flow-guide/blob/master/tutorial/01-react/00-intro.js | MIT |
renderData = () => {
switch (showAs) {
case 'list': return this._renderList(data);
case 'grid': return this._renderGrid(data);
default: return null;
}
} | We define the structure of our props,
which will usually be done during runtime
via React.PropTypes | renderData | javascript | ryyppy/flow-guide | tutorial/01-react/00-intro.js | https://github.com/ryyppy/flow-guide/blob/master/tutorial/01-react/00-intro.js | MIT |
if (!isLoading) {
return null;
} | We define the structure of our props,
which will usually be done during runtime
via React.PropTypes | if | javascript | ryyppy/flow-guide | tutorial/01-react/00-intro.js | https://github.com/ryyppy/flow-guide/blob/master/tutorial/01-react/00-intro.js | MIT |
function waitFor(testFx, onReady, timeOutMillis) {
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 10001, //< Default Max Timout is 3s
start = new Date().getTime(),
condition = false,
interval = setInterval(function() {
if ( (new Date().getTime() - start < maxtimeOutMillis... | Wait until the test condition is true or a timeout occurs. Useful for waiting
on a server response or for a ui change (fadeIn, etc.) to occur.
@param testFx javascript condition that evaluates to a boolean,
it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
as a callback function.
@param ... | waitFor | javascript | smalot/bootstrap-datetimepicker | tests/run-qunit.js | https://github.com/smalot/bootstrap-datetimepicker/blob/master/tests/run-qunit.js | Apache-2.0 |
function readFileLines(filename) {
var stream = fs.open(filename, 'r');
var lines = [];
var line;
while (!stream.atEnd()) {
lines.push(stream.readLine());
}
stream.close();
return lines;
} | Wait until the test condition is true or a timeout occurs. Useful for waiting
on a server response or for a ui change (fadeIn, etc.) to occur.
@param testFx javascript condition that evaluates to a boolean,
it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
as a callback function.
@param ... | readFileLines | javascript | smalot/bootstrap-datetimepicker | tests/run-qunit.js | https://github.com/smalot/bootstrap-datetimepicker/blob/master/tests/run-qunit.js | Apache-2.0 |
performAction({ innerAccess, method, url, query, params, headers, body }) {
this.app.meta.util.deprecated('ctx.performAction', 'ctx.meta.util.performAction');
return this.meta.util.performAction({ innerAccess, method, url, query, params, headers, body });
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | performAction | javascript | cabloy/cabloy | packages/egg-born-backend/app/extend/context.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/app/extend/context.js | MIT |
getVal(name) {
return (
(this.params && this.params[name]) ||
(this.query && this.query[name]) ||
(this.request.body && this.request.body[name])
);
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | getVal | javascript | cabloy/cabloy | packages/egg-born-backend/app/extend/context.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/app/extend/context.js | MIT |
getInt(name) {
return parseInt(this.getVal(name));
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | getInt | javascript | cabloy/cabloy | packages/egg-born-backend/app/extend/context.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/app/extend/context.js | MIT |
getFloat(name) {
return parseFloat(this.getVal(name));
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | getFloat | javascript | cabloy/cabloy | packages/egg-born-backend/app/extend/context.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/app/extend/context.js | MIT |
getStr(name) {
const v = this.getVal(name);
return (v && v.toString()) || '';
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | getStr | javascript | cabloy/cabloy | packages/egg-born-backend/app/extend/context.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/app/extend/context.js | MIT |
getSafeStr(name) {
const v = this.getStr(name);
return v.replace(/'/gi, "''");
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | getSafeStr | javascript | cabloy/cabloy | packages/egg-born-backend/app/extend/context.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/app/extend/context.js | MIT |
successMore(list, index, size) {
this.success({ list, index: index + list.length, finished: size === -1 || size === 0 || list.length < size });
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | successMore | javascript | cabloy/cabloy | packages/egg-born-backend/app/extend/context.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/app/extend/context.js | MIT |
async getPayload(options) {
return await raw(inflate(this.req), options);
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | getPayload | javascript | cabloy/cabloy | packages/egg-born-backend/app/extend/context.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/app/extend/context.js | MIT |
function getText(locale, ...args) {
const key = args[0];
if (!key) return null;
// try locale
let resource = ebLocales[locale] || {};
let text = resource[key];
if (text === undefined && locale !== 'en-us') {
// try en-us
resource = ebLocales['en-us'] || {};
text = resource[key... | based on koa-locales
https://github.com/koajs/locales/blob/master/index.js | getText | javascript | cabloy/cabloy | packages/egg-born-backend/lib/module/locales.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/module/locales.js | MIT |
function formatLocale(locale) {
// support zh_CN, en_US => zh-CN, en-US
return locale.replace('_', '-').toLowerCase();
} | based on koa-locales
https://github.com/koajs/locales/blob/master/index.js | formatLocale | javascript | cabloy/cabloy | packages/egg-born-backend/lib/module/locales.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/module/locales.js | MIT |
get() {
return ctxCaller.locale;
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | get | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/performAction.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/performAction.js | MIT |
get() {
return ctxCaller.subdomain;
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | get | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/performAction.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/performAction.js | MIT |
function delegateHeaders(ctx, ctxCaller, headers) {
if (ctxCaller && ctxCaller.headers) {
Object.assign(ctx.headers, ctxCaller.headers);
}
if (headers) {
Object.assign(ctx.headers, headers);
}
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | delegateHeaders | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/performAction.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/performAction.js | MIT |
function delegateCookies(ctx, ctxCaller) {
const _cookies = ctx.cookies;
Object.defineProperty(ctx, 'cookies', {
get() {
return ctxCaller.cookies || _cookies;
},
});
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | delegateCookies | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/performAction.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/performAction.js | MIT |
get() {
return ctxCaller.cookies || _cookies;
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | get | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/performAction.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/performAction.js | MIT |
function delegateProperty(ctx, ctxCaller, property) {
Object.defineProperty(ctx, property, {
get() {
return ctxCaller[property];
},
});
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | delegateProperty | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/performAction.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/performAction.js | MIT |
get() {
return ctxCaller[property];
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | get | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/performAction.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/performAction.js | MIT |
function createRequest({ method, url }, ctxCaller) {
// _req
const _req = ctxCaller.request;
// req
const req = new http.IncomingMessage();
req.headers = _req.headers;
req.host = _req.host;
req.hostname = _req.hostname;
req.protocol = _req.protocol;
req.secure = _req.secure;
req.method = method.toUp... | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | createRequest | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/performAction.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/performAction.js | MIT |
async performAction({ innerAccess, method, url, query, params, headers, body }) {
return await performActionFn({
ctxCaller: ctx,
innerAccess,
method,
url,
query,
params,
headers,
body,
});
} | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | performAction | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/utilCtx.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/utilCtx.js | MIT |
getDbOriginal() {
const dbLevel = ctx.dbLevel;
const mysqlConfig = ctx.app.mysql.__ebdb_test;
if (!mysqlConfig) return ctx.app.mysql.get('__ebdb');
let dbs = ctx.app.mysql.__ebdb_test_dbs;
if (!dbs) {
dbs = ctx.app.mysql.__ebdb_test_dbs = [];
}
if (!dbs[dbLevel]) {
... | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | getDbOriginal | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/utilCtx.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/utilCtx.js | MIT |
createDatabase() {
const db = this.getDbOriginal();
return new Proxy(db, {
get(target, prop) {
const value = target[prop];
if (!is.function(value)) return value;
// if (value.name !== 'createPromise') return value;
// check if use transaction
if (!ct... | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | createDatabase | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/utilCtx.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/utilCtx.js | MIT |
get(target, prop) {
const value = target[prop];
if (!is.function(value)) return value;
// if (value.name !== 'createPromise') return value;
// check if use transaction
if (!ctx.dbMeta.transaction.inTransaction) return value;
return function (...args) {
... | perform action of this or that module
@param {string} options options
@param {string} options.method method
@param {string} options.url url
@param {json} options.body body(optional)
@return {promise} response.body.data or throw error | get | javascript | cabloy/cabloy | packages/egg-born-backend/lib/utils/utilCtx.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-backend/lib/utils/utilCtx.js | MIT |
description() {
return 'backend cov';
} | /dist/backend.js'];
// check dev server
const devServerRunning = yield utils.checkIfDevServerRunning({
warnWhenRunning: true,
});
if (devServerRunning) return;
yield super.run(context);
}
formatTestArgs({ argv, debugOptions }) {
const testArgv = Object.assign({}, argv);
/* istanbu... | description | javascript | cabloy/cabloy | packages/egg-born-bin/lib/cmd/backend-cov.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-bin/lib/cmd/backend-cov.js | MIT |
*curl(url, options) {
return yield this.httpClient.request(url, options);
} | send curl to remote server
@param {String} url - target url
@param {Object} [options] - request options
@return {Object} response data | curl | javascript | cabloy/cabloy | packages/egg-born-bin/lib/cmd/test-update.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-bin/lib/cmd/test-update.js | MIT |
*getPackageInfo(pkgName, withFallback) {
this.log(`fetching npm info of ${pkgName}`);
try {
const result = yield this.curl(`${this.registryUrl}/${pkgName}/latest`, {
dataType: 'json',
followRedirect: true,
maxRedirects: 5,
timeout: 20000,
});
assert(result.statu... | get package info from registry
@param {String} pkgName - package name
@param {Boolean} [withFallback] - when http request fail, whethe to require local
@return {Object} pkgInfo | getPackageInfo | javascript | cabloy/cabloy | packages/egg-born-bin/lib/cmd/test-update.js | https://github.com/cabloy/cabloy/blob/master/packages/egg-born-bin/lib/cmd/test-update.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.