code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function generateTransformOrigin(x, y) {
return x + 'px ' + y + 'px';
} | Transform to string
@param x
@param y
@returns {string} | generateTransformOrigin | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function getTouches(touches) {
return Array.prototype.slice.call(touches).map(function (touch) {
return {
left: touch.pageX,
top: touch.pageY
};
});
} | Get touch pointer
@param touches
@returns {Array} | getTouches | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function calculateScale(start, end) {
var startDistance = getDistance(start[0], start[1]);
var endDistance = getDistance(end[0], end[1]);
return endDistance / startDistance;
} | Get scale
@param start
@param end
@returns {number} | calculateScale | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function getComputedTranslate(obj) {
var result = {
translateX: 0,
translateY: 0,
translateZ: 0,
scaleX: 1,
scaleY: 1,
offsetX: 0,
offsetY: 0
};
var offsetX = 0, offsetY = 0;
if (!global.getComputedStyle || !obj) return result;
var style = global.getComputedStyle(obj), transform, origin;
transform = style.webkitTransform || style.mozTransform;
origin = style.webkitTransformOrigin || style.mozTransformOrigin;
var par = origin.match(/(.*)px\s+(.*)px/);
if (par.length > 1) {
offsetX = par[1] - 0;
offsetY = par[2] - 0;
}
if (transform === 'none') return result;
var mat3d = transform.match(/^matrix3d\((.+)\)$/);
var mat2d = transform.match(/^matrix\((.+)\)$/);
var str;
if (mat3d) {
str = mat3d[1].split(', ');
result = {
translateX: str[12] - 0,
translateY: str[13] - 0,
translateZ: str[14] - 0,
offsetX: offsetX - 0,
offsetY: offsetY - 0,
scaleX: str[0] - 0,
scaleY: str[5] - 0,
scaleZ: str[10] - 0
};
} else if (mat2d) {
str = mat2d[1].split(', ');
result = {
translateX: str[4] - 0,
translateY: str[5] - 0,
offsetX: offsetX - 0,
offsetY: offsetY - 0,
scaleX: str[0] - 0,
scaleY: str[3] - 0
};
}
return result;
} | Get computed translate
@param obj
@returns {{translateX: number, translateY: number, translateZ: number, scaleX: number, scaleY: number, offsetX: number, offsetY: number}} | getComputedTranslate | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function getCenter(a, b) {
return {
x: (a.x + b.x) / 2,
y: (a.y + b.y) / 2
};
} | Get center point
@param a
@param b
@returns {{x: number, y: number}} | getCenter | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function startHandler(evt) {
startHandlerOriginal.call(this, evt);
// must be a picture, only one picture!!
var node = this.els[1].querySelector('img:first-child');
var device = this.deviceEvents;
if (device.hasTouch && node !== null) {
IN_SCALE_MODE = true;
var transform = getComputedTranslate(node);
startTouches = getTouches(evt.targetTouches);
startX = transform.translateX - 0;
startY = transform.translateY - 0;
currentScale = transform.scaleX;
zoomNode = node;
var pos = getPosition(node);
if (evt.targetTouches.length == 2) {
lastTouchStart = null;
var touches = evt.touches;
var touchCenter = getCenter({
x: touches[0].pageX,
y: touches[0].pageY
}, {
x: touches[1].pageX,
y: touches[1].pageY
});
node.style.webkitTransformOrigin = generateTransformOrigin(touchCenter.x - pos.left, touchCenter.y - pos.top);
} else if (evt.targetTouches.length === 1) {
var time = (new Date()).getTime();
gesture = 0;
if (time - lastTouchStart < 300) {
evt.preventDefault();
gesture = 3;
}
lastTouchStart = time;
}
}
} | Start event handle
@param {object} evt | startHandler | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function moveHandler(evt) {
if (IN_SCALE_MODE) {
var result = 0;
var node = zoomNode;
var device = this.deviceEvents;
if (device.hasTouch) {
if (evt.targetTouches.length === 2) {
node.style.webkitTransitionDuration = '0';
evt.preventDefault();
scaleImage(evt);
result = 2;
} else if (evt.targetTouches.length === 1 && currentScale > 1) {
node.style.webkitTransitionDuration = '0';
evt.preventDefault();
moveImage.call(this, evt);
result = 1;
}
gesture = result;
if (result > 0) {
return;
}
}
}
moveHandlerOriginal.call(this, evt);
} | Move event handle
@param {object} evt
@returns {number} | moveHandler | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function handleDoubleTap(evt) {
var zoomFactor = zoomFactor || 2;
var node = zoomNode;
var pos = getPosition(node);
currentScale = currentScale == 1 ? zoomFactor : 1;
node.style.webkitTransform = generateTranslate(0, 0, 0, currentScale);
if (currentScale != 1) node.style.webkitTransformOrigin = generateTransformOrigin(evt.touches[0].pageX - pos.left, evt.touches[0].pageY - pos.top);
} | Double tao handle
@param {object} evt | handleDoubleTap | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function getPosition(element) {
var pos = {'left': 0, 'top': 0};
do {
pos.top += element.offsetTop || 0;
pos.left += element.offsetLeft || 0;
element = element.offsetParent;
}
while (element);
return pos;
} | Get position
@param element
@returns {{left: number, top: number}} | getPosition | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function valueInViewScope(node, value, tag) {
var min, max;
var pos = getPosition(node);
viewScope = {
start: {left: pos.left, top: pos.top},
end: {left: pos.left + node.clientWidth, top: pos.top + node.clientHeight}
};
var str = tag == 1 ? 'left' : 'top';
min = viewScope.start[str];
max = viewScope.end[str];
return (value >= min && value <= max);
} | Check target is in range
@param node
@param value
@param tag
@returns {boolean} | valueInViewScope | javascript | be-fe/iSlider | src/js/plugins/zoompic.js | https://github.com/be-fe/iSlider/blob/master/src/js/plugins/zoompic.js | MIT |
function error(type) {
throw new RangeError(errors[type]);
} | A generic error utility function.
@private
@param {String} type The error type.
@returns {Error} Throws a `RangeError` with the applicable error message. | error | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
function map(array, fn) {
var result = [];
var length = array.length;
while (length--) {
result[length] = fn(array[length]);
}
return result;
} | A generic `Array#map` utility function.
@private
@param {Array} array The array to iterate over.
@param {Function} callback The function that gets called for every array
item.
@returns {Array} A new array of values returned by the callback function. | map | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
function mapDomain(string, fn) {
var parts = string.split('@');
var result = '';
if (parts.length > 1) {
// In email addresses, only the domain name should be punycoded. Leave
// the local part (i.e. everything up to `@`) intact.
result = parts[0] + '@';
string = parts[1];
}
// Avoid `split(regex)` for IE8 compatibility. See #17.
string = string.replace(regexSeparators, '\x2E');
var labels = string.split('.');
var encoded = map(labels, fn).join('.');
return result + encoded;
} | A simple `Array#map`-like wrapper to work with domain name strings or email
addresses.
@private
@param {String} domain The domain name or email address.
@param {Function} callback The function that gets called for every
character.
@returns {Array} A new string of characters returned by the callback
function. | mapDomain | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
function ucs2decode(string) {
var output = [];
var counter = 0;
var length = string.length;
while (counter < length) {
var value = string.charCodeAt(counter++);
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
// It's a high surrogate, and there is a next character.
var extra = string.charCodeAt(counter++);
if ((extra & 0xFC00) == 0xDC00) {
// Low surrogate.
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
} else {
// It's an unmatched surrogate; only append this code unit, in case the
// next code unit is the high surrogate of a surrogate pair.
output.push(value);
counter--;
}
} else {
output.push(value);
}
}
return output;
} | Creates an array containing the numeric code points of each Unicode
character in the string. While JavaScript uses UCS-2 internally,
this function will convert a pair of surrogate halves (each of which
UCS-2 exposes as separate characters) into a single code point,
matching UTF-16.
@see `punycode.ucs2.encode`
@see <https://mathiasbynens.be/notes/javascript-encoding>
@memberOf punycode.ucs2
@name decode
@param {String} string The Unicode input string (UCS-2).
@returns {Array} The new array of code points. | ucs2decode | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
ucs2encode = function ucs2encode(array) {
return String.fromCodePoint.apply(String, _toConsumableArray(array));
} | Creates a string based on an array of numeric code points.
@see `punycode.ucs2.decode`
@memberOf punycode.ucs2
@name encode
@param {Array} codePoints The array of numeric code points.
@returns {String} The new Unicode string (UCS-2). | ucs2encode | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
basicToDigit = function basicToDigit(codePoint) {
if (codePoint - 0x30 < 0x0A) {
return codePoint - 0x16;
}
if (codePoint - 0x41 < 0x1A) {
return codePoint - 0x41;
}
if (codePoint - 0x61 < 0x1A) {
return codePoint - 0x61;
}
return base;
} | Converts a basic code point into a digit/integer.
@see `digitToBasic()`
@private
@param {Number} codePoint The basic numeric code point value.
@returns {Number} The numeric value of a basic code point (for use in
representing integers) in the range `0` to `base - 1`, or `base` if
the code point does not represent a value. | basicToDigit | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
digitToBasic = function digitToBasic(digit, flag) {
// 0..25 map to ASCII a..z or A..Z
// 26..35 map to ASCII 0..9
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
} | Converts a digit/integer into a basic code point.
@see `basicToDigit()`
@private
@param {Number} digit The numeric value of a basic code point.
@returns {Number} The basic code point whose value (when used for
representing integers) is `digit`, which needs to be in the range
`0` to `base - 1`. If `flag` is non-zero, the uppercase form is
used; else, the lowercase form is used. The behavior is undefined
if `flag` is non-zero and `digit` has no uppercase form. | digitToBasic | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
adapt = function adapt(delta, numPoints, firstTime) {
var k = 0;
delta = firstTime ? floor(delta / damp) : delta >> 1;
delta += floor(delta / numPoints);
for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) {
delta = floor(delta / baseMinusTMin);
}
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
} | Bias adaptation function as per section 3.4 of RFC 3492.
https://tools.ietf.org/html/rfc3492#section-3.4
@private | adapt | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
decode = function decode(input) {
// Don't use UCS-2.
var output = [];
var inputLength = input.length;
var i = 0;
var n = initialN;
var bias = initialBias;
// Handle the basic code points: let `basic` be the number of input code
// points before the last delimiter, or `0` if there is none, then copy
// the first basic code points to the output.
var basic = input.lastIndexOf(delimiter);
if (basic < 0) {
basic = 0;
}
for (var j = 0; j < basic; ++j) {
// if it's not a basic code point
if (input.charCodeAt(j) >= 0x80) {
error('not-basic');
}
output.push(input.charCodeAt(j));
}
// Main decoding loop: start just after the last delimiter if any basic code
// points were copied; start at the beginning otherwise.
for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{
// `index` is the index of the next character to be consumed.
// Decode a generalized variable-length integer into `delta`,
// which gets added to `i`. The overflow checking is easier
// if we increase `i` as we go, then subtract off its starting
// value at the end to obtain `delta`.
var oldi = i;
for (var w = 1, k = base;; /* no condition */k += base) {
if (index >= inputLength) {
error('invalid-input');
}
var digit = basicToDigit(input.charCodeAt(index++));
if (digit >= base || digit > floor((maxInt - i) / w)) {
error('overflow');
}
i += digit * w;
var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
if (digit < t) {
break;
}
var baseMinusT = base - t;
if (w > floor(maxInt / baseMinusT)) {
error('overflow');
}
w *= baseMinusT;
}
var out = output.length + 1;
bias = adapt(i - oldi, out, oldi == 0);
// `i` was supposed to wrap around from `out` to `0`,
// incrementing `n` each time, so we'll fix that now:
if (floor(i / out) > maxInt - n) {
error('overflow');
}
n += floor(i / out);
i %= out;
// Insert `n` at position `i` of the output.
output.splice(i++, 0, n);
}
return String.fromCodePoint.apply(String, output);
} | Converts a Punycode string of ASCII-only symbols to a string of Unicode
symbols.
@memberOf punycode
@param {String} input The Punycode string of ASCII-only symbols.
@returns {String} The resulting string of Unicode symbols. | decode | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
encode = function encode(input) {
var output = [];
// Convert the input in UCS-2 to an array of Unicode code points.
input = ucs2decode(input);
// Cache the length.
var inputLength = input.length;
// Initialize the state.
var n = initialN;
var delta = 0;
var bias = initialBias;
// Handle the basic code points.
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _currentValue2 = _step.value;
if (_currentValue2 < 0x80) {
output.push(stringFromCharCode(_currentValue2));
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var basicLength = output.length;
var handledCPCount = basicLength;
// `handledCPCount` is the number of code points that have been handled;
// `basicLength` is the number of basic code points.
// Finish the basic string with a delimiter unless it's empty.
if (basicLength) {
output.push(delimiter);
}
// Main encoding loop:
while (handledCPCount < inputLength) {
// All non-basic code points < n have been handled already. Find the next
// larger one:
var m = maxInt;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var currentValue = _step2.value;
if (currentValue >= n && currentValue < m) {
m = currentValue;
}
}
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
// but guard against overflow.
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
var handledCPCountPlusOne = handledCPCount + 1;
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
error('overflow');
}
delta += (m - n) * handledCPCountPlusOne;
n = m;
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var _currentValue = _step3.value;
if (_currentValue < n && ++delta > maxInt) {
error('overflow');
}
if (_currentValue == n) {
// Represent delta as a generalized variable-length integer.
var q = delta;
for (var k = base;; /* no condition */k += base) {
var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
if (q < t) {
break;
}
var qMinusT = q - t;
var baseMinusT = base - t;
output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
q = floor(qMinusT / baseMinusT);
}
output.push(stringFromCharCode(digitToBasic(q, 0)));
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
delta = 0;
++handledCPCount;
}
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
++delta;
++n;
}
return output.join('');
} | Converts a string of Unicode symbols (e.g. a domain name label) to a
Punycode string of ASCII-only symbols.
@memberOf punycode
@param {String} input The string of Unicode symbols.
@returns {String} The resulting Punycode string of ASCII-only symbols. | encode | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
toUnicode = function toUnicode(input) {
return mapDomain(input, function (string) {
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
});
} | Converts a Punycode string representing a domain name or an email address
to Unicode. Only the Punycoded parts of the input will be converted, i.e.
it doesn't matter if you call it on a string that has already been
converted to Unicode.
@memberOf punycode
@param {String} input The Punycoded domain name or email address to
convert to Unicode.
@returns {String} The Unicode representation of the given Punycode
string. | toUnicode | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
toASCII = function toASCII(input) {
return mapDomain(input, function (string) {
return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
});
} | Converts a Unicode string representing a domain name or an email address to
Punycode. Only the non-ASCII parts of the domain name will be converted,
i.e. it doesn't matter if you call it with a domain that's already in
ASCII.
@memberOf punycode
@param {String} input The domain name or email address to convert, as a
Unicode string.
@returns {String} The Punycode representation of the given domain name or
email address. | toASCII | javascript | amol-/dukpy | dukpy/jscore/punycode.js | https://github.com/amol-/dukpy/blob/master/dukpy/jscore/punycode.js | MIT |
function createFileMap(keyMapper) {
var files = {};
return {
get: get,
set: set,
contains: contains,
remove: remove,
forEachValue: forEachValueInMap,
clear: clear
};
function forEachValueInMap(f) {
for (var key in files) {
f(key, files[key]);
}
}
// path should already be well-formed so it does not need to be normalized
function get(path) {
return files[toKey(path)];
}
function set(path, value) {
files[toKey(path)] = value;
}
function contains(path) {
return hasProperty(files, toKey(path));
}
function remove(path) {
var key = toKey(path);
delete files[key];
}
function clear() {
files = {};
}
function toKey(path) {
return keyMapper ? keyMapper(path) : path;
}
} | Ternary values are defined such that
x & y is False if either x or y is False.
x & y is Maybe if either x or y is Maybe, but neither x or y is False.
x & y is True if both x and y are True.
x | y is False if both x and y are False.
x | y is Maybe if either x or y is Maybe, but neither x or y is True.
x | y is True if either x or y is True. | createFileMap | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function forEachValueInMap(f) {
for (var key in files) {
f(key, files[key]);
}
} | Ternary values are defined such that
x & y is False if either x or y is False.
x & y is Maybe if either x or y is Maybe, but neither x or y is False.
x & y is True if both x and y are True.
x | y is False if both x and y are False.
x | y is Maybe if either x or y is Maybe, but neither x or y is True.
x | y is True if either x or y is True. | forEachValueInMap | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function get(path) {
return files[toKey(path)];
} | Ternary values are defined such that
x & y is False if either x or y is False.
x & y is Maybe if either x or y is Maybe, but neither x or y is False.
x & y is True if both x and y are True.
x | y is False if both x and y are False.
x | y is Maybe if either x or y is Maybe, but neither x or y is True.
x | y is True if either x or y is True. | get | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function set(path, value) {
files[toKey(path)] = value;
} | Ternary values are defined such that
x & y is False if either x or y is False.
x & y is Maybe if either x or y is Maybe, but neither x or y is False.
x & y is True if both x and y are True.
x | y is False if both x and y are False.
x | y is Maybe if either x or y is Maybe, but neither x or y is True.
x | y is True if either x or y is True. | set | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function contains(path) {
return hasProperty(files, toKey(path));
} | Ternary values are defined such that
x & y is False if either x or y is False.
x & y is Maybe if either x or y is Maybe, but neither x or y is False.
x & y is True if both x and y are True.
x | y is False if both x and y are False.
x | y is Maybe if either x or y is Maybe, but neither x or y is True.
x | y is True if either x or y is True. | contains | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function remove(path) {
var key = toKey(path);
delete files[key];
} | Ternary values are defined such that
x & y is False if either x or y is False.
x & y is Maybe if either x or y is Maybe, but neither x or y is False.
x & y is True if both x and y are True.
x | y is False if both x and y are False.
x | y is Maybe if either x or y is Maybe, but neither x or y is True.
x | y is True if either x or y is True. | remove | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function clear() {
files = {};
} | Ternary values are defined such that
x & y is False if either x or y is False.
x & y is Maybe if either x or y is Maybe, but neither x or y is False.
x & y is True if both x and y are True.
x | y is False if both x and y are False.
x | y is Maybe if either x or y is Maybe, but neither x or y is True.
x | y is True if either x or y is True. | clear | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function toKey(path) {
return keyMapper ? keyMapper(path) : path;
} | Ternary values are defined such that
x & y is False if either x or y is False.
x & y is Maybe if either x or y is Maybe, but neither x or y is False.
x & y is True if both x and y are True.
x | y is False if both x and y are False.
x | y is Maybe if either x or y is Maybe, but neither x or y is True.
x | y is True if either x or y is True. | toKey | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function toPath(fileName, basePath, getCanonicalFileName) {
var nonCanonicalizedPath = isRootedDiskPath(fileName)
? normalizePath(fileName)
: getNormalizedAbsolutePath(fileName, basePath);
return getCanonicalFileName(nonCanonicalizedPath);
} | Ternary values are defined such that
x & y is False if either x or y is False.
x & y is Maybe if either x or y is Maybe, but neither x or y is False.
x & y is True if both x and y are True.
x | y is False if both x and y are False.
x | y is Maybe if either x or y is Maybe, but neither x or y is True.
x | y is True if either x or y is True. | toPath | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function contains(array, value) {
if (array) {
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
var v = array_1[_i];
if (v === value) {
return true;
}
}
}
return false;
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | contains | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function indexOf(array, value) {
if (array) {
for (var i = 0, len = array.length; i < len; i++) {
if (array[i] === value) {
return i;
}
}
}
return -1;
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | indexOf | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function countWhere(array, predicate) {
var count = 0;
if (array) {
for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {
var v = array_2[_i];
if (predicate(v)) {
count++;
}
}
}
return count;
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | countWhere | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function filter(array, f) {
var result;
if (array) {
result = [];
for (var _i = 0, array_3 = array; _i < array_3.length; _i++) {
var item = array_3[_i];
if (f(item)) {
result.push(item);
}
}
}
return result;
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | filter | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function map(array, f) {
var result;
if (array) {
result = [];
for (var _i = 0, array_4 = array; _i < array_4.length; _i++) {
var v = array_4[_i];
result.push(f(v));
}
}
return result;
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | map | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function concatenate(array1, array2) {
if (!array2 || !array2.length)
return array1;
if (!array1 || !array1.length)
return array2;
return array1.concat(array2);
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | concatenate | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function deduplicate(array) {
var result;
if (array) {
result = [];
for (var _i = 0, array_5 = array; _i < array_5.length; _i++) {
var item = array_5[_i];
if (!contains(result, item)) {
result.push(item);
}
}
}
return result;
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | deduplicate | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function sum(array, prop) {
var result = 0;
for (var _i = 0, array_6 = array; _i < array_6.length; _i++) {
var v = array_6[_i];
result += v[prop];
}
return result;
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | sum | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function addRange(to, from) {
if (to && from) {
for (var _i = 0, from_1 = from; _i < from_1.length; _i++) {
var v = from_1[_i];
to.push(v);
}
}
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | addRange | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function rangeEquals(array1, array2, pos, end) {
while (pos < end) {
if (array1[pos] !== array2[pos]) {
return false;
}
pos++;
}
return true;
} | Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned. | rangeEquals | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function lastOrUndefined(array) {
if (array.length === 0) {
return undefined;
}
return array[array.length - 1];
} | Returns the last element of an array if non-empty, undefined otherwise. | lastOrUndefined | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function reduceLeft(array, f, initial) {
if (array) {
var count = array.length;
if (count > 0) {
var pos = 0;
var result = arguments.length <= 2 ? array[pos++] : initial;
while (pos < count) {
result = f(result, array[pos++]);
}
return result;
}
}
return initial;
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | reduceLeft | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function reduceRight(array, f, initial) {
if (array) {
var pos = array.length - 1;
if (pos >= 0) {
var result = arguments.length <= 2 ? array[pos--] : initial;
while (pos >= 0) {
result = f(result, array[pos--]);
}
return result;
}
}
return initial;
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | reduceRight | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function hasProperty(map, key) {
return hasOwnProperty.call(map, key);
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | hasProperty | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getProperty(map, key) {
return hasOwnProperty.call(map, key) ? map[key] : undefined;
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | getProperty | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isEmpty(map) {
for (var id in map) {
if (hasProperty(map, id)) {
return false;
}
}
return true;
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | isEmpty | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function clone(object) {
var result = {};
for (var id in object) {
result[id] = object[id];
}
return result;
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | clone | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function extend(first, second) {
var result = {};
for (var id in first) {
result[id] = first[id];
}
for (var id in second) {
if (!hasProperty(result, id)) {
result[id] = second[id];
}
}
return result;
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | extend | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function forEachValue(map, callback) {
var result;
for (var id in map) {
if (result = callback(map[id]))
break;
}
return result;
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | forEachValue | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function forEachKey(map, callback) {
var result;
for (var id in map) {
if (result = callback(id))
break;
}
return result;
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | forEachKey | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function lookUp(map, key) {
return hasProperty(map, key) ? map[key] : undefined;
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | lookUp | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function copyMap(source, target) {
for (var p in source) {
target[p] = source[p];
}
} | Performs a binary search, finding the index at which 'value' occurs in 'array'.
If no such index is found, returns the 2's-complement of first index at which
number[index] exceeds number.
@param array A sorted array whose first element must be no larger than number
@param number The value to be searched for in the array. | copyMap | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function memoize(callback) {
var value;
return function () {
if (callback) {
value = callback();
callback = undefined;
}
return value;
};
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | memoize | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function formatStringFromArgs(text, args, baseIndex) {
baseIndex = baseIndex || 0;
return text.replace(/\{(\d+)\}/g, function (match, index) { return args[+index + baseIndex]; });
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | formatStringFromArgs | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getLocaleSpecificMessage(message) {
return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key]
? ts.localizedDiagnosticMessages[message.key]
: message.message;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getLocaleSpecificMessage | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createFileDiagnostic(file, start, length, message) {
var end = start + length;
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
if (file) {
Debug.assert(start <= file.text.length, "start must be within the bounds of the file. " + start + " > " + file.text.length);
Debug.assert(end <= file.text.length, "end must be the bounds of the file. " + end + " > " + file.text.length);
}
var text = getLocaleSpecificMessage(message);
if (arguments.length > 4) {
text = formatStringFromArgs(text, arguments, 4);
}
return {
file: file,
start: start,
length: length,
messageText: text,
category: message.category,
code: message.code
};
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | createFileDiagnostic | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createCompilerDiagnostic(message) {
var text = getLocaleSpecificMessage(message);
if (arguments.length > 1) {
text = formatStringFromArgs(text, arguments, 1);
}
return {
file: undefined,
start: undefined,
length: undefined,
messageText: text,
category: message.category,
code: message.code
};
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | createCompilerDiagnostic | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function chainDiagnosticMessages(details, message) {
var text = getLocaleSpecificMessage(message);
if (arguments.length > 2) {
text = formatStringFromArgs(text, arguments, 2);
}
return {
messageText: text,
category: message.category,
code: message.code,
next: details
};
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | chainDiagnosticMessages | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function concatenateDiagnosticMessageChains(headChain, tailChain) {
var lastChain = headChain;
while (lastChain.next) {
lastChain = lastChain.next;
}
lastChain.next = tailChain;
return headChain;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | concatenateDiagnosticMessageChains | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function compareValues(a, b) {
if (a === b)
return 0 /* EqualTo */;
if (a === undefined)
return -1 /* LessThan */;
if (b === undefined)
return 1 /* GreaterThan */;
return a < b ? -1 /* LessThan */ : 1 /* GreaterThan */;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | compareValues | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getDiagnosticFileName(diagnostic) {
return diagnostic.file ? diagnostic.file.fileName : undefined;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getDiagnosticFileName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function compareDiagnostics(d1, d2) {
return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) ||
compareValues(d1.start, d2.start) ||
compareValues(d1.length, d2.length) ||
compareValues(d1.code, d2.code) ||
compareMessageText(d1.messageText, d2.messageText) ||
0 /* EqualTo */;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | compareDiagnostics | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function compareMessageText(text1, text2) {
while (text1 && text2) {
// We still have both chains.
var string1 = typeof text1 === "string" ? text1 : text1.messageText;
var string2 = typeof text2 === "string" ? text2 : text2.messageText;
var res = compareValues(string1, string2);
if (res) {
return res;
}
text1 = typeof text1 === "string" ? undefined : text1.next;
text2 = typeof text2 === "string" ? undefined : text2.next;
}
if (!text1 && !text2) {
// if the chains are done, then these messages are the same.
return 0 /* EqualTo */;
}
// We still have one chain remaining. The shorter chain should come first.
return text1 ? 1 /* GreaterThan */ : -1 /* LessThan */;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | compareMessageText | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function sortAndDeduplicateDiagnostics(diagnostics) {
return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics));
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | sortAndDeduplicateDiagnostics | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function deduplicateSortedDiagnostics(diagnostics) {
if (diagnostics.length < 2) {
return diagnostics;
}
var newDiagnostics = [diagnostics[0]];
var previousDiagnostic = diagnostics[0];
for (var i = 1; i < diagnostics.length; i++) {
var currentDiagnostic = diagnostics[i];
var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0 /* EqualTo */;
if (!isDupe) {
newDiagnostics.push(currentDiagnostic);
previousDiagnostic = currentDiagnostic;
}
}
return newDiagnostics;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | deduplicateSortedDiagnostics | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function normalizeSlashes(path) {
return path.replace(/\\/g, "/");
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | normalizeSlashes | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getNormalizedParts(normalizedSlashedPath, rootLength) {
var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator);
var normalized = [];
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
var part = parts_1[_i];
if (part !== ".") {
if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") {
normalized.pop();
}
else {
// A part may be an empty string (which is 'falsy') if the path had consecutive slashes,
// e.g. "path//file.ts". Drop these before re-joining the parts.
if (part) {
normalized.push(part);
}
}
}
}
return normalized;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getNormalizedParts | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function normalizePath(path) {
path = normalizeSlashes(path);
var rootLength = getRootLength(path);
var normalized = getNormalizedParts(path, rootLength);
return path.substr(0, rootLength) + normalized.join(ts.directorySeparator);
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | normalizePath | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getDirectoryPath(path) {
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator)));
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getDirectoryPath | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isUrl(path) {
return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | isUrl | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isRootedDiskPath(path) {
return getRootLength(path) !== 0;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | isRootedDiskPath | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function normalizedPathComponents(path, rootLength) {
var normalizedParts = getNormalizedParts(path, rootLength);
return [path.substr(0, rootLength)].concat(normalizedParts);
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | normalizedPathComponents | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getNormalizedPathComponents(path, currentDirectory) {
path = normalizeSlashes(path);
var rootLength = getRootLength(path);
if (rootLength === 0) {
// If the path is not rooted it is relative to current directory
path = combinePaths(normalizeSlashes(currentDirectory), path);
rootLength = getRootLength(path);
}
return normalizedPathComponents(path, rootLength);
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getNormalizedPathComponents | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getNormalizedAbsolutePath(fileName, currentDirectory) {
return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getNormalizedAbsolutePath | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getNormalizedPathFromPathComponents(pathComponents) {
if (pathComponents && pathComponents.length) {
return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator);
}
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getNormalizedPathFromPathComponents | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getNormalizedPathComponentsOfUrl(url) {
// Get root length of http://www.website.com/folder1/foler2/
// In this example the root is: http://www.website.com/
// normalized path components should be ["http://www.website.com/", "folder1", "folder2"]
var urlLength = url.length;
// Initial root length is http:// part
var rootLength = url.indexOf("://") + "://".length;
while (rootLength < urlLength) {
// Consume all immediate slashes in the protocol
// eg.initial rootlength is just file:// but it needs to consume another "/" in file:///
if (url.charCodeAt(rootLength) === 47 /* slash */) {
rootLength++;
}
else {
// non slash character means we continue proceeding to next component of root search
break;
}
}
// there are no parts after http:// just return current string as the pathComponent
if (rootLength === urlLength) {
return [url];
}
// Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://)
var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength);
if (indexOfNextSlash !== -1) {
// Found the "/" after the website.com so the root is length of http://www.website.com/
// and get components afetr the root normally like any other folder components
rootLength = indexOfNextSlash + 1;
return normalizedPathComponents(url, rootLength);
}
else {
// Can't find the host assume the rest of the string as component
// but make sure we append "/" to it as root is not joined using "/"
// eg. if url passed in was http://website.com we want to use root as [http://website.com/]
// so that other path manipulations will be correct and it can be merged with relative paths correctly
return [url + ts.directorySeparator];
}
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getNormalizedPathComponentsOfUrl | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) {
if (isUrl(pathOrUrl)) {
return getNormalizedPathComponentsOfUrl(pathOrUrl);
}
else {
return getNormalizedPathComponents(pathOrUrl, currentDirectory);
}
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getNormalizedPathOrUrlComponents | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") {
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
directoryComponents.length--;
}
// Find the component that differs
for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) {
break;
}
}
// Get the relative path
if (joinStartIndex) {
var relativePath = "";
var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length);
for (; joinStartIndex < directoryComponents.length; joinStartIndex++) {
if (directoryComponents[joinStartIndex] !== "") {
relativePath = relativePath + ".." + ts.directorySeparator;
}
}
return relativePath + relativePathComponents.join(ts.directorySeparator);
}
// Cant find the relative path, get the absolute path
var absolutePath = getNormalizedPathFromPathComponents(pathComponents);
if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) {
absolutePath = "file:///" + absolutePath;
}
return absolutePath;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getRelativePathToDirectoryOrUrl | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getBaseFileName(path) {
if (!path) {
return undefined;
}
var i = path.lastIndexOf(ts.directorySeparator);
return i < 0 ? path : path.substring(i + 1);
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | getBaseFileName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function combinePaths(path1, path2) {
if (!(path1 && path1.length))
return path2;
if (!(path2 && path2.length))
return path1;
if (getRootLength(path2) !== 0)
return path2;
if (path1.charAt(path1.length - 1) === ts.directorySeparator)
return path1 + path2;
return path1 + ts.directorySeparator + path2;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | combinePaths | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function fileExtensionIs(path, extension) {
var pathLen = path.length;
var extLen = extension.length;
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
} | Creates a map from the elements of an array.
@param array the array of input elements.
@param makeKey a function that produces a key for a given element.
This function makes no effort to avoid collisions; if any two elements produce
the same key with the given 'makeKey' function, then the element with the higher
index in the array will be the one associated with the produced key. | fileExtensionIs | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isSupportedSourceFileName(fileName) {
if (!fileName) {
return false;
}
for (var _i = 0, supportedExtensions_1 = ts.supportedExtensions; _i < supportedExtensions_1.length; _i++) {
var extension = supportedExtensions_1[_i];
if (fileExtensionIs(fileName, extension)) {
return true;
}
}
return false;
} | List of supported extensions in order of file resolution precedence. | isSupportedSourceFileName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function removeFileExtension(path) {
for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
var ext = extensionsToRemove_1[_i];
if (fileExtensionIs(path, ext)) {
return path.substr(0, path.length - ext.length);
}
}
return path;
} | List of supported extensions in order of file resolution precedence. | removeFileExtension | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function Symbol(flags, name) {
this.flags = flags;
this.name = name;
this.declarations = undefined;
} | List of supported extensions in order of file resolution precedence. | Symbol | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function Type(checker, flags) {
this.flags = flags;
} | List of supported extensions in order of file resolution precedence. | Type | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function Node(kind, pos, end) {
this.kind = kind;
this.pos = pos;
this.end = end;
this.flags = 0 /* None */;
this.parent = undefined;
} | List of supported extensions in order of file resolution precedence. | Node | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function shouldAssert(level) {
return currentAssertionLevel >= level;
} | List of supported extensions in order of file resolution precedence. | shouldAssert | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function assert(expression, message, verboseDebugInfo) {
if (!expression) {
var verboseDebugString = "";
if (verboseDebugInfo) {
verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo();
}
debugger;
throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString);
}
} | List of supported extensions in order of file resolution precedence. | assert | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function fail(message) {
Debug.assert(false, message);
} | List of supported extensions in order of file resolution precedence. | fail | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function copyListRemovingItem(item, list) {
var copiedList = [];
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
var e = list_1[_i];
if (e !== item) {
copiedList.push(e);
}
}
return copiedList;
} | List of supported extensions in order of file resolution precedence. | copyListRemovingItem | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getWScriptSystem() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fileStream = new ActiveXObject("ADODB.Stream");
fileStream.Type = 2 /*text*/;
var binaryStream = new ActiveXObject("ADODB.Stream");
binaryStream.Type = 1 /*binary*/;
var args = [];
for (var i = 0; i < WScript.Arguments.length; i++) {
args[i] = WScript.Arguments.Item(i);
}
function readFile(fileName, encoding) {
if (!fso.FileExists(fileName)) {
return undefined;
}
fileStream.Open();
try {
if (encoding) {
fileStream.Charset = encoding;
fileStream.LoadFromFile(fileName);
}
else {
// Load file and read the first two bytes into a string with no interpretation
fileStream.Charset = "x-ansi";
fileStream.LoadFromFile(fileName);
var bom = fileStream.ReadText(2) || "";
// Position must be at 0 before encoding can be changed
fileStream.Position = 0;
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8
fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8";
}
// ReadText method always strips byte order mark from resulting string
return fileStream.ReadText();
}
catch (e) {
throw e;
}
finally {
fileStream.Close();
}
}
function writeFile(fileName, data, writeByteOrderMark) {
fileStream.Open();
binaryStream.Open();
try {
// Write characters in UTF-8 encoding
fileStream.Charset = "utf-8";
fileStream.WriteText(data);
// If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM).
// If not, start from position 0, as the BOM will be added automatically when charset==utf8.
if (writeByteOrderMark) {
fileStream.Position = 0;
}
else {
fileStream.Position = 3;
}
fileStream.CopyTo(binaryStream);
binaryStream.SaveToFile(fileName, 2 /*overwrite*/);
}
finally {
binaryStream.Close();
fileStream.Close();
}
}
function getCanonicalPath(path) {
return path.toLowerCase();
}
function getNames(collection) {
var result = [];
for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
result.push(e.item().Name);
}
return result.sort();
}
function readDirectory(path, extension, exclude) {
var result = [];
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); });
visitDirectory(path);
return result;
function visitDirectory(path) {
var folder = fso.GetFolder(path || ".");
var files = getNames(folder.files);
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
var current = files_1[_i];
var name_1 = ts.combinePaths(path, current);
if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) {
result.push(name_1);
}
}
var subfolders = getNames(folder.subfolders);
for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) {
var current = subfolders_1[_a];
var name_2 = ts.combinePaths(path, current);
if (!ts.contains(exclude, getCanonicalPath(name_2))) {
visitDirectory(name_2);
}
}
}
}
return {
args: args,
newLine: "\r\n",
useCaseSensitiveFileNames: false,
write: function (s) {
WScript.StdOut.Write(s);
},
readFile: readFile,
writeFile: writeFile,
resolvePath: function (path) {
return fso.GetAbsolutePathName(path);
},
fileExists: function (path) {
return fso.FileExists(path);
},
directoryExists: function (path) {
return fso.FolderExists(path);
},
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
fso.CreateFolder(directoryName);
}
},
getExecutingFilePath: function () {
return WScript.ScriptFullName;
},
getCurrentDirectory: function () {
return new ActiveXObject("WScript.Shell").CurrentDirectory;
},
readDirectory: readDirectory,
exit: function (exitCode) {
try {
WScript.Quit(exitCode);
}
catch (e) {
}
}
};
} | List of supported extensions in order of file resolution precedence. | getWScriptSystem | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function readFile(fileName, encoding) {
if (!fso.FileExists(fileName)) {
return undefined;
}
fileStream.Open();
try {
if (encoding) {
fileStream.Charset = encoding;
fileStream.LoadFromFile(fileName);
}
else {
// Load file and read the first two bytes into a string with no interpretation
fileStream.Charset = "x-ansi";
fileStream.LoadFromFile(fileName);
var bom = fileStream.ReadText(2) || "";
// Position must be at 0 before encoding can be changed
fileStream.Position = 0;
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8
fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8";
}
// ReadText method always strips byte order mark from resulting string
return fileStream.ReadText();
}
catch (e) {
throw e;
}
finally {
fileStream.Close();
}
} | List of supported extensions in order of file resolution precedence. | readFile | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function writeFile(fileName, data, writeByteOrderMark) {
fileStream.Open();
binaryStream.Open();
try {
// Write characters in UTF-8 encoding
fileStream.Charset = "utf-8";
fileStream.WriteText(data);
// If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM).
// If not, start from position 0, as the BOM will be added automatically when charset==utf8.
if (writeByteOrderMark) {
fileStream.Position = 0;
}
else {
fileStream.Position = 3;
}
fileStream.CopyTo(binaryStream);
binaryStream.SaveToFile(fileName, 2 /*overwrite*/);
}
finally {
binaryStream.Close();
fileStream.Close();
}
} | List of supported extensions in order of file resolution precedence. | writeFile | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getCanonicalPath(path) {
return path.toLowerCase();
} | List of supported extensions in order of file resolution precedence. | getCanonicalPath | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getNames(collection) {
var result = [];
for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
result.push(e.item().Name);
}
return result.sort();
} | List of supported extensions in order of file resolution precedence. | getNames | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function readDirectory(path, extension, exclude) {
var result = [];
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); });
visitDirectory(path);
return result;
function visitDirectory(path) {
var folder = fso.GetFolder(path || ".");
var files = getNames(folder.files);
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
var current = files_1[_i];
var name_1 = ts.combinePaths(path, current);
if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) {
result.push(name_1);
}
}
var subfolders = getNames(folder.subfolders);
for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) {
var current = subfolders_1[_a];
var name_2 = ts.combinePaths(path, current);
if (!ts.contains(exclude, getCanonicalPath(name_2))) {
visitDirectory(name_2);
}
}
}
} | List of supported extensions in order of file resolution precedence. | readDirectory | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function visitDirectory(path) {
var folder = fso.GetFolder(path || ".");
var files = getNames(folder.files);
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
var current = files_1[_i];
var name_1 = ts.combinePaths(path, current);
if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) {
result.push(name_1);
}
}
var subfolders = getNames(folder.subfolders);
for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) {
var current = subfolders_1[_a];
var name_2 = ts.combinePaths(path, current);
if (!ts.contains(exclude, getCanonicalPath(name_2))) {
visitDirectory(name_2);
}
}
} | List of supported extensions in order of file resolution precedence. | visitDirectory | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getNodeSystem() {
var _fs = require("fs");
var _path = require("path");
var _os = require("os");
var _tty = require("tty");
// average async stat takes about 30 microseconds
// set chunk size to do 30 files in < 1 millisecond
function createWatchedFileSet(interval, chunkSize) {
if (interval === void 0) { interval = 2500; }
if (chunkSize === void 0) { chunkSize = 30; }
var watchedFiles = [];
var nextFileToCheck = 0;
var watchTimer;
function getModifiedTime(fileName) {
return _fs.statSync(fileName).mtime;
}
function poll(checkedIndex) {
var watchedFile = watchedFiles[checkedIndex];
if (!watchedFile) {
return;
}
_fs.stat(watchedFile.fileName, function (err, stats) {
if (err) {
watchedFile.callback(watchedFile.fileName);
}
else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) {
watchedFile.mtime = getModifiedTime(watchedFile.fileName);
watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0);
}
});
}
// this implementation uses polling and
// stat due to inconsistencies of fs.watch
// and efficiency of stat on modern filesystems
function startWatchTimer() {
watchTimer = setInterval(function () {
var count = 0;
var nextToCheck = nextFileToCheck;
var firstCheck = -1;
while ((count < chunkSize) && (nextToCheck !== firstCheck)) {
poll(nextToCheck);
if (firstCheck < 0) {
firstCheck = nextToCheck;
}
nextToCheck++;
if (nextToCheck === watchedFiles.length) {
nextToCheck = 0;
}
count++;
}
nextFileToCheck = nextToCheck;
}, interval);
}
function addFile(fileName, callback) {
var file = {
fileName: fileName,
callback: callback,
mtime: getModifiedTime(fileName)
};
watchedFiles.push(file);
if (watchedFiles.length === 1) {
startWatchTimer();
}
return file;
}
function removeFile(file) {
watchedFiles = ts.copyListRemovingItem(file, watchedFiles);
}
return {
getModifiedTime: getModifiedTime,
poll: poll,
startWatchTimer: startWatchTimer,
addFile: addFile,
removeFile: removeFile
};
}
// REVIEW: for now this implementation uses polling.
// The advantage of polling is that it works reliably
// on all os and with network mounted files.
// For 90 referenced files, the average time to detect
// changes is 2*msInterval (by default 5 seconds).
// The overhead of this is .04 percent (1/2500) with
// average pause of < 1 millisecond (and max
// pause less than 1.5 milliseconds); question is
// do we anticipate reference sets in the 100s and
// do we care about waiting 10-20 seconds to detect
// changes for large reference sets? If so, do we want
// to increase the chunk size or decrease the interval
// time dynamically to match the large reference set?
var watchedFileSet = createWatchedFileSet();
function isNode4OrLater() {
return parseInt(process.version.charAt(1)) >= 4;
}
var platform = _os.platform();
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
function readFile(fileName, encoding) {
if (!_fs.existsSync(fileName)) {
return undefined;
}
var buffer = _fs.readFileSync(fileName);
var len = buffer.length;
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
// flip all byte pairs and treat as little endian.
len &= ~1;
for (var i = 0; i < len; i += 2) {
var temp = buffer[i];
buffer[i] = buffer[i + 1];
buffer[i + 1] = temp;
}
return buffer.toString("utf16le", 2);
}
if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
// Little endian UTF-16 byte order mark detected
return buffer.toString("utf16le", 2);
}
if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
// UTF-8 byte order mark detected
return buffer.toString("utf8", 3);
}
// Default is UTF-8 with no byte order mark
return buffer.toString("utf8");
}
function writeFile(fileName, data, writeByteOrderMark) {
// If a BOM is required, emit one
if (writeByteOrderMark) {
data = "\uFEFF" + data;
}
var fd;
try {
fd = _fs.openSync(fileName, "w");
_fs.writeSync(fd, data, undefined, "utf8");
}
finally {
if (fd !== undefined) {
_fs.closeSync(fd);
}
}
}
function getCanonicalPath(path) {
return useCaseSensitiveFileNames ? path.toLowerCase() : path;
}
function readDirectory(path, extension, exclude) {
var result = [];
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); });
visitDirectory(path);
return result;
function visitDirectory(path) {
var files = _fs.readdirSync(path || ".").sort();
var directories = [];
for (var _i = 0, files_2 = files; _i < files_2.length; _i++) {
var current = files_2[_i];
var name_3 = ts.combinePaths(path, current);
if (!ts.contains(exclude, getCanonicalPath(name_3))) {
var stat = _fs.statSync(name_3);
if (stat.isFile()) {
if (!extension || ts.fileExtensionIs(name_3, extension)) {
result.push(name_3);
}
}
else if (stat.isDirectory()) {
directories.push(name_3);
}
}
}
for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) {
var current = directories_1[_a];
visitDirectory(current);
}
}
}
return {
args: process.argv.slice(2),
newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
write: function (s) {
process.stdout.write(s);
},
readFile: readFile,
writeFile: writeFile,
watchFile: function (fileName, callback) {
// Node 4.0 stablized the `fs.watch` function on Windows which avoids polling
// and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649
// and https://github.com/Microsoft/TypeScript/issues/4643), therefore
// if the current node.js version is newer than 4, use `fs.watch` instead.
if (isNode4OrLater()) {
// Note: in node the callback of fs.watch is given only the relative file name as a parameter
return _fs.watch(fileName, function (eventName, relativeFileName) { return callback(fileName); });
}
var watchedFile = watchedFileSet.addFile(fileName, callback);
return {
close: function () { return watchedFileSet.removeFile(watchedFile); }
};
},
watchDirectory: function (path, callback, recursive) {
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
return _fs.watch(path, { persistent: true, recursive: !!recursive }, function (eventName, relativeFileName) {
// In watchDirectory we only care about adding and removing files (when event name is
// "rename"); changes made within files are handled by corresponding fileWatchers (when
// event name is "change")
if (eventName === "rename") {
// When deleting a file, the passed baseFileName is null
callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(path, relativeFileName)));
}
;
});
},
resolvePath: function (path) {
return _path.resolve(path);
},
fileExists: function (path) {
return _fs.existsSync(path);
},
directoryExists: function (path) {
return _fs.existsSync(path) && _fs.statSync(path).isDirectory();
},
createDirectory: function (directoryName) {
if (!this.directoryExists(directoryName)) {
_fs.mkdirSync(directoryName);
}
},
getExecutingFilePath: function () {
return __filename;
},
getCurrentDirectory: function () {
return process.cwd();
},
readDirectory: readDirectory,
getMemoryUsage: function () {
if (global.gc) {
global.gc();
}
return process.memoryUsage().heapUsed;
},
exit: function (exitCode) {
process.exit(exitCode);
}
};
} | List of supported extensions in order of file resolution precedence. | getNodeSystem | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getModifiedTime(fileName) {
return _fs.statSync(fileName).mtime;
} | List of supported extensions in order of file resolution precedence. | getModifiedTime | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.