_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
|---|---|---|---|---|---|
q59300
|
RSASetPublic
|
validation
|
function RSASetPublic(N,E) {
if(N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N,16);
this.e = parseInt(E,16);
}
else
alert("Invalid RSA public key");
}
|
javascript
|
{
"resource": ""
}
|
q59301
|
RSASetPrivate
|
validation
|
function RSASetPrivate(N,E,D) {
if(N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N,16);
this.e = parseInt(E,16);
this.d = parseBigInt(D,16);
}
else
alert("Invalid RSA private key");
}
|
javascript
|
{
"resource": ""
}
|
q59302
|
supportedLocalesOf
|
validation
|
function supportedLocalesOf(service, locales, options) {
if (IS_NULL(InternalRegExpMatch(GetServiceRE(), service))) {
throw MakeError(kWrongServiceType, service);
}
// Provide defaults if matcher was not specified.
if (IS_UNDEFINED(options)) {
options = {};
} else {
options = TO_OBJECT(options);
}
var matcher = options.localeMatcher;
if (!IS_UNDEFINED(matcher)) {
matcher = TO_STRING(matcher);
if (matcher !== 'lookup' && matcher !== 'best fit') {
throw MakeRangeError(kLocaleMatcher, matcher);
}
} else {
matcher = 'best fit';
}
var requestedLocales = initializeLocaleList(locales);
// Cache these, they don't ever change per service.
if (IS_UNDEFINED(AVAILABLE_LOCALES[service])) {
AVAILABLE_LOCALES[service] = getAvailableLocalesOf(service);
}
// Use either best fit or lookup algorithm to match locales.
if (matcher === 'best fit') {
return initializeLocaleList(bestFitSupportedLocalesOf(
requestedLocales, AVAILABLE_LOCALES[service]));
}
return initializeLocaleList(lookupSupportedLocalesOf(
requestedLocales, AVAILABLE_LOCALES[service]));
}
|
javascript
|
{
"resource": ""
}
|
q59303
|
addWEPropertyIfDefined
|
validation
|
function addWEPropertyIfDefined(object, property, value) {
if (!IS_UNDEFINED(value)) {
defineWEProperty(object, property, value);
}
}
|
javascript
|
{
"resource": ""
}
|
q59304
|
addWECPropertyIfDefined
|
validation
|
function addWECPropertyIfDefined(object, property, value) {
if (!IS_UNDEFINED(value)) {
defineWECProperty(object, property, value);
}
}
|
javascript
|
{
"resource": ""
}
|
q59305
|
toLDMLString
|
validation
|
function toLDMLString(options) {
var getOption = getGetOption(options, 'dateformat');
var ldmlString = '';
var option = getOption('weekday', 'string', ['narrow', 'short', 'long']);
ldmlString += appendToLDMLString(
option, {narrow: 'EEEEE', short: 'EEE', long: 'EEEE'});
option = getOption('era', 'string', ['narrow', 'short', 'long']);
ldmlString += appendToLDMLString(
option, {narrow: 'GGGGG', short: 'GGG', long: 'GGGG'});
option = getOption('year', 'string', ['2-digit', 'numeric']);
ldmlString += appendToLDMLString(option, {'2-digit': 'yy', 'numeric': 'y'});
option = getOption('month', 'string',
['2-digit', 'numeric', 'narrow', 'short', 'long']);
ldmlString += appendToLDMLString(option, {'2-digit': 'MM', 'numeric': 'M',
'narrow': 'MMMMM', 'short': 'MMM', 'long': 'MMMM'});
option = getOption('day', 'string', ['2-digit', 'numeric']);
ldmlString += appendToLDMLString(
option, {'2-digit': 'dd', 'numeric': 'd'});
var hr12 = getOption('hour12', 'boolean');
option = getOption('hour', 'string', ['2-digit', 'numeric']);
if (IS_UNDEFINED(hr12)) {
ldmlString += appendToLDMLString(option, {'2-digit': 'jj', 'numeric': 'j'});
} else if (hr12 === true) {
ldmlString += appendToLDMLString(option, {'2-digit': 'hh', 'numeric': 'h'});
} else {
ldmlString += appendToLDMLString(option, {'2-digit': 'HH', 'numeric': 'H'});
}
option = getOption('minute', 'string', ['2-digit', 'numeric']);
ldmlString += appendToLDMLString(option, {'2-digit': 'mm', 'numeric': 'm'});
option = getOption('second', 'string', ['2-digit', 'numeric']);
ldmlString += appendToLDMLString(option, {'2-digit': 'ss', 'numeric': 's'});
option = getOption('timeZoneName', 'string', ['short', 'long']);
ldmlString += appendToLDMLString(option, {short: 'z', long: 'zzzz'});
return ldmlString;
}
|
javascript
|
{
"resource": ""
}
|
q59306
|
fromLDMLString
|
validation
|
function fromLDMLString(ldmlString) {
// First remove '' quoted text, so we lose 'Uhr' strings.
ldmlString = InternalRegExpReplace(GetQuotedStringRE(), ldmlString, '');
var options = {};
var match = InternalRegExpMatch(/E{3,5}/, ldmlString);
options = appendToDateTimeObject(
options, 'weekday', match, {EEEEE: 'narrow', EEE: 'short', EEEE: 'long'});
match = InternalRegExpMatch(/G{3,5}/, ldmlString);
options = appendToDateTimeObject(
options, 'era', match, {GGGGG: 'narrow', GGG: 'short', GGGG: 'long'});
match = InternalRegExpMatch(/y{1,2}/, ldmlString);
options = appendToDateTimeObject(
options, 'year', match, {y: 'numeric', yy: '2-digit'});
match = InternalRegExpMatch(/M{1,5}/, ldmlString);
options = appendToDateTimeObject(options, 'month', match, {MM: '2-digit',
M: 'numeric', MMMMM: 'narrow', MMM: 'short', MMMM: 'long'});
// Sometimes we get L instead of M for month - standalone name.
match = InternalRegExpMatch(/L{1,5}/, ldmlString);
options = appendToDateTimeObject(options, 'month', match, {LL: '2-digit',
L: 'numeric', LLLLL: 'narrow', LLL: 'short', LLLL: 'long'});
match = InternalRegExpMatch(/d{1,2}/, ldmlString);
options = appendToDateTimeObject(
options, 'day', match, {d: 'numeric', dd: '2-digit'});
match = InternalRegExpMatch(/h{1,2}/, ldmlString);
if (match !== null) {
options['hour12'] = true;
}
options = appendToDateTimeObject(
options, 'hour', match, {h: 'numeric', hh: '2-digit'});
match = InternalRegExpMatch(/H{1,2}/, ldmlString);
if (match !== null) {
options['hour12'] = false;
}
options = appendToDateTimeObject(
options, 'hour', match, {H: 'numeric', HH: '2-digit'});
match = InternalRegExpMatch(/m{1,2}/, ldmlString);
options = appendToDateTimeObject(
options, 'minute', match, {m: 'numeric', mm: '2-digit'});
match = InternalRegExpMatch(/s{1,2}/, ldmlString);
options = appendToDateTimeObject(
options, 'second', match, {s: 'numeric', ss: '2-digit'});
match = InternalRegExpMatch(/z|zzzz/, ldmlString);
options = appendToDateTimeObject(
options, 'timeZoneName', match, {z: 'short', zzzz: 'long'});
return options;
}
|
javascript
|
{
"resource": ""
}
|
q59307
|
toLocaleDateTime
|
validation
|
function toLocaleDateTime(date, locales, options, required, defaults, service) {
if (!(date instanceof GlobalDate)) {
throw MakeTypeError(kMethodInvokedOnWrongType, "Date");
}
if (IsNaN(date)) return 'Invalid Date';
var internalOptions = toDateTimeOptions(options, required, defaults);
var dateFormat =
cachedOrNewService(service, locales, options, internalOptions);
return formatDate(dateFormat, date);
}
|
javascript
|
{
"resource": ""
}
|
q59308
|
locateAcpiDevice
|
validation
|
function locateAcpiDevice(dev) {
if (!dev.isDevice()) {
return null;
}
const addr = dev.address();
const slotId = ((addr >>> 16) & 0xffff) >>> 0;
const funcId = (addr & 0xffff) >>> 0;
let busId = 0;
if (dev.isRootBridge()) {
busId = dev.getRootBridgeBusNumber();
return {
bus: busId,
slot: slotId,
func: funcId,
};
}
const parentDev = dev.parent();
if (parentDev === null) {
return null;
}
if (!parentDev.isDevice()) {
return null;
}
if (parentDev.isRootBridge()) {
busId = parentDev.getRootBridgeBusNumber();
return {
bus: busId,
slot: slotId,
func: funcId,
};
}
const parentLocation = locateAcpiDevice(parentDev);
if (parentLocation === null) {
return null;
}
const pciParent = pciAccessorFactory.get({
bus: parentLocation.bus,
slot: parentLocation.slot,
func: parentLocation.func,
});
const header = pciParent.read(pciParent.fields().HEADER_TYPE);
// Mask multifunction bit
const headerType = (header & 0x7f) >>> 0;
if (headerType !== 0x01 && headerType !== 0x02) {
return null;
}
const bridgeBus = pciParent.read(pciParent.bridgeFields().SECONDARY_BUS);
return {
bus: bridgeBus,
slot: slotId,
func: funcId,
};
}
|
javascript
|
{
"resource": ""
}
|
q59309
|
BinaryConstraint
|
validation
|
function BinaryConstraint(var1, var2, strength) {
BinaryConstraint.superConstructor.call(this, strength);
this.v1 = var1;
this.v2 = var2;
this.direction = Direction.NONE;
this.addConstraint();
}
|
javascript
|
{
"resource": ""
}
|
q59310
|
sc_isVectorEqual
|
validation
|
function sc_isVectorEqual(v1, v2, comp) {
if (v1.length !== v2.length) return false;
for (var i = 0; i < v1.length; i++)
if (!comp(v1[i], v2[i])) return false;
return true;
}
|
javascript
|
{
"resource": ""
}
|
q59311
|
ArrayPush
|
validation
|
function ArrayPush() {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.push");
var array = TO_OBJECT(this);
var n = TO_LENGTH(array.length);
var m = arguments.length;
// Subtract n from kMaxSafeInteger rather than testing m + n >
// kMaxSafeInteger. n may already be kMaxSafeInteger. In that case adding
// e.g., 1 would not be safe.
if (m > kMaxSafeInteger - n) throw MakeTypeError(kPushPastSafeLength, m, n);
for (var i = 0; i < m; i++) {
array[i+n] = arguments[i];
}
var new_length = n + m;
array.length = new_length;
return new_length;
}
|
javascript
|
{
"resource": ""
}
|
q59312
|
ArraySome
|
validation
|
function ArraySome(f, receiver) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some");
// Pull out the length so that modifications to the length in the
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
var length = TO_LENGTH(array.length);
return InnerArraySome(f, receiver, array, length);
}
|
javascript
|
{
"resource": ""
}
|
q59313
|
ArrayCopyWithin
|
validation
|
function ArrayCopyWithin(target, start, end) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin");
var array = TO_OBJECT(this);
var length = TO_LENGTH(array.length);
return InnerArrayCopyWithin(target, start, end, array, length);
}
|
javascript
|
{
"resource": ""
}
|
q59314
|
ArrayFind
|
validation
|
function ArrayFind(predicate, thisArg) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find");
var array = TO_OBJECT(this);
var length = TO_INTEGER(array.length);
return InnerArrayFind(predicate, thisArg, array, length);
}
|
javascript
|
{
"resource": ""
}
|
q59315
|
ArrayFindIndex
|
validation
|
function ArrayFindIndex(predicate, thisArg) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.findIndex");
var array = TO_OBJECT(this);
var length = TO_INTEGER(array.length);
return InnerArrayFindIndex(predicate, thisArg, array, length);
}
|
javascript
|
{
"resource": ""
}
|
q59316
|
ArrayIncludes
|
validation
|
function ArrayIncludes(searchElement, fromIndex) {
CHECK_OBJECT_COERCIBLE(this, "Array.prototype.includes");
var array = TO_OBJECT(this);
var length = TO_LENGTH(array.length);
return InnerArrayIncludes(searchElement, fromIndex, array, length);
}
|
javascript
|
{
"resource": ""
}
|
q59317
|
GetMethod
|
validation
|
function GetMethod(obj, p) {
var func = obj[p];
if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
if (IS_CALLABLE(func)) return func;
throw MakeTypeError(kCalledNonCallable, typeof func);
}
|
javascript
|
{
"resource": ""
}
|
q59318
|
CreateStringIterator
|
validation
|
function CreateStringIterator(string) {
CHECK_OBJECT_COERCIBLE(string, 'String.prototype[Symbol.iterator]');
var s = TO_STRING(string);
var iterator = new StringIterator;
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, s);
SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, 0);
return iterator;
}
|
javascript
|
{
"resource": ""
}
|
q59319
|
MakeMirror
|
validation
|
function MakeMirror(value, opt_transient) {
var mirror;
// Look for non transient mirrors in the mirror cache.
if (!opt_transient && mirror_cache_enabled_) {
for (var id in mirror_cache_) {
mirror = mirror_cache_[id];
if (mirror.value() === value) {
return mirror;
}
// Special check for NaN as NaN == NaN is false.
if (mirror.isNumber() && IsNaN(mirror.value()) &&
typeof value == 'number' && IsNaN(value)) {
return mirror;
}
}
}
if (IS_UNDEFINED(value)) {
mirror = new UndefinedMirror();
} else if (IS_NULL(value)) {
mirror = new NullMirror();
} else if (IS_BOOLEAN(value)) {
mirror = new BooleanMirror(value);
} else if (IS_NUMBER(value)) {
mirror = new NumberMirror(value);
} else if (IS_STRING(value)) {
mirror = new StringMirror(value);
} else if (IS_SYMBOL(value)) {
mirror = new SymbolMirror(value);
} else if (IS_ARRAY(value)) {
mirror = new ArrayMirror(value);
} else if (IS_DATE(value)) {
mirror = new DateMirror(value);
} else if (IS_FUNCTION(value)) {
mirror = new FunctionMirror(value);
} else if (IS_REGEXP(value)) {
mirror = new RegExpMirror(value);
} else if (IS_ERROR(value)) {
mirror = new ErrorMirror(value);
} else if (IS_SCRIPT(value)) {
mirror = new ScriptMirror(value);
} else if (IS_MAP(value) || IS_WEAKMAP(value)) {
mirror = new MapMirror(value);
} else if (IS_SET(value) || IS_WEAKSET(value)) {
mirror = new SetMirror(value);
} else if (IS_MAP_ITERATOR(value) || IS_SET_ITERATOR(value)) {
mirror = new IteratorMirror(value);
} else if (ObjectIsPromise(value)) {
mirror = new PromiseMirror(value);
} else if (IS_GENERATOR(value)) {
mirror = new GeneratorMirror(value);
} else {
mirror = new ObjectMirror(value, MirrorType.OBJECT_TYPE, opt_transient);
}
if (mirror_cache_enabled_) mirror_cache_[mirror.handle()] = mirror;
return mirror;
}
|
javascript
|
{
"resource": ""
}
|
q59320
|
StringConcat
|
validation
|
function StringConcat(other /* and more */) { // length == 1
"use strict";
CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat");
var s = TO_STRING(this);
var len = arguments.length;
for (var i = 0; i < len; ++i) {
s = s + TO_STRING(arguments[i]);
}
return s;
}
|
javascript
|
{
"resource": ""
}
|
q59321
|
PromiseSet
|
validation
|
function PromiseSet(promise, status, value) {
SET_PRIVATE(promise, promiseStateSymbol, status);
SET_PRIVATE(promise, promiseResultSymbol, value);
// There are 3 possible states for the resolve, reject symbols when we add
// a new callback --
// 1) UNDEFINED -- This is the zero state where there is no callback
// registered. When we see this state, we directly attach the callbacks to
// the symbol.
// 2) !IS_ARRAY -- There is a single callback directly attached to the
// symbols. We need to create a new array to store additional callbacks.
// 3) IS_ARRAY -- There are multiple callbacks already registered,
// therefore we can just push the new callback to the existing array.
SET_PRIVATE(promise, promiseFulfillReactionsSymbol, UNDEFINED);
SET_PRIVATE(promise, promiseRejectReactionsSymbol, UNDEFINED);
// There are 2 possible states for this symbol --
// 1) UNDEFINED -- This is the zero state, no deferred object is
// attached to this symbol. When we want to add a new deferred we
// directly attach it to this symbol.
// 2) symbol with attached deferred object -- New deferred objects
// are not attached to this symbol, but instead they are directly
// attached to the resolve, reject callback arrays. At this point,
// the deferred symbol's state is stale, and the deferreds should be
// read from the reject, resolve callbacks.
SET_PRIVATE(promise, promiseDeferredReactionsSymbol, UNDEFINED);
return promise;
}
|
javascript
|
{
"resource": ""
}
|
q59322
|
PromiseHasUserDefinedRejectHandlerCheck
|
validation
|
function PromiseHasUserDefinedRejectHandlerCheck(handler, deferred) {
if (handler !== PromiseIdRejectHandler) {
var combinedDeferred = GET_PRIVATE(handler, promiseCombinedDeferredSymbol);
if (IS_UNDEFINED(combinedDeferred)) return true;
if (PromiseHasUserDefinedRejectHandlerRecursive(combinedDeferred.promise)) {
return true;
}
} else if (PromiseHasUserDefinedRejectHandlerRecursive(deferred.promise)) {
return true;
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
q59323
|
CollectNew
|
validation
|
function CollectNew(node_list) {
for (var i = 0; i < node_list.length; i++) {
link_to_original_script_list.push(node_list[i]);
CollectNew(node_list[i].children);
}
}
|
javascript
|
{
"resource": ""
}
|
q59324
|
TemporaryRemoveBreakPoints
|
validation
|
function TemporaryRemoveBreakPoints(original_script, change_log) {
var script_break_points = GetScriptBreakPoints(original_script);
var break_points_update_report = [];
change_log.push( { break_points_update: break_points_update_report } );
var break_point_old_positions = [];
for (var i = 0; i < script_break_points.length; i++) {
var break_point = script_break_points[i];
break_point.clear();
// TODO(LiveEdit): be careful with resource offset here.
var break_point_position = FindScriptSourcePosition(original_script,
break_point.line(), break_point.column());
var old_position_description = {
position: break_point_position,
line: break_point.line(),
column: break_point.column()
};
break_point_old_positions.push(old_position_description);
}
// Restores breakpoints and creates their copies in the "old" copy of
// the script.
return function (pos_translator, old_script_copy_opt) {
// Update breakpoints (change positions and restore them in old version
// of script.
for (var i = 0; i < script_break_points.length; i++) {
var break_point = script_break_points[i];
if (old_script_copy_opt) {
var clone = break_point.cloneForOtherScript(old_script_copy_opt);
clone.set(old_script_copy_opt);
break_points_update_report.push( {
type: "copied_to_old",
id: break_point.number(),
new_id: clone.number(),
positions: break_point_old_positions[i]
} );
}
var updated_position = pos_translator.Translate(
break_point_old_positions[i].position,
PosTranslator.ShiftWithTopInsideChunkHandler);
var new_location =
original_script.locationFromPosition(updated_position, false);
break_point.update_positions(new_location.line, new_location.column);
var new_position_description = {
position: updated_position,
line: new_location.line,
column: new_location.column
};
break_point.set(original_script);
break_points_update_report.push( { type: "position_changed",
id: break_point.number(),
old_positions: break_point_old_positions[i],
new_positions: new_position_description
} );
}
};
}
|
javascript
|
{
"resource": ""
}
|
q59325
|
BuildCodeInfoTree
|
validation
|
function BuildCodeInfoTree(code_info_array) {
// Throughtout all function we iterate over input array.
var index = 0;
// Recursive function that builds a branch of tree.
function BuildNode() {
var my_index = index;
index++;
var child_array = new GlobalArray();
while (index < code_info_array.length &&
code_info_array[index].outer_index == my_index) {
child_array.push(BuildNode());
}
var node = new CodeInfoTreeNode(code_info_array[my_index], child_array,
my_index);
for (var i = 0; i < child_array.length; i++) {
child_array[i].parent = node;
}
return node;
}
var root = BuildNode();
Assert(index == code_info_array.length);
return root;
}
|
javascript
|
{
"resource": ""
}
|
q59326
|
ProcessInternals
|
validation
|
function ProcessInternals(info_node) {
info_node.new_start_pos = chunk_it.TranslatePos(
info_node.info.start_position);
var child_index = 0;
var code_changed = false;
var source_changed = false;
// Simultaneously iterates over child functions and over chunks.
while (!chunk_it.done() &&
chunk_it.current().pos1 < info_node.info.end_position) {
if (child_index < info_node.children.length) {
var child = info_node.children[child_index];
if (child.info.end_position <= chunk_it.current().pos1) {
ProcessUnchangedChild(child);
child_index++;
continue;
} else if (child.info.start_position >=
chunk_it.current().pos1 + chunk_it.current().len1) {
code_changed = true;
chunk_it.next();
continue;
} else if (child.info.start_position <= chunk_it.current().pos1 &&
child.info.end_position >= chunk_it.current().pos1 +
chunk_it.current().len1) {
ProcessInternals(child);
source_changed = source_changed ||
( child.status != FunctionStatus.UNCHANGED );
code_changed = code_changed ||
( child.status == FunctionStatus.DAMAGED );
child_index++;
continue;
} else {
code_changed = true;
child.status = FunctionStatus.DAMAGED;
child.status_explanation =
"Text diff overlaps with function boundary";
child_index++;
continue;
}
} else {
if (chunk_it.current().pos1 + chunk_it.current().len1 <=
info_node.info.end_position) {
info_node.status = FunctionStatus.CHANGED;
chunk_it.next();
continue;
} else {
info_node.status = FunctionStatus.DAMAGED;
info_node.status_explanation =
"Text diff overlaps with function boundary";
return;
}
}
Assert("Unreachable", false);
}
while (child_index < info_node.children.length) {
var child = info_node.children[child_index];
ProcessUnchangedChild(child);
child_index++;
}
if (code_changed) {
info_node.status = FunctionStatus.CHANGED;
} else if (source_changed) {
info_node.status = FunctionStatus.SOURCE_CHANGED;
}
info_node.new_end_pos =
chunk_it.TranslatePos(info_node.info.end_position);
}
|
javascript
|
{
"resource": ""
}
|
q59327
|
FindFunctionInfos
|
validation
|
function FindFunctionInfos(compile_info) {
var wrappers = [];
for (var i = 0; i < shared_infos.length; i++) {
var wrapper = shared_infos[i];
if (wrapper.start_position == compile_info.start_position &&
wrapper.end_position == compile_info.end_position) {
wrappers.push(wrapper);
}
}
if (wrappers.length > 0) {
return wrappers;
}
}
|
javascript
|
{
"resource": ""
}
|
q59328
|
FunctionCompileInfo
|
validation
|
function FunctionCompileInfo(raw_array) {
this.function_name = raw_array[0];
this.start_position = raw_array[1];
this.end_position = raw_array[2];
this.param_num = raw_array[3];
this.code = raw_array[4];
this.code_scope_info = raw_array[5];
this.scope_info = raw_array[6];
this.outer_index = raw_array[7];
this.shared_function_info = raw_array[8];
this.next_sibling_index = null;
this.raw_array = raw_array;
}
|
javascript
|
{
"resource": ""
}
|
q59329
|
IsFunctionContextLocalsChanged
|
validation
|
function IsFunctionContextLocalsChanged(function_info1, function_info2) {
var scope_info1 = function_info1.scope_info;
var scope_info2 = function_info2.scope_info;
var scope_info1_text;
var scope_info2_text;
if (scope_info1) {
scope_info1_text = scope_info1.toString();
} else {
scope_info1_text = "";
}
if (scope_info2) {
scope_info2_text = scope_info2.toString();
} else {
scope_info2_text = "";
}
if (scope_info1_text != scope_info2_text) {
return "Variable map changed: [" + scope_info1_text +
"] => [" + scope_info2_text + "]";
}
// No differences. Return undefined.
return;
}
|
javascript
|
{
"resource": ""
}
|
q59330
|
DescribeChangeTree
|
validation
|
function DescribeChangeTree(old_code_tree) {
function ProcessOldNode(node) {
var child_infos = [];
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
if (child.status != FunctionStatus.UNCHANGED) {
child_infos.push(ProcessOldNode(child));
}
}
var new_child_infos = [];
if (node.textually_unmatched_new_nodes) {
for (var i = 0; i < node.textually_unmatched_new_nodes.length; i++) {
var child = node.textually_unmatched_new_nodes[i];
new_child_infos.push(ProcessNewNode(child));
}
}
var res = {
name: node.info.function_name,
positions: DescribePositions(node),
status: node.status,
children: child_infos,
new_children: new_child_infos
};
if (node.status_explanation) {
res.status_explanation = node.status_explanation;
}
if (node.textual_corresponding_node) {
res.new_positions = DescribePositions(node.textual_corresponding_node);
}
return res;
}
function ProcessNewNode(node) {
var child_infos = [];
// Do not list ancestors.
if (false) {
for (var i = 0; i < node.children.length; i++) {
child_infos.push(ProcessNewNode(node.children[i]));
}
}
var res = {
name: node.info.function_name,
positions: DescribePositions(node),
children: child_infos,
};
return res;
}
function DescribePositions(node) {
return {
start_position: node.info.start_position,
end_position: node.info.end_position
};
}
return ProcessOldNode(old_code_tree);
}
|
javascript
|
{
"resource": ""
}
|
q59331
|
MakeBreakPoint
|
validation
|
function MakeBreakPoint(source_position, opt_script_break_point) {
var break_point = new BreakPoint(source_position, opt_script_break_point);
break_points.push(break_point);
return break_point;
}
|
javascript
|
{
"resource": ""
}
|
q59332
|
ScriptBreakPoint
|
validation
|
function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
opt_groupId, opt_position_alignment) {
this.type_ = type;
if (type == Debug.ScriptBreakPointType.ScriptId) {
this.script_id_ = script_id_or_name;
} else if (type == Debug.ScriptBreakPointType.ScriptName) {
this.script_name_ = script_id_or_name;
} else if (type == Debug.ScriptBreakPointType.ScriptRegExp) {
this.script_regexp_object_ = new GlobalRegExp(script_id_or_name);
} else {
throw MakeError(kDebugger, "Unexpected breakpoint type " + type);
}
this.line_ = opt_line || 0;
this.column_ = opt_column;
this.groupId_ = opt_groupId;
this.position_alignment_ = IS_UNDEFINED(opt_position_alignment)
? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
this.active_ = true;
this.condition_ = null;
this.break_points_ = [];
}
|
javascript
|
{
"resource": ""
}
|
q59333
|
UpdateScriptBreakPoints
|
validation
|
function UpdateScriptBreakPoints(script) {
for (var i = 0; i < script_break_points.length; i++) {
var break_point = script_break_points[i];
if ((break_point.type() == Debug.ScriptBreakPointType.ScriptName ||
break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) &&
break_point.matchesScript(script)) {
break_point.set(script);
}
}
}
|
javascript
|
{
"resource": ""
}
|
q59334
|
ArrayToProtocolArray_
|
validation
|
function ArrayToProtocolArray_(array, mirror_serializer) {
var json = [];
for (var i = 0; i < array.length; i++) {
json.push(ValueToProtocolValue_(array[i], mirror_serializer));
}
return json;
}
|
javascript
|
{
"resource": ""
}
|
q59335
|
ValueToProtocolValue_
|
validation
|
function ValueToProtocolValue_(value, mirror_serializer) {
// Format the value based on its type.
var json;
switch (typeof value) {
case 'object':
if (value instanceof Mirror) {
json = mirror_serializer.serializeValue(value);
} else if (IS_ARRAY(value)){
json = ArrayToProtocolArray_(value, mirror_serializer);
} else {
json = ObjectToProtocolObject_(value, mirror_serializer);
}
break;
case 'boolean':
case 'string':
case 'number':
json = value;
break;
default:
json = null;
}
return json;
}
|
javascript
|
{
"resource": ""
}
|
q59336
|
runRichards
|
validation
|
function runRichards() {
var scheduler = new Scheduler();
scheduler.addIdleTask(ID_IDLE, 0, null, COUNT);
var queue = new Packet(null, ID_WORKER, KIND_WORK);
queue = new Packet(queue, ID_WORKER, KIND_WORK);
scheduler.addWorkerTask(ID_WORKER, 1000, queue);
queue = new Packet(null, ID_DEVICE_A, KIND_DEVICE);
queue = new Packet(queue, ID_DEVICE_A, KIND_DEVICE);
queue = new Packet(queue, ID_DEVICE_A, KIND_DEVICE);
scheduler.addHandlerTask(ID_HANDLER_A, 2000, queue);
queue = new Packet(null, ID_DEVICE_B, KIND_DEVICE);
queue = new Packet(queue, ID_DEVICE_B, KIND_DEVICE);
queue = new Packet(queue, ID_DEVICE_B, KIND_DEVICE);
scheduler.addHandlerTask(ID_HANDLER_B, 3000, queue);
scheduler.addDeviceTask(ID_DEVICE_A, 4000, null);
scheduler.addDeviceTask(ID_DEVICE_B, 5000, null);
scheduler.schedule();
if (scheduler.queueCount != EXPECTED_QUEUE_COUNT ||
scheduler.holdCount != EXPECTED_HOLD_COUNT) {
var msg =
"Error during execution: queueCount = " + scheduler.queueCount +
", holdCount = " + scheduler.holdCount + ".";
throw new Error(msg);
}
}
|
javascript
|
{
"resource": ""
}
|
q59337
|
Scheduler
|
validation
|
function Scheduler() {
this.queueCount = 0;
this.holdCount = 0;
this.blocks = new Array(NUMBER_OF_IDS);
this.list = null;
this.currentTcb = null;
this.currentId = null;
}
|
javascript
|
{
"resource": ""
}
|
q59338
|
TaskControlBlock
|
validation
|
function TaskControlBlock(link, id, priority, queue, task) {
this.link = link;
this.id = id;
this.priority = priority;
this.queue = queue;
this.task = task;
if (queue == null) {
this.state = STATE_SUSPENDED;
} else {
this.state = STATE_SUSPENDED_RUNNABLE;
}
}
|
javascript
|
{
"resource": ""
}
|
q59339
|
IdleTask
|
validation
|
function IdleTask(scheduler, v1, count) {
this.scheduler = scheduler;
this.v1 = v1;
this.count = count;
}
|
javascript
|
{
"resource": ""
}
|
q59340
|
WorkerTask
|
validation
|
function WorkerTask(scheduler, v1, v2) {
this.scheduler = scheduler;
this.v1 = v1;
this.v2 = v2;
}
|
javascript
|
{
"resource": ""
}
|
q59341
|
Packet
|
validation
|
function Packet(link, id, kind) {
this.link = link;
this.id = id;
this.kind = kind;
this.a1 = 0;
this.a2 = new Array(DATA_SIZE);
}
|
javascript
|
{
"resource": ""
}
|
q59342
|
ccallFunc
|
validation
|
function ccallFunc(func, returnType, argTypes, args) {
var stack = 0;
function toC(value, type) {
if (type == 'string') {
if (value === null || value === undefined || value === 0) return 0; // null string
if (!stack) stack = Runtime.stackSave();
var ret = Runtime.stackAlloc(value.length+1);
writeStringToMemory(value, ret);
return ret;
} else if (type == 'array') {
if (!stack) stack = Runtime.stackSave();
var ret = Runtime.stackAlloc(value.length);
writeArrayToMemory(value, ret);
return ret;
}
return value;
}
function fromC(value, type) {
if (type == 'string') {
return Pointer_stringify(value);
}
assert(type != 'array');
return value;
}
var i = 0;
var cArgs = args ? args.map(function(arg) {
return toC(arg, argTypes[i++]);
}) : [];
var ret = fromC(func.apply(null, cArgs), returnType);
if (stack) Runtime.stackRestore(stack);
return ret;
}
|
javascript
|
{
"resource": ""
}
|
q59343
|
addPreRun
|
validation
|
function addPreRun(func) {
if (!Module['preRun']) Module['preRun'] = [];
else if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
Module['preRun'].push(func);
}
|
javascript
|
{
"resource": ""
}
|
q59344
|
findPackage
|
validation
|
function findPackage(directory) {
const file = path.resolve(directory, 'package.json')
if (fs.existsSync(file) && fs.statSync(file).isFile()) {
return require(file)
}
const parent = path.resolve(directory, '..')
return parent === directory ? null : findPackage(parent)
}
|
javascript
|
{
"resource": ""
}
|
q59345
|
isMultisource
|
validation
|
function isMultisource(arg) {
return Array.isArray(arg) &&
!(typeof arg[0] === 'number' && (arg.length === 1 || typeof arg[1] === 'number')) &&
!(arg.length < 32 && arg.every(ch => Array.isArray(ch) || ArrayBuffer.isView(ch)))
}
|
javascript
|
{
"resource": ""
}
|
q59346
|
resolvePath
|
validation
|
function resolvePath (fileName, depth=2) {
if (!isBrowser && isRelative(fileName) && !isURL(fileName)) {
var callerPath = callsites()[depth].getFileName()
fileName = path.dirname(callerPath) + path.sep + fileName
fileName = path.normalize(fileName)
}
return fileName
}
|
javascript
|
{
"resource": ""
}
|
q59347
|
areEquivalent
|
validation
|
function areEquivalent(s1, s2, table, alphabet) {
for (const symbol of alphabet) {
if (!goToSameSet(s1, s2, table, symbol)) {
return false;
}
}
return true;
}
|
javascript
|
{
"resource": ""
}
|
q59348
|
goToSameSet
|
validation
|
function goToSameSet(s1, s2, table, symbol) {
if (!currentTransitionMap[s1] || !currentTransitionMap[s2]) {
return false;
}
const originalTransitionS1 = table[s1][symbol];
const originalTransitionS2 = table[s2][symbol];
// If no actual transition on this symbol, treat it as positive.
if (!originalTransitionS1 && !originalTransitionS2) {
return true;
}
// Otherwise, check if they are in the same sets.
return currentTransitionMap[s1].has(originalTransitionS1) &&
currentTransitionMap[s2].has(originalTransitionS2);
}
|
javascript
|
{
"resource": ""
}
|
q59349
|
isSimpleRange
|
validation
|
function isSimpleRange(classRange) {
const {from, to} = classRange;
return (
from.codePoint >= DIGIT_0_CP && from.codePoint <= DIGIT_9_CP &&
to.codePoint >= DIGIT_0_CP && to.codePoint <= DIGIT_9_CP
) || (
from.codePoint >= UPPER_A_CP && from.codePoint <= UPPER_Z_CP &&
to.codePoint >= UPPER_A_CP && to.codePoint <= UPPER_Z_CP
) || (
from.codePoint >= LOWER_A_CP && from.codePoint <= LOWER_Z_CP &&
to.codePoint >= LOWER_A_CP && to.codePoint <= LOWER_Z_CP
);
}
|
javascript
|
{
"resource": ""
}
|
q59350
|
getRange
|
validation
|
function getRange(text) {
const range = text.match(/\d+/g).map(Number);
if (Number.isFinite(range[1]) && range[1] < range[0]) {
throw new SyntaxError(`Numbers out of order in ${text} quantifier`);
}
return range;
}
|
javascript
|
{
"resource": ""
}
|
q59351
|
checkClassRange
|
validation
|
function checkClassRange(from, to) {
if (from.kind === 'control' || to.kind === 'control' || (!isNaN(from.codePoint) && !isNaN(to.codePoint) && from.codePoint > to.codePoint)) {
throw new SyntaxError(`Range ${from.value}-${to.value} out of order in character class`);
}
}
|
javascript
|
{
"resource": ""
}
|
q59352
|
Char
|
validation
|
function Char(value, kind, loc) {
let symbol;
let codePoint;
switch (kind) {
case 'decimal': {
codePoint = Number(value.slice(1));
symbol = String.fromCodePoint(codePoint);
break;
}
case 'oct': {
codePoint = parseInt(value.slice(1), 8);
symbol = String.fromCodePoint(codePoint);
break;
}
case 'hex':
case 'unicode': {
if (value.lastIndexOf('\\u') > 0) {
let [lead, trail] = value.split('\\u').slice(1);
lead = parseInt(lead, 16);
trail = parseInt(trail, 16);
codePoint = (lead - 0xd800) * 0x400 + (trail - 0xdc00) + 0x10000;
symbol = String.fromCodePoint(codePoint);
} else {
const hex = value.slice(2).replace('{', '');
codePoint = parseInt(hex, 16);
if (codePoint > 0x10ffff) {
throw new SyntaxError(`Bad character escape sequence: ${value}`);
}
symbol = String.fromCodePoint(codePoint);
}
break;
}
case 'meta': {
switch (value) {
case '\\t':
symbol = '\t';
codePoint = symbol.codePointAt(0);
break;
case '\\n':
symbol = '\n';
codePoint = symbol.codePointAt(0);
break;
case '\\r':
symbol = '\r';
codePoint = symbol.codePointAt(0);
break;
case '\\v':
symbol = '\v';
codePoint = symbol.codePointAt(0);
break;
case '\\f':
symbol = '\f';
codePoint = symbol.codePointAt(0);
break;
case '\\b':
symbol = '\b';
codePoint = symbol.codePointAt(0);
case '\\0':
symbol = '\0';
codePoint = 0;
case '.':
symbol = '.';
codePoint = NaN;
break;
default:
codePoint = NaN;
}
break;
}
case 'simple': {
symbol = value;
codePoint = symbol.codePointAt(0);
break;
}
}
return Node({
type: 'Char',
value,
kind,
symbol,
codePoint,
}, loc);
}
|
javascript
|
{
"resource": ""
}
|
q59353
|
checkFlags
|
validation
|
function checkFlags(flags) {
const seen = new Set();
for (const flag of flags) {
if (seen.has(flag) || !validFlags.includes(flag)) {
throw new SyntaxError(`Invalid flags: ${flags}`);
}
seen.add(flag);
}
return flags.split('').sort().join('');
}
|
javascript
|
{
"resource": ""
}
|
q59354
|
GroupRefOrDecChar
|
validation
|
function GroupRefOrDecChar(text, textLoc) {
const reference = Number(text.slice(1));
if (reference > 0 && reference <= capturingGroupsCount) {
return Node({
type: 'Backreference',
kind: 'number',
number: reference,
reference,
}, textLoc);
}
return Char(text, 'decimal', textLoc);
}
|
javascript
|
{
"resource": ""
}
|
q59355
|
validateUnicodeGroupName
|
validation
|
function validateUnicodeGroupName(name, state) {
const isUnicodeName = uRe.test(name) || ucpRe.test(name);
const isUnicodeState = (state === 'u' || state === 'xu' || state === 'u_class');
if (isUnicodeName && !isUnicodeState) {
throw new SyntaxError(`invalid group Unicode name "${name}", use \`u\` flag.`);
}
}
|
javascript
|
{
"resource": ""
}
|
q59356
|
Node
|
validation
|
function Node(node, loc) {
if (yy.options.captureLocations) {
node.loc = {
source: parsingString.slice(loc.startOffset, loc.endOffset),
start: {
line: loc.startLine,
column: loc.startColumn,
offset: loc.startOffset,
},
end: {
line: loc.endLine,
column: loc.endColumn,
offset: loc.endOffset,
},
};
}
return node;
}
|
javascript
|
{
"resource": ""
}
|
q59357
|
loc
|
validation
|
function loc(start, end) {
if (!yy.options.captureLocations) {
return null;
}
return {
startOffset: start.startOffset,
endOffset: end.endOffset,
startLine: start.startLine,
endLine: end.endLine,
startColumn: start.startColumn,
endColumn: end.endColumn,
};
}
|
javascript
|
{
"resource": ""
}
|
q59358
|
isMeta
|
validation
|
function isMeta(expression, value = null) {
return expression.type === 'Char' &&
expression.kind === 'meta' &&
(value ? expression.value === value : /^\\[dws]$/i.test(expression.value));
}
|
javascript
|
{
"resource": ""
}
|
q59359
|
astTraverse
|
validation
|
function astTraverse(root, options = {}) {
const pre = options.pre;
const post = options.post;
const skipProperty = options.skipProperty;
function visit(node, parent, prop, idx) {
if (!node || typeof node.type !== 'string') {
return;
}
let res = undefined;
if (pre) {
res = pre(node, parent, prop, idx);
}
if (res !== false) {
// A node can be replaced during traversal, so we have to
// recalculate it from the parent, to avoid traversing "dead" nodes.
if (parent && parent[prop]) {
if (!isNaN(idx)) {
node = parent[prop][idx];
} else {
node = parent[prop];
}
}
for (let prop in node) if (node.hasOwnProperty(prop)) {
if (skipProperty ? skipProperty(prop, node) : prop[0] === '$') {
continue;
}
const child = node[prop];
// Collection node.
//
// NOTE: a node (or several nodes) can be removed or inserted
// during traversal.
//
// Current traversing index is stored on top of the
// `NodePath.traversingIndexStack`. The stack is used to support
// recursive nature of the traversal.
//
// In this case `NodePath.traversingIndex` (which we use here) is
// updated in the NodePath remove/insert methods.
//
if (Array.isArray(child)) {
let index = 0;
NodePath.traversingIndexStack.push(index);
while (index < child.length) {
visit(
child[index],
node,
prop,
index
);
index = NodePath.updateTraversingIndex(+1);
}
NodePath.traversingIndexStack.pop();
}
// Simple node.
else {
visit(child, node, prop);
}
}
}
if (post) {
post(node, parent, prop, idx);
}
}
visit(root, null);
}
|
javascript
|
{
"resource": ""
}
|
q59360
|
alt
|
validation
|
function alt(first, ...fragments) {
for (let fragment of fragments) {
first = altPair(first, fragment);
}
return first;
}
|
javascript
|
{
"resource": ""
}
|
q59361
|
or
|
validation
|
function or(first, ...fragments) {
for (let fragment of fragments) {
first = orPair(first, fragment);
}
return first;
}
|
javascript
|
{
"resource": ""
}
|
q59362
|
gen
|
validation
|
function gen(node) {
if (node && !generator[node.type]) {
throw new Error(`${node.type} is not supported in NFA/DFA interpreter.`);
}
return node ? generator[node.type](node) : '';
}
|
javascript
|
{
"resource": ""
}
|
q59363
|
preservesInCharClass
|
validation
|
function preservesInCharClass(value, index, parent) {
if (value === '^') {
// Avoid [\^a] turning into [^a]
return index === 0 && !parent.negative;
}
if (value === '-') {
// Avoid [a\-z] turning into [a-z]
return index !== 0 && index !== parent.expressions.length - 1;
}
return /[\]\\]/.test(value);
}
|
javascript
|
{
"resource": ""
}
|
q59364
|
disjunctionToList
|
validation
|
function disjunctionToList(node) {
if (node.type !== 'Disjunction') {
throw new TypeError(`Expected "Disjunction" node, got "${node.type}"`);
}
const list = [];
if (node.left && node.left.type === 'Disjunction') {
list.push(...disjunctionToList(node.left), node.right);
} else {
list.push(node.left, node.right);
}
return list;
}
|
javascript
|
{
"resource": ""
}
|
q59365
|
install
|
validation
|
function install(name, algorithm) {
if (typeof name !== 'string' || name === '') {
throw new TypeError('The algorithm name must be an non-empty string.');
}
if (
typeof algorithm !== 'object' ||
algorithm === null ||
Array.isArray(algorithm)
) {
throw new TypeError('The algorithm object must be an object.');
}
if (typeof algorithm.hash !== 'function') {
throw new TypeError(
'The hash property of the algorithm object should be a function.'
);
}
if (typeof algorithm.verify !== 'function') {
throw new TypeError(
'The verify property of the algorithm object should be a function.'
);
}
if (typeof algorithm.identifiers !== 'function') {
throw new TypeError(
'The identifiers property of the algorithm object should be a function.'
);
}
if (funcs[name] !== undefined) {
throw new TypeError(`The ${name} algorithm is already installed.`);
}
const idfs = algorithm.identifiers();
for (const an of queue) {
if (funcs[an].identifiers().some(idf => idfs.indexOf(idf) !== -1)) {
throw new Error(
'The identifiers property of the algorithm object clashes with the ones of another algorithm.'
);
}
}
funcs[name] = Object.assign({}, algorithm);
Object.freeze(funcs[name]);
queue.push(name);
}
|
javascript
|
{
"resource": ""
}
|
q59366
|
uninstall
|
validation
|
function uninstall(name) {
if (typeof name !== 'string' || name === '') {
throw new TypeError('The algorithm name must be an non-empty string.');
}
const hashFunc = funcs[name];
if (!hashFunc) {
throw new TypeError(`The ${name} algorithm is not installed`);
}
delete funcs[name];
queue.splice(queue.indexOf(name), 1);
}
|
javascript
|
{
"resource": ""
}
|
q59367
|
use
|
validation
|
function use(name) {
if (name === undefined) {
if (queue.length === 0) {
throw new Error('No algorithm installed.');
}
name = queue[queue.length - 1];
} else if (typeof name !== 'string' || name === '') {
throw new TypeError('The algorithm name must be an non-empty string.');
}
const hashFunc = funcs[name];
if (!hashFunc) {
throw new TypeError(`The ${name} algorithm is not installed`);
}
return hashFunc;
}
|
javascript
|
{
"resource": ""
}
|
q59368
|
which
|
validation
|
function which(hashstr) {
if (typeof hashstr !== 'string' || hashstr === '') {
throw new TypeError('The hashstr param must be an non-empty string.');
}
const fields = hashstr.split('$');
if (fields.length < 3 || fields[0] !== '') {
throw new TypeError(
'The hashstr param provided is not in a supported format.'
);
}
const idf = fields[1];
if (queue.length === 0) {
throw new Error('No algorithm installed.');
}
for (const name of queue) {
if (funcs[name].identifiers().indexOf(idf) === -1) continue;
return name;
}
return null;
}
|
javascript
|
{
"resource": ""
}
|
q59369
|
verify
|
validation
|
function verify(hashstr, password) {
const name = which(hashstr);
if (name === null) {
throw new TypeError('No compatible algorithm installed.');
}
return use(name).verify(hashstr, password);
}
|
javascript
|
{
"resource": ""
}
|
q59370
|
sanitizeProps
|
validation
|
function sanitizeProps(props, toRemove) {
props = {...props};
for (let i = 0, l = toRemove.length; i < l; i += 1) {
delete props[toRemove[i]]
}
return props;
}
|
javascript
|
{
"resource": ""
}
|
q59371
|
getServers
|
validation
|
function getServers () {
var interfaces = os.networkInterfaces()
var result = []
for (var key in interfaces) {
var addresses = interfaces[key]
for (var i = addresses.length; i--;) {
var address = addresses[i]
if (address.family === 'IPv4' && !address.internal) {
var subnet = ip.subnet(address.address, address.netmask)
var current = ip.toLong(subnet.firstAddress)
var last = ip.toLong(subnet.lastAddress) - 1
while (current++ < last) result.push(ip.fromLong(current))
}
}
}
return result
}
|
javascript
|
{
"resource": ""
}
|
q59372
|
pingServer
|
validation
|
function pingServer (address) {
return new Promise(function (resolve) {
var socket = new net.Socket()
socket.setTimeout(1000, close)
socket.connect(80, address, close)
socket.once('error', close)
function close () {
socket.destroy()
resolve(address)
}
})
}
|
javascript
|
{
"resource": ""
}
|
q59373
|
parseAll
|
validation
|
function parseAll (data) {
if (!data || !data[0]) {
return []
}
if (process.platform.includes('linux')) {
var rows = data[0].split('\n')
return rows.map(function (row) {
return parseLinux(row, servers)
}).filter(Boolean)
} else if (process.platform.includes('win32')) {
var winRows = data[0].split('\n').splice(1)
return winRows.map(function (row) {
return parseWin32(row, servers)
}).filter(Boolean)
}
return data[0]
.trim()
.split('\n')
.map(function (row) {
return parseRow(row, servers)
})
.filter(Boolean)
}
|
javascript
|
{
"resource": ""
}
|
q59374
|
parseOne
|
validation
|
function parseOne (data) {
if (!data || !data[0]) {
return
}
if (process.platform.includes('linux')) {
// ignore unresolved hosts (can happen when parseOne returns only one unresolved host)
if (data[0].indexOf('no entry') >= 0) {
return
}
// remove first row (containing "headlines")
var rows = data[0].split('\n').slice(1)[0]
return parseLinux(rows, servers, true)
} else if (process.platform.includes('win32')) {
return // currently not supported
}
return parseRow(data[0], servers)
}
|
javascript
|
{
"resource": ""
}
|
q59375
|
timePassed
|
validation
|
function timePassed(t) {
if (t > 0) this.find(".wcp-time-current").text(parseTime(t,this.vlc.length));
else if (this.find(".wcp-time-current").text() != "" && this.find(".wcp-time-total").text() == "") this.find(".wcp-time-current").text("");
if (typeof opts[this.context].subtitles === 'undefined') opts[this.context].subtitles = [];
if (opts[this.context].subtitles.length > 0) {
// End show subtitle text (external subtitles)
var nowSecond = (t - opts[this.context].subDelay) /1000;
if (opts[this.context].trackSub > -2) {
var subtitle = -1;
var os = 0;
for (os in opts[this.context].subtitles) {
if (os > nowSecond) break;
subtitle = os;
}
if (subtitle > 0) {
if(subtitle != opts[this.context].trackSub) {
if ((opts[this.context].subtitles[subtitle].t.match(new RegExp("<", "g")) || []).length == 2) {
if (!(opts[this.context].subtitles[subtitle].t.substr(0,1) == "<" && opts[this.context].subtitles[subtitle].t.slice(-1) == ">")) {
opts[this.context].subtitles[subtitle].t = opts[this.context].subtitles[subtitle].t.replace(/<\/?[^>]+(>|$)/g, "");
}
} else if ((opts[this.context].subtitles[subtitle].t.match(new RegExp("<", "g")) || []).length > 2) {
opts[this.context].subtitles[subtitle].t = opts[this.context].subtitles[subtitle].t.replace(/<\/?[^>]+(>|$)/g, "");
}
this.find(".wcp-subtitle-text").html(nl2br(opts[this.context].subtitles[subtitle].t));
opts[this.context].trackSub = subtitle;
} else if (opts[this.context].subtitles[subtitle].o < nowSecond) {
this.find(".wcp-subtitle-text").html("");
}
}
}
// End show subtitle text (external subtitles)
}
}
|
javascript
|
{
"resource": ""
}
|
q59376
|
validation
|
function(opts) {
opts.accesskey = opts.accesskey || opts.password;
delete opts.password;
if (opts.selenium.hostname.match(/ondemand.saucelabs.com/)) {
opts.SAUCE_USERNAME = opts.SAUCE_USERNAME || opts.username;
opts.SAUCE_ACCESSKEY = opts.SAUCE_ACCESSKEY || opts.accesskey;
if (typeof opts.SAUCE_USERNAME !== 'undefined' && typeof opts.SAUCE_ACCESSKEY !== 'undefined') {
opts.selenium.auth = opts.SAUCE_USERNAME + ':' + opts.SAUCE_ACCESSKEY;
delete opts.SAUCE_ACCESSKEY;
delete opts.SAUCE_USERNAME;
}
} else if (opts.selenium.hostname.match(/hub.browserstack.com/)) {
opts.BROWSERSTACK_USERNAME = opts.BROWSERSTACK_USERNAME || opts.username;
opts.BROWSERSTACK_KEY = opts.BROWSERSTACK_KEY || opts.accesskey;
if (typeof opts.BROWSERSTACK_USERNAME !== 'undefined') {
opts.browsers.forEach(function(browser) {
browser['browserstack.user'] = opts.BROWSERSTACK_USERNAME;
browser['browserstack.key'] = opts.BROWSERSTACK_KEY;
});
delete opts.BROWSERSTACK_USERNAME;
delete opts.BROWSERSTACK_KEY;
delete opts.selenium.user;
delete opts.selenium.pwd;
}
}
delete opts.username;
delete opts.password;
return opts;
}
|
javascript
|
{
"resource": ""
}
|
|
q59377
|
ScrollAction
|
validation
|
function ScrollAction(opt_callback, opt_distance_func) {
var self = this;
this.beginMeasuringHook = function() {}
this.endMeasuringHook = function() {}
this.callback_ = opt_callback;
this.distance_func_ = opt_distance_func;
}
|
javascript
|
{
"resource": ""
}
|
q59378
|
mockXhrGenerator
|
validation
|
function mockXhrGenerator(file) {
var xhr = new MockHttpRequest();
xhr.upload = {};
xhr.onsend = function() {
if (xhr.upload.onloadstart) {
xhr.upload.onloadstart();
}
var total = file && file.size || 1024, done = 0;
function start() {
setTimeout(progress, 1000);
}
function progress() {
xhr.upload.onprogress({total: total, loaded: done});
if (done < total) {
setTimeout(progress, 200);
done = Math.min(total, done + 254000);
} else if (!file.abort) {
setTimeout(finish, 1000);
}
}
function finish() {
xhr.receive(200, '{"message":"OK"}');
}
start();
};
return xhr;
}
|
javascript
|
{
"resource": ""
}
|
q59379
|
getLocalModuleVersion
|
validation
|
function getLocalModuleVersion (name) {
check.verify.string(name, 'missing name string')
try {
var filename = path.join('node_modules', name, 'package.json')
var contents = fs.readFileSync(filename, 'utf-8')
var pkg = JSON.parse(contents)
return pkg.version
} catch (error) {
console.error('could not fetch version for local module', name)
console.error(error)
return null
}
}
|
javascript
|
{
"resource": ""
}
|
q59380
|
nextVersions
|
validation
|
function nextVersions (options, nameVersionPairs, checkLatestOnly) {
check.verify.object(options, 'expected object with options')
check.verify.array(nameVersionPairs, 'expected array')
nameVersionPairs = cleanVersions(nameVersionPairs)
const verbose = verboseLog(options)
verbose('checking NPM registry')
var MAX_CHECK_TIMEOUT = options.checkVersionTimeout || 10000
var fetchPromises = nameVersionPairs.map(fetchVersions.bind(null, options))
var fetchAllPromise = q.all(fetchPromises)
.timeout(MAX_CHECK_TIMEOUT, 'timed out waiting for NPM after ' + MAX_CHECK_TIMEOUT + 'ms')
return fetchAllPromise.then(
_.partial(filterFetchedVersions, checkLatestOnly),
q.reject
)
}
|
javascript
|
{
"resource": ""
}
|
q59381
|
serializeMethods
|
validation
|
function serializeMethods(o) {
var v;
for (var k in o) {
v = o[k];
if (_.isObject(v) && !_.isArray(v) && !_.isFunction(v)) {
serializeMethods(v);
} else {
o[k] = serializeFunctions(v);
}
}
}
|
javascript
|
{
"resource": ""
}
|
q59382
|
_toJson
|
validation
|
function _toJson(next) {
options.xmlConverter(response.body, options, function(error, data) {
if (error) return next(error);
debug('Parsed XML', data);
timer('time to parsed XML', Date.now() - _startTime);
next(null, data);
});
}
|
javascript
|
{
"resource": ""
}
|
q59383
|
itemsCallback
|
validation
|
function itemsCallback(error, itemsResponse) {
if (error) throw error;
var items = itemsResponse.searchResult.item;
console.log('Found', items.length, 'items');
for (var i = 0; i < items.length; i++) {
console.log('- ' + items[i].title);
}
}
|
javascript
|
{
"resource": ""
}
|
q59384
|
getExe
|
validation
|
function getExe() {
/* istanbul ignore next: tested on all platform on travis */
switch (process.platform) {
case "darwin":
return "mkcert-" + MKCERT_VERSION + "-darwin-amd64"
case "linux":
return "mkcert-" + MKCERT_VERSION + "-linux-amd64"
case "win32":
return "mkcert-" + MKCERT_VERSION + "-windows-amd64.exe"
default:
console.warn("Cannot generate the localhost certificate on your " +
"platform. Please, consider contacting the developer if you can help.")
process.exit(0)
}
}
|
javascript
|
{
"resource": ""
}
|
q59385
|
download
|
validation
|
function download(url, path) {
console.log("Downloading the mkcert executable...")
const file = fs.createWriteStream(path)
return new Promise(resolve => {
function get(url, file) {
https.get(url, (response) => {
if (response.statusCode === 302) get(response.headers.location, file)
else response.pipe(file).on("finish", resolve)
})
}
get(url, file)
})
}
|
javascript
|
{
"resource": ""
}
|
q59386
|
mkcert
|
validation
|
function mkcert(appDataPath, exe) {
const logPath = path.join(appDataPath, "mkcert.log")
const errPath = path.join(appDataPath, "mkcert.err")
// escape spaces in appDataPath (Mac OS)
appDataPath = appDataPath.replace(" ", "\\ ")
const exePath = path.join(appDataPath, exe)
const crtPath = path.join(appDataPath, "localhost.crt")
const keyPath = path.join(appDataPath, "localhost.key")
const cmd = exePath + " -install -cert-file " + crtPath +
" -key-file " + keyPath + " localhost"
return new Promise((resolve, reject) => {
console.log("Running mkcert to generate certificates...")
exec(cmd, (err, stdout, stderr) => {
// log
const errFun = err => {
/* istanbul ignore if: cannot be tested */
if (err) console.error(err)
}
fs.writeFile(logPath, stdout, errFun)
fs.writeFile(errPath, stderr, errFun)
/* istanbul ignore if: cannot be tested */
if (err) reject(err)
resolve()
})
})
}
|
javascript
|
{
"resource": ""
}
|
q59387
|
remove
|
validation
|
function remove(appDataPath = CERT_PATH) {
if (fs.existsSync(appDataPath)) {
fs.readdirSync(appDataPath)
.forEach(file => fs.unlinkSync(path.join(appDataPath, file)))
fs.rmdirSync(appDataPath)
}
}
|
javascript
|
{
"resource": ""
}
|
q59388
|
clone
|
validation
|
function clone(v) {
if (v === null || typeof v !== "object") {
return v;
}
if (isArray(v)) {
var arr = v.slice();
for (var i = 0; i < v.length; i++) {
arr[i] = clone(arr[i]);
}
return arr;
}
else {
var obj = {};
for (var k in v) {
obj[k] = clone(v[k]);
}
return obj;
}
}
|
javascript
|
{
"resource": ""
}
|
q59389
|
validation
|
function (identifier, data, config, cb) {
if (data.tags === undefined) {
return new Error("tags param can not be empty.");
}
var path = api.getPathWithData(baseURL, identifier, tagsActionPath, data);
api.delete(path, config, cb);
}
|
javascript
|
{
"resource": ""
}
|
|
q59390
|
validation
|
function (identifier, data, config, cb) {
var path = api.getPath(baseURL, identifier, detailsActionPath);
api.post(path, data, config, cb);
}
|
javascript
|
{
"resource": ""
}
|
|
q59391
|
validation
|
function (identifier, data, config, cb) {
if (data.action === undefined) {
return new Error("action param can not be empty.");
}
var path = api.getPath(baseURL, identifier, customActionPath + data.action);
api.post(path, data, config, cb);
}
|
javascript
|
{
"resource": ""
}
|
|
q59392
|
validation
|
function (identifier, data, config, cb) {
var path = api.getPathWithData(baseURL, identifier, listLogsPath, data);
api.get(path, config, cb);
}
|
javascript
|
{
"resource": ""
}
|
|
q59393
|
validation
|
function (identifier, data, config, cb) {
var path = api.getPath(savedSearchbaseURL, identifier, null);
api.patch(path, data, config, cb)
}
|
javascript
|
{
"resource": ""
}
|
|
q59394
|
optimize
|
validation
|
async function optimize(file) {
check(file);
const name = getName(file);
log('reading file ' + path.basename(name));
const data = await readFile(name, 'utf8');
return onDataRead(file, data);
}
|
javascript
|
{
"resource": ""
}
|
q59395
|
onDataRead
|
validation
|
async function onDataRead(filename, data) {
log('file ' + path.basename(filename) + ' read');
const ext = path.extname(filename).replace(/^\./, '');
const optimizedData = await minify[ext](data);
let b64Optimize;
if (ext === 'css')
[, b64Optimize] = await tryToCatch(minify.img, filename, optimizedData);
return b64Optimize || optimizedData;
}
|
javascript
|
{
"resource": ""
}
|
q59396
|
applyOptions
|
validation
|
function applyOptions(options) {
const settings = {};
options = options || {};
Object.assign(settings, defaults, options);
return settings;
}
|
javascript
|
{
"resource": ""
}
|
q59397
|
parseForwarded
|
validation
|
function parseForwarded(value) {
const forwarded = {}
value.trim().split(';').forEach((part) => {
const pair = part.trim().split('=');
forwarded[pair[0]] = pair[1];
});
return forwarded;
}
|
javascript
|
{
"resource": ""
}
|
q59398
|
loadRcConfig
|
validation
|
function loadRcConfig(callback) {
const sync = typeof callback !== 'function';
if (sync) {
const fp = rcLoader.for(this.resourcePath);
if (typeof fp !== 'string') {
// no .jshintrc found
return {};
}
this.addDependency(fp);
const options = loadConfig(fp);
delete options.dirname;
return options;
}
// eslint-disable-next-line consistent-return
rcLoader.for(this.resourcePath, (err, fp) => {
if (typeof fp !== 'string') {
// no .jshintrc found
return callback(null, {});
}
this.addDependency(fp);
const options = loadConfig(fp);
delete options.dirname;
callback(err, options);
});
}
|
javascript
|
{
"resource": ""
}
|
q59399
|
inferMaster
|
validation
|
function inferMaster() {
var inferred = _.find(self.nestedLocales, { name: self.defaultLocale }) || self.nestedLocales[0];
if ((self.nestedLocales.length > 1) && (!_.find(self.nestedLocales, function(locale) {
return locale.children && locale.children.length;
}))) {
var others = _.filter(self.nestedLocales, function(locale) {
return locale.name !== inferred.name;
});
self.nestedLocales = [ inferred ];
if (others.length) {
inferred.children = others;
}
}
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.