function getFilterClickHandler(filter) {
            var isKind = filter === 'kind';
            var has = isKind ? sbSearch.hasKind : sbSearch.hasScope;
            var add = isKind ? sbSearch.addKind : sbSearch.addScope;
            var remove = isKind ? sbSearch.removeKind : sbSearch.removeScope;

            return function (event) {
                var btn = $(this);
                // get scope or kind value from the data- attribute.
                // e.g. data-scope="instance" or data-kind="method"
                var value = (btn.attr('data-' + filter) || '*').toLowerCase();

                // if we already have this filter, we'll remove it
                if (has.call(sbSearch, value)) {
                    remove.call(sbSearch, value);
                } else if (event.shiftKey) {
                    // if shift is pressed, we'll add it (multiple filters, no
                    // duplicates)
                    add.call(sbSearch, value);
                } else {
                    // otherwise, we'll set it as the only filter (replace with
                    // previous)
                    sbSearch[filter] = [value];
                }

                var strSearch;
                if ($txtSearch) {
                    sbSearch.parseKeywords($txtSearch.val());
                    strSearch = sbSearch.toString();
                    $txtSearch.val(strSearch).focus();
                    if ($btnClean) $btnClean.show();
                } else {
                    sbSearch.keywords = [];
                    strSearch = sbSearch.toString();
                }
                filterSidebarNodes(strSearch);
            };
        }

gets a click event handler for either scope filter buttons or kind filter buttons.

gets a click event handler for either scope filter buttons or kind filter buttons .


function getWithResolvedData(ctx, cur, down) {
    return function(data) {
      return ctx.push(data)._get(cur, down);
    };
  }

function getWithResolvedData ( ctx , cur , down ) { return function ( data ) { return ctx . push ( data ) . _get ( cur , down ) ; } ; }

Factory function that creates a closure scope around a Thenable-callback.
Returns a function that can be passed to a Thenable that will resume a
Context lookup once the Thenable resolves with new data, adding that new
data to the lookup stack.

Factory function that creates a closure scope around a Thenable - callback . Returns a function that can be passed to a Thenable that will resume a Context lookup once the Thenable resolves with new data adding that new data to the lookup stack .


function cleanName(name) {
    // e.g. <anonymous>~obj.doStuff —» obj.doStuff
    name = getStr(name)
        .replace(/([^>]+>)?~?(.*)/, '$2')
        // e.g. '"./node_modules/eventemitter3/index.js"~EventEmitter'.
        .replace(/^"[^"]+"\.?~?([^"]+)$/, '$1')
        .replace(/^(module\.)?exports\./, '')
        .replace(/^module:/, '');
    return fixBracket(name);
}

Cleans the given symbol name.
@private
@param {String} name - Symbol name to be cleaned.
@returns {String} -


function computeInputVariants(str, n) {
  var variants = [ str ];
  for (var i = 1; i < n; i++) {
    var pos = Math.floor(Math.random() * str.length);
    var chr = String.fromCharCode((str.charCodeAt(pos) + Math.floor(Math.random() * 128)) % 128);
    variants[i] = str.substring(0, pos) + chr + str.substring(pos + 1, str.length);
  }
  return variants;
}

function computeInputVariants ( str , n ) { var variants = [ str ] ; for ( var i = 1 ; i < n ; i ++ ) { var pos = Math . floor ( Math . random ( ) * str . length ) ; var chr = String . fromCharCode ( ( str . charCodeAt ( pos ) + Math . floor ( Math . random ( ) * 128 ) ) % 128 ) ; variants [ i ] = str . substring ( 0 , pos ) + chr + str . substring ( pos + 1 , str . length ) ; } return variants ; }

Returns an array of n different variants of the input string str. The variants are computed by randomly rotating one random character.

Returns an array of n different variants of the input string str . The variants are computed by randomly rotating one random character .


function BenchmarkSuite(name, reference, benchmarks) {
  this.name = name;
  this.reference = reference;
  this.benchmarks = benchmarks;
  BenchmarkSuite.suites.push(this);
}

function BenchmarkSuite ( name , reference , benchmarks ) { this . name = name ; this . reference = reference ; this . benchmarks = benchmarks ; BenchmarkSuite . suites . push ( this ) ; }

Suites of benchmarks consist of a name and the set of benchmarks in addition to the reference timing that the final score will be based on. This way, all scores are relative to a reference run and higher scores implies better performance.

Suites of benchmarks consist of a name and the set of benchmarks in addition to the reference timing that the final score will be based on . This way all scores are relative to a reference run and higher scores implies better performance .


function RunNextSetup() {
    if (index < length) {
      try {
        suite.benchmarks[index].Setup();
      } catch (e) {
        suite.NotifyError(e);
        return null;
      }
      return RunNextBenchmark;
    }
    suite.NotifyResult();
    return null;
  }

function RunNextSetup ( ) { if ( index < length ) { try { suite . benchmarks [ index ] . Setup ( ) ; } catch ( e ) { suite . NotifyError ( e ) ; return null ; } return RunNextBenchmark ; } suite . NotifyResult ( ) ; return null ; }

Run the setup, the actual benchmark, and the tear down in three separate steps to allow the framework to yield between any of the steps.

Run the setup the actual benchmark and the tear down in three separate steps to allow the framework to yield between any of the steps .


function sendPacket(socket, srcMAC, type, serverIP, yourIP) {
  // Request info option
  const opt55 = {
    id: 55,
    bytes: [
      1, // subnet
      3, // router
      6, // dns
    ],
  };

  let options;
  if (serverIP && yourIP) {
    const opt54 = {
      id: 54,
      bytes: [serverIP.a, serverIP.b, serverIP.c, serverIP.d],
    };
    const opt50 = {
      id: 50,
      bytes: [yourIP.a, yourIP.b, yourIP.c, yourIP.d],
    };
    options = [opt55, opt54, opt50];
  } else {
    options = [opt55];
  }

  const u8 = dhcpPacket.create(type, srcMAC, options);
  socket.send(IP4Address.BROADCAST, 67, u8);
}

function
sendPacket
(
socket
,
srcMAC
,
type
,
serverIP
,
yourIP
)
{
// Request info option
const
opt55
=
{
id
:
55
,
bytes
:
[
1
,
// subnet
3
,
// router
6
,
// dns
]
,
}
;
let
options
;
if
(
serverIP
&&
yourIP
)
{
const
opt54
=
{
id
:
54
,
bytes
:
[
serverIP
.
a
,
serverIP
.
b
,
serverIP
.
c
,
serverIP
.
d
]
,
}
;
const
opt50
=
{
id
:
50
,
bytes
:
[
yourIP
.
a
,
yourIP
.
b
,
yourIP
.
c
,
yourIP
.
d
]
,
}
;
options
=
[
opt55
,
opt54
,
opt50
]
;
}
else
{
options
=
[
opt55
]
;
}
const
u8
=
dhcpPacket
.
create
(
type
,
srcMAC
,
options
)
;
socket
.
send
(
IP4Address
.
BROADCAST
,
67
,
u8
)
;
}


function TimerEvent(label, color, pause, thread_id) {
    assert(thread_id >= 0 && thread_id < kNumThreads, "invalid thread id");
    this.label = label;
    this.color = color;
    this.pause = pause;
    this.ranges = [];
    this.thread_id = thread_id;
    this.index = ++num_timer_event;
  }

function
TimerEvent
(
label
,
color
,
pause
,
thread_id
)
{
assert
(
thread_id
>=
0
&&
thread_id
<
kNumThreads
,
"invalid thread id"
)
;
this
.
label
=
label
;
this
.
color
=
color
;
this
.
pause
=
pause
;
this
.
ranges
=
[
]
;
this
.
thread_id
=
thread_id
;
this
.
index
=
++
num_timer_event
;
}


function(timestamp) {
      int_timestamp = parseInt(timestamp);
      assert(int_timestamp >= last_timestamp, "Inconsistent timestamps.");
      last_timestamp = int_timestamp;
      distortion += distortion_per_entry;
      return int_timestamp / 1000 - distortion;
    }

function
(
timestamp
)
{
int_timestamp
=
parseInt
(
timestamp
)
;
assert
(
int_timestamp
>=
last_timestamp
,
"Inconsistent timestamps."
)
;
last_timestamp
=
int_timestamp
;
distortion
+=
distortion_per_entry
;
return
int_timestamp
/
1000
distortion
;
}


function RegExpGetFlags() {
  if (!IS_RECEIVER(this)) {
    throw MakeTypeError(
        kRegExpNonObject, "RegExp.prototype.flags", TO_STRING(this));
  }
  var result = '';
  if (this.global) result += 'g';
  if (this.ignoreCase) result += 'i';
  if (this.multiline) result += 'm';
  if (this.unicode) result += 'u';
  if (this.sticky) result += 'y';
  return result;
}

function RegExpGetFlags ( ) { if ( ! IS_RECEIVER ( this ) ) { throw MakeTypeError ( kRegExpNonObject , "RegExp.prototype.flags" , TO_STRING ( this ) ) ; } var result = '' ; if ( this . global ) result += 'g' ; if ( this . ignoreCase ) result += 'i' ; if ( this . multiline ) result += 'm' ; if ( this . unicode ) result += 'u' ; if ( this . sticky ) result += 'y' ; return result ; }


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");
}

function
RSASetPublic
(
N
,
E
)
{
if
(
N
!=
&&
E
!=
&&
N
.
length
>
0
&&
E
.
length
>
0
)
{
this
.
n
=
parseBigInt
(
N
,
16
)
;
this
.
e
=
parseInt
(
E
,
16
)
;
}
else
alert
(
"Invalid RSA public key"
)
;
}

Set the public key fields N and e from hex strings


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");
}

function
RSASetPrivate
(
N
,
E
,
D
)
{
if
(
N
!=
&&
E
!=
&&
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"
)
;
}

Set the private key fields N, e, and d from hex strings

Set the private key fields N e and d from hex strings


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]));
}

Returns an intersection of locales and service supported locales.
Parameter locales is treated as a priority list.

Returns an intersection of locales and service supported locales . Parameter locales is treated as a priority list .


function addWEPropertyIfDefined(object, property, value) {
  if (!IS_UNDEFINED(value)) {
    defineWEProperty(object, property, value);
  }
}

function addWEPropertyIfDefined ( object , property , value ) { if ( ! IS_UNDEFINED ( value ) ) { defineWEProperty ( object , property , value ) ; } }

Adds property to an object if the value is not undefined.
Sets configurable descriptor to false.

Adds property to an object if the value is not undefined . Sets configurable descriptor to false .


function addWECPropertyIfDefined(object, property, value) {
  if (!IS_UNDEFINED(value)) {
    defineWECProperty(object, property, value);
  }
}

function addWECPropertyIfDefined ( object , property , value ) { if ( ! IS_UNDEFINED ( value ) ) { defineWECProperty ( object , property , value ) ; } }

Adds property to an object if the value is not undefined.
Sets all descriptors to true.

Adds property to an object if the value is not undefined . Sets all descriptors to true .


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;
}

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 ; }

Returns a string that matches LDML representation of the options object.

Returns a string that matches LDML representation of the options object .


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;
}

Returns object that matches LDML representation of the date.

Returns object that matches LDML representation of the date .


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);
}

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
)
;
}

Returns actual formatted date or fails if date parameter is invalid.

Returns actual formatted date or fails if date parameter is invalid .


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,
  };
}

function
locateAcpiDevice
(
dev
)
{
if
(
!
dev
.
isDevice
(
)
)
{
return
;
}
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
===
)
{
return
;
}
if
(
!
parentDev
.
isDevice
(
)
)
{
return
;
}
if
(
parentDev
.
isRootBridge
(
)
)
{
busId
=
parentDev
.
getRootBridgeBusNumber
(
)
;
return
{
bus
:
busId
,
slot
:
slotId
,
func
:
funcId
,
}
;
}
const
parentLocation
=
locateAcpiDevice
(
parentDev
)
;
if
(
parentLocation
===
)
{
return
;
}
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
;
}
const
bridgeBus
=
pciParent
.
read
(
pciParent
.
bridgeFields
(
)
.
SECONDARY_BUS
)
;
return
{
bus
:
bridgeBus
,
slot
:
slotId
,
func
:
funcId
,
}
;
}

Find ACPI PCI device bus, slot and function

Find ACPI PCI device bus slot and function


function BinaryConstraint(var1, var2, strength) {
  BinaryConstraint.superConstructor.call(this, strength);
  this.v1 = var1;
  this.v2 = var2;
  this.direction = Direction.NONE;
  this.addConstraint();
}

function BinaryConstraint ( var1 , var2 , strength ) { BinaryConstraint . superConstructor . call ( this , strength ) ; this . v1 = var1 ; this . v2 = var2 ; this . direction = Direction . NONE ; this . addConstraint ( ) ; }

Abstract superclass for constraints having two possible output
variables.

Abstract superclass for constraints having two possible output variables .


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;
}

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 ; }


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;
}

Appends the arguments to the end of the array and returns the new length of the array. See ECMA-262, section 15.4.4.7.

Appends the arguments to the end of the array and returns the new length of the array . See ECMA - 262 section 15 . 4 . 4 . 7 .


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);
}

Executes the function once for each element present in the array until it finds one where callback returns true.

Executes the function once for each element present in the array until it finds one where callback returns true .


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);
}

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 ) ; }


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);
}

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 ) ; }


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);
}

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 ) ; }


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);
}

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 ) ; }


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);
}

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 ) ; }


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;
}

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 ; }

21.1.5.1 CreateStringIterator Abstract Operation


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;
}

Returns the mirror for a specified value or object.

@param {value or Object} value the value or object to retreive the mirror for
@param {boolean} transient indicate whether this object is transient and
should not be added to the mirror cache. The default is not transient.
@returns {Mirror} the mirror reflects the passed value or object

Returns the mirror for a specified value or object .


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;
}

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
;
}


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;
}


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;
}


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);
        }
      }

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 ) ; } }

Recursively collects all newly compiled functions that are going into business and should have link to the actual script updated.

Recursively collects all newly compiled functions that are going into business and should have link to the actual script updated .


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
          } );
      }
    };
  }

Returns function that restores breakpoints.

Returns function that restores breakpoints .


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;
  }

From array of function infos that is implicitly a tree creates an actual tree of functions in script.

From array of function infos that is implicitly a tree creates an actual tree of functions in script .


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);
    }

A recursive function that processes internals of a function and all its inner functions. Iterator chunk_it initially points to a chunk that is below function start.

A recursive function that processes internals of a function and all its inner functions . Iterator chunk_it initially points to a chunk that is below function start .


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;
      }
    }

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 ; } }

Finds all SharedFunctionInfos that corresponds to compile info in old version of the script.

Finds all SharedFunctionInfos that corresponds to compile info in old version of the script .


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;
  }

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 ; }

An object describing function compilation details. Its index fields apply to indexes inside array that stores these objects.

An object describing function compilation details . Its index fields apply to indexes inside array that stores these objects .


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;
  }

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
;
}

Compares a function scope heap structure, old and new version, whether it changed or not. Returns explanation if they differ.

Compares a function scope heap structure old and new version whether it changed or not . Returns explanation if they differ .


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);
  }

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
)
;
}

Creates JSON description for a change tree.

Creates JSON description for a change tree .


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;
}

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 ; }

Create a new break point object and add it to the list of break points.

Create a new break point object and add it to the list of break points .


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_ = [];
}

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_
=
;
this
.
break_points_
=
[
]
;
}

Object representing a script break point. The script is referenced by its script name or script id and the break point is represented as line and column.

Object representing a script break point . The script is referenced by its script name or script id and the break point is represented as line and column .


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);
    }
  }
}

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 ) ; } } }

Function called from runtime when a new script is compiled to set any script break points set in this script.

Function called from runtime when a new script is compiled to set any script break points set in this script .


function ArrayToProtocolArray_(array, mirror_serializer) {
  var json = [];
  for (var i = 0; i < array.length; i++) {
    json.push(ValueToProtocolValue_(array[i], mirror_serializer));
  }
  return json;
}

function ArrayToProtocolArray_ ( array , mirror_serializer ) { var json = [ ] ; for ( var i = 0 ; i < array . length ; i ++ ) { json . push ( ValueToProtocolValue_ ( array [ i ] , mirror_serializer ) ) ; } return json ; }

Convert an array to its debugger protocol representation. It will convert
each array element to a protocol value.
@param {Array} array The array to format as protocol array.
@param {MirrorSerializer} mirror_serializer The serializer to use if any
mirror objects are encountered.
@return {Array} Protocol array value.

Convert an array to its debugger protocol representation . It will convert each array element to a protocol value .


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;
}

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
=
;
}
return
json
;
}

Convert a value to its debugger protocol representation.
@param {*} value The value to format as protocol value.
@param {MirrorSerializer} mirror_serializer The serializer to use if any
mirror objects are encountered.
@return {*} Protocol value.

Convert a value to its debugger protocol representation .


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);
  }
}

function
runRichards
(
)
{
var
scheduler
=
new
Scheduler
(
)
;
scheduler
.
addIdleTask
(
ID_IDLE
,
0
,
,
COUNT
)
;
var
queue
=
new
Packet
(
,
ID_WORKER
,
KIND_WORK
)
;
queue
=
new
Packet
(
queue
,
ID_WORKER
,
KIND_WORK
)
;
scheduler
.
addWorkerTask
(
ID_WORKER
,
1000
,
queue
)
;
queue
=
new
Packet
(
,
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
(
,
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
,
)
;
scheduler
.
addDeviceTask
(
ID_DEVICE_B
,
5000
,
)
;
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
)
;
}
}

The Richards benchmark simulates the task dispatcher of an
operating system.

The Richards benchmark simulates the task dispatcher of an operating system .


function Scheduler() {
  this.queueCount = 0;
  this.holdCount = 0;
  this.blocks = new Array(NUMBER_OF_IDS);
  this.list = null;
  this.currentTcb = null;
  this.currentId = null;
}

function Scheduler ( ) { this . queueCount = 0 ; this . holdCount = 0 ; this . blocks = new Array ( NUMBER_OF_IDS ) ; this . list = null ; this . currentTcb = null ; this . currentId = null ; }

A scheduler can be used to schedule a set of tasks based on their relative
priorities.  Scheduling is done by maintaining a list of task control blocks
which holds tasks and the data queue they are processing.
@constructor

A scheduler can be used to schedule a set of tasks based on their relative priorities . Scheduling is done by maintaining a list of task control blocks which holds tasks and the data queue they are processing .


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;
  }
}

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 ; } }

A task control block manages a task and the queue of work packages associated
with it.
@param {TaskControlBlock} link the preceding block in the linked block list
@param {int} id the id of this block
@param {int} priority the priority of this block
@param {Packet} queue the queue of packages to be processed by the task
@param {Task} task the task
@constructor

A task control block manages a task and the queue of work packages associated with it .


function IdleTask(scheduler, v1, count) {
  this.scheduler = scheduler;
  this.v1 = v1;
  this.count = count;
}

function IdleTask ( scheduler , v1 , count ) { this . scheduler = scheduler ; this . v1 = v1 ; this . count = count ; }

An idle task doesn't do any work itself but cycles control between the two
device tasks.
@param {Scheduler} scheduler the scheduler that manages this task
@param {int} v1 a seed value that controls how the device tasks are scheduled
@param {int} count the number of times this task should be scheduled
@constructor

An idle task doesn t do any work itself but cycles control between the two device tasks .


function WorkerTask(scheduler, v1, v2) {
  this.scheduler = scheduler;
  this.v1 = v1;
  this.v2 = v2;
}

function WorkerTask ( scheduler , v1 , v2 ) { this . scheduler = scheduler ; this . v1 = v1 ; this . v2 = v2 ; }

A task that manipulates work packets.
@param {Scheduler} scheduler the scheduler that manages this task
@param {int} v1 a seed used to specify how work packets are manipulated
@param {int} v2 another seed used to specify how work packets are manipulated
@constructor


function Packet(link, id, kind) {
  this.link = link;
  this.id = id;
  this.kind = kind;
  this.a1 = 0;
  this.a2 = new Array(DATA_SIZE);
}

function Packet ( link , id , kind ) { this . link = link ; this . id = id ; this . kind = kind ; this . a1 = 0 ; this . a2 = new Array ( DATA_SIZE ) ; }

A simple package of data that is manipulated by the tasks.  The exact layout
of the payload data carried by a packet is not importaint, and neither is the
nature of the work performed on packets by the tasks.

Besides carrying data, packets form linked lists and are hence used both as
data and worklists.
@param {Packet} link the tail of the linked list of packets
@param {int} id an ID for this packet
@param {int} kind the type of this packet
@constructor

A simple package of data that is manipulated by the tasks . The exact layout of the payload data carried by a packet is not importaint and neither is the nature of the work performed on packets by the tasks .


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;
}

function
ccallFunc
(
func
,
returnType
,
argTypes
,
args
)
{
var
stack
=
0
;
function
toC
(
value
,
type
)
{
if
(
type
==
'string'
)
{
if
(
value
===
||
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
(
,
cArgs
)
,
returnType
)
;
if
(
stack
)
Runtime
.
stackRestore
(
stack
)
;
return
ret
;
}

Internal function that does a C call using a function, not an identifier

Internal function that does a C call using a function not an identifier


function addPreRun(func) {
  if (!Module['preRun']) Module['preRun'] = [];
  else if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
  Module['preRun'].push(func);
}

function addPreRun ( func ) { if ( ! Module [ 'preRun' ] ) Module [ 'preRun' ] = [ ] ; else if ( typeof Module [ 'preRun' ] == 'function' ) Module [ 'preRun' ] = [ Module [ 'preRun' ] ] ; Module [ 'preRun' ] . push ( func ) ; }


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)
}

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 ) }

Retrieves the main module package.json information.

@param {string} directory
The directory to start looking in.

@return {Object|null}
An object containing the package.json contents or NULL if it could not be found.

Retrieves the main module package . json information .


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)))
}

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 ) ) ) }


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
}

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 }

path resolver taking in account file structure


function areEquivalent(s1, s2, table, alphabet) {
  for (const symbol of alphabet) {
    if (!goToSameSet(s1, s2, table, symbol)) {
      return false;
    }
  }
  return true;
}

function areEquivalent ( s1 , s2 , table , alphabet ) { for ( const symbol of alphabet ) { if ( ! goToSameSet ( s1 , s2 , table , symbol ) ) { return false ; } } return true ; }

Checks whether two states are N-equivalent, i.e. whether they go
to the same set on a symbol.

Checks whether two states are N - equivalent i . e . whether they go to the same set on a symbol .


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);
}

Checks whether states go to the same set.

Checks whether states go to the same set .


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
  );
}

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 ) ; }

Checks if a range is included either in 0-9, a-z or A-Z
@param classRange
@returns {boolean}

Checks if a range is included either in 0 - 9 a - z or A - Z


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;
}

function getRange ( text ) { const range = text . match ( / \d+ / g ) . map ( Number ) ; if ( Number . isFinite ( range [ 1 ] ) && range [ 1 ] < range [ 0 ] ) { throw new SyntaxError ( ` ${ text } ` ) ; } return range ; }


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`);
  }
}

function checkClassRange ( from , to ) { if ( from . kind === 'control' || to . kind === 'control' || ( ! isNaN ( from . codePoint ) && ! isNaN ( to . codePoint ) && from . codePoint > to . codePoint ) ) { throw new SyntaxError ( ` ${ from . value } ${ to . value } ` ) ; } }


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);
}

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 ( ` ${ 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 ) ; }


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('');
}

function checkFlags ( flags ) { const seen = new Set ( ) ; for ( const flag of flags ) { if ( seen . has ( flag ) || ! validFlags . includes ( flag ) ) { throw new SyntaxError ( ` ${ flags } ` ) ; } seen . add ( flag ) ; } return flags . split ( '' ) . sort ( ) . join ( '' ) ; }

Checks the flags are valid, and that
we don't duplicate flags.

Checks the flags are valid and that we don t duplicate flags .


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);
}

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 ) ; }

Parses patterns like \1, \2, etc. either as a backreference
to a group, or a deciaml char code.

Parses patterns like \ 1 \ 2 etc . either as a backreference to a group or a deciaml char code .


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.`);
  }
}

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 ( ` ${ name } \` \` ` ) ; } }


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;
}

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 ; }


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,
  };
}

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 , } ; }


function isMeta(expression, value = null) {
  return expression.type === 'Char' &&
    expression.kind === 'meta' &&
    (value ? expression.value === value : /^\\[dws]$/i.test(expression.value));
}

function isMeta ( expression , value = null ) { return expression . type === 'Char' && expression . kind === 'meta' && ( value ? expression . value === value : / ^\\[dws]$ / i . test ( expression . value ) ) ; }

Checks if a node is a meta char from the set \d\w\s\D\W\S
@param {Object} expression - Char or ClassRange node
@param {?string} value
@returns {boolean}

Checks if a node is a meta char from the set \ d \ w \ s \ D \ W \ S


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);
}

Does an actual AST traversal, using visitor pattern,
and calling set of callbacks.

Based on https://github.com/olov/ast-traverse

Expects AST in Mozilla Parser API: nodes which are supposed to be
handled should have `type` property.

@param Object root - a root node to start traversal from.

@param Object options - an object with set of callbacks:

- `pre(node, parent, prop, index)` - a hook called on node enter
- `post`(node, parent, prop, index) - a hook called on node exit
- `skipProperty(prop)` - a predicated whether a property should be skipped

Does an actual AST traversal using visitor pattern and calling set of callbacks .


function alt(first, ...fragments) {
  for (let fragment of fragments) {
    first = altPair(first, fragment);
  }
  return first;
}

function alt ( first , ... fragments ) { for ( let fragment of fragments ) { first = altPair ( first , fragment ) ; } return first ; }

Alteration factory.

Creates a alteration NFA for (at least) two NFA-fragments.


function or(first, ...fragments) {
  for (let fragment of fragments) {
    first = orPair(first, fragment);
  }
  return first;
}

function or ( first , ... fragments ) { for ( let fragment of fragments ) { first = orPair ( first , fragment ) ; } return first ; }

Disjunction factory.

Creates a disjunction NFA for (at least) two NFA-fragments.


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) : '';
}

function gen ( node ) { if ( node && ! generator [ node . type ] ) { throw new Error ( ` ${ node . type } ` ) ; } return node ? generator [ node . type ] ( node ) : '' ; }

Helper `gen` function calls node type handler.

Helper gen function calls node type handler .


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);
}

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
)
;
}


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;
}

function disjunctionToList ( node ) { if ( node . type !== 'Disjunction' ) { throw new TypeError ( ` ${ 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 ; }

Flattens a nested disjunction node to a list.

/a|b|c|d/

{{{a, b}, c}, d} -> [a, b, c, d]

Flattens a nested disjunction node to a list .


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);
}

Installs a compatible password hashing function.
@public
@param {string} name The name of the password hashing function.
@param {Object} algorithm The password hashing function object.
@param {Function} algorithm.hash A function that takes a password and returns
a cryptographically secure password hash string.
@param {Function} algorithm.verify A function that takes a secure password
hash string and a password and returns whether or not the password is valid
for the given hash string.
@param {Function} algorithm.identifiers A function that returns the list of
identifiers that this password hashing algorithm is able to generate / verify.

Installs a compatible password hashing function .


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);
}

Uninstalls a password hashing function previously installed.
@public
@param {string} name The name of the algorithm to uninstall or 'last' to
uninstall the last one installed.

Uninstalls a password hashing function previously installed .


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;
}

Selects manually which password hashing function to use.
You can call hash and verify on the object returned.
@public
@param {string|undefined} name The name of the algorithm to use.
@return {Object} The password hashing function object.

Selects manually which password hashing function to use . You can call hash and verify on the object returned .


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;
}

Returns the name of the algorithm that has generated the hash string.
@public
@param {string} hashstr Secure hash string generated from this package.
@return {string|null} The name of password hashing algorithm.

Returns the name of the algorithm that has generated the hash string .


function verify(hashstr, password) {
  const name = which(hashstr);

  if (name === null) {
    throw new TypeError('No compatible algorithm installed.');
  }

  return use(name).verify(hashstr, password);
}

function
verify
(
hashstr
,
password
)
{
const
name
=
which
(
hashstr
)
;
if
(
name
===
)
{
throw
new
TypeError
(
'No compatible algorithm installed.'
)
;
}
return
use
(
name
)
.
verify
(
hashstr
,
password
)
;
}

Determines whether or not the hash provided matches the hash generated for
the given password choosing the right algorithm based on the identifier
contained in the hash.
@public
@param {string} hashstr Secure hash string generated from this package.
@param {string} password User's password input.
@returns {Promise.<boolean>} A boolean that is true if the hash computed
for the password matches.

Determines whether or not the hash provided matches the hash generated for the given password choosing the right algorithm based on the identifier contained in the hash .


function sanitizeProps(props, toRemove) {
  props = {...props};
  for (let i = 0, l = toRemove.length; i < l; i += 1) {
    delete props[toRemove[i]]
  }
  return props;
}

function sanitizeProps ( props , toRemove ) { props = { ... props } ; for ( let i = 0 , l = toRemove . length ; i < l ; i += 1 ) { delete props [ toRemove [ i ] ] } return props ; }

Simply removes all unwanted props in order to avoid react 'unkown prop' warning
@param  {Object} props     that should be sanitized
@param  {Object} toRemove  array of prop names to remove
@return {Object}           cloned and sanitized props

Simply removes all unwanted props in order to avoid react unkown prop warning


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
}

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 }

Gets the current list of possible servers in the local networks.

Gets the current list of possible servers in the local networks .


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)
    }
  })
}

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 ) } } ) }

Pings and individual server to update the arp table.

Pings and individual server to update the arp table .


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)
}

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 ) }

Parses arp scan data into a useable collection.

Parses arp scan data into a useable collection .


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)
}


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)
    }
}


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;
	}

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 ; }


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;
  }

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 ; }

This class scrolls a page from the top to the bottom once.  The page is scrolled down by a single scroll gesture.

This class scrolls a page from the top to the bottom once . The page is scrolled down by a single scroll gesture .


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;
}

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 ; }


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
  }
}


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
  )
}

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
(
,
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
)
}

returns a promise with available new versions


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);
        }
    }
}

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 ) ; } } }


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);
        });
      }

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
(
,
data
)
;
}
)
;
}