code stringlengths 28 313k | docstring stringlengths 25 85.3k | func_name stringlengths 1 74 | language stringclasses 1
value | repo stringlengths 5 60 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
moveBinding(binding, toScope) {
this.bindings.get(binding.scope).delete(binding.identifier.name);
this.bindings.get(toScope).set(binding.identifier.name, binding);
} | Moves Binding from it's own Scope to {@param toScope}
required for fixup-var-scope
@param {Binding} binding
@param {Scope} toScope | moveBinding | javascript | babel/minify | packages/babel-plugin-minify-mangle-names/src/scope-tracker.js | https://github.com/babel/minify/blob/master/packages/babel-plugin-minify-mangle-names/src/scope-tracker.js | MIT |
hasBinding(scope, name) {
return this.bindings.get(scope).has(name);
} | has a Binding in the current {Scope}
@param {Scope} scope
@param {String} name | hasBinding | javascript | babel/minify | packages/babel-plugin-minify-mangle-names/src/scope-tracker.js | https://github.com/babel/minify/blob/master/packages/babel-plugin-minify-mangle-names/src/scope-tracker.js | MIT |
renameBinding(scope, oldName, newName) {
const bindings = this.bindings.get(scope);
bindings.set(newName, bindings.get(oldName));
bindings.delete(oldName);
} | Update the ScopeTracker on rename
@param {Scope} scope
@param {String} oldName
@param {String} newName | renameBinding | javascript | babel/minify | packages/babel-plugin-minify-mangle-names/src/scope-tracker.js | https://github.com/babel/minify/blob/master/packages/babel-plugin-minify-mangle-names/src/scope-tracker.js | MIT |
function pathJoin(...parts) {
if (path.isAbsolute(parts[0])) {
return path.join(...parts);
}
return "." + path.sep + path.join(...parts);
} | Jest changes __dirname to relative path and the require of relative path
that doesn't start with "." will be a module require -
require("./packages/babel-plugin...") vs require("packages/babel-plugin..");
So we start the path with a "./" | pathJoin | javascript | babel/minify | utils/test-runner/src/index.js | https://github.com/babel/minify/blob/master/utils/test-runner/src/index.js | MIT |
function inArray(o, arr) {
return arr.indexOf(o) > -1;
} | Check in array
@param {*} o
@param {Array} arr
@returns {Boolean} | inArray | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
} | Check is array
@param {*} o
@returns {Boolean} | isArray | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function isObject(o) {
return Object.prototype.toString.call(o) === '[object Object]';
} | Check is object
@param {*} o
@returns {Boolean} | isObject | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function hasClass(el, cls) {
return el.className.match(new RegExp('(\\s|^)(' + cls + ')(\\s|$)'));
} | @param {HTMLElement} el
@param {String} cls
@returns {Array|{index: number, input: string}} | hasClass | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function addClass(el, cls) {
if (!hasClass(el, cls)) {
el.className += ' ' + cls;
}
} | @param {HTMLElement} el
@param {String} cls | addClass | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function isUrl(url) {
if (/<\/?[^>]*>/.test(url))
return false;
return /^(?:(https|http|ftp|rtsp|mms):)?(\/\/)?(\w+:{0,1}\w*@)?([^\?#:\/]+\.[a-z]+|\d+\.\d+\.\d+\.\d+)?(:[0-9]+)?((?:\.?\/)?([^\?#]*)?(\?[^#]+)?(#.+)?)?$/.test(url);
} | Check is url
@param {String} url
@returns {Boolean} | isUrl | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function isDom(obj) {
try {
return obj instanceof HTMLElement;
}
catch (e) {
return (typeof obj === "object") &&
(obj.nodeType === 1) && (typeof obj.style === "object") &&
(typeof obj.ownerDocument === "object");
}
} | Check is dom object
@param {object} dom
@returns {Boolean} | isDom | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function _A(a) {
return Array.prototype.slice.apply(a, Array.prototype.slice.call(arguments, 1));
} | Parse arguments to array
@param {Arguments} a
@param {Number|null} start
@param {Number|null} end
@returns {Array} | _A | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
iSlider = function () {
var args = _A(arguments, 0, 3);
if (!args.length) {
throw new Error('Parameters required!');
}
var opts = isObject(args.slice(-1)[0]) ? args.pop() : {};
switch (args.length) {
case 2:
opts.data = opts.data... | @constructor
iSlider([[{HTMLElement} container,] {Array} datalist,] {Object} options)
@param {HTMLElement} container
@param {Array} datalist
@param {Object} options
@description
options.dom > container
options.data > datalist | iSlider | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function normal(dom, axis, scale, i, offset) {
iSlider.setStyle(dom, 'transform', 'translateZ(0) translate' + axis + '(' + (offset + scale * (i - 1)) + 'px)');
} | @type {Object}
@param {HTMLElement} dom The wrapper <li> element
@param {String} axis Animate direction
@param {Number} scale Outer wrapper
@param {Number} i Wrapper's index
@param {Number} offset Move distance
@protected | normal | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
insertImg = function renderItemInsertImg() {
var simg = ' src="' + item.content + '"';
// auto scale to full screen
if (item.height / item.width > self.ratio) {
simg += ' height="100%"';
} else {
simg += ' width="100%"';
... | render single item html by idx
@param {HTMLElement} el ..
@param {Number} dataIndex ..
@private | insertImg | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
loadImg = function (index) {
var item = data[index];
if (self._itemType(item) === 'pic' && !item.load) {
var preloadImg = new Image();
preloadImg.src = item.content;
preloadImg.onload = function () {
... | Preload img when slideChange
From current index +2, -2 scene
@param {Number} dataIndex means which image will be load
@private | loadImg | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function dispatchLink(el) {
if (el != null) {
if (el.tagName === 'A') {
if (el.href) {
if (el.getAttribute('target') === '_blank') {
global.open(el.href);
} else {
... | touchend callback
@param {Object} evt event object
@public | dispatchLink | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function delegatedEventCallbackHandle(e) {
var evt = global.event ? global.event : e;
var target = evt.target;
var eleArr = document.querySelectorAll(selector);
for (var i = 0; i < eleArr.length; i++) {
if (target === eleArr[i]) {
... | simple event delegate method
@param {String} evtType event name
@param {String} selector the simple css selector like jQuery
@param {Function} callback event callback
@public
@alias iSliderPrototype.bind | delegatedEventCallbackHandle | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function rotate(dom, axis, scale, i, offset, direct) {
var rotateDirect = (axis === 'X') ? 'Y' : 'X';
if (this.isVertical) {
offset = -offset;
if (Math.abs(direct) > 1) {
direct = -direct;
}
... | More animations
@file animate.js
@author BE-FE Team
xieyu33333 xieyu33333@gmail.com
shinate shine.wangrs@gmail.com | rotate | javascript | be-fe/iSlider | build/index.bundle.js | https://github.com/be-fe/iSlider/blob/master/build/index.bundle.js | MIT |
function parseZone(sizes) {
if (typeof sizes === 'number') {
if (sizes < 0) {
sizes = 0;
}
return [sizes, sizes, sizes, sizes];
} else if (sizes instanceof Array) {
switch (sizes.length) {
cas... | Boundary Identification Zone
@file BIZone.js
@author BE-FE Team
shinate shine.wangrs@gmail.com | parseZone | javascript | be-fe/iSlider | build/iSlider.plugin.BIZone.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.BIZone.js | MIT |
function renderDots() {
var fragment = document.createDocumentFragment();
dots.forEach(function (el, i) {
el.removeEventListener(endEvt, evtHandle[i], false);
});
dots = [], evtHandle = [];
dotWrap.innerHTML = '';
for (var i = 0; i ... | To create dots index on iSlider
@file dot.js
@author BE-FE Team
xieyu33333 xieyu33333@gmail.com
shinate shine.wangrs@gmail.com
@Instructions
activation:
new iSlider({
...
plugins: ['dot']
...
});
more options:
new iSlider({
...
plugins: [['dot'... | renderDots | javascript | be-fe/iSlider | build/iSlider.plugin.dot.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.dot.js | MIT |
function generateTranslate(x, y, z, scale) {
return 'translate' + (has3d ? '3d(' : '(') + x + 'px,' + y + (has3d ? 'px,' + z + 'px)' : 'px)') + 'scale(' + scale + ')';
} | Generate translate
@param x
@param y
@param z
@param scale
@returns {string} | generateTranslate | javascript | be-fe/iSlider | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.zoompic.js | MIT |
function getDistance(a, b) {
var x, y;
x = a.left - b.left;
y = a.top - b.top;
return Math.sqrt(x * x + y * y);
} | Get distance
@param a
@param b
@returns {number} | getDistance | javascript | be-fe/iSlider | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.zoompic.js | MIT |
function generateTransformOrigin(x, y) {
return x + 'px ' + y + 'px';
} | Transform to string
@param x
@param y
@returns {string} | generateTransformOrigin | javascript | be-fe/iSlider | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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 | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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 | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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 ... | 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 | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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 | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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;
... | Start event handle
@param {object} evt | startHandler | javascript | be-fe/iSlider | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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';
... | Move event handle
@param {object} evt
@returns {number} | moveHandler | javascript | be-fe/iSlider | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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.... | Double tao handle
@param {object} evt | handleDoubleTap | javascript | be-fe/iSlider | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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 | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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';... | Check target is in range
@param node
@param value
@param tag
@returns {boolean} | valueInViewScope | javascript | be-fe/iSlider | build/iSlider.plugin.zoompic.js | https://github.com/be-fe/iSlider/blob/master/build/iSlider.plugin.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... | 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.charCod... | 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 <htt... | 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 val... | 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, th... | 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) * d... | 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 fi... | 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 po... | 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... | 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
Uni... | 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 (v... | 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 e... | createFileMap | 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 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[po... | 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 arra... | reduceLeft | 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
inde... | memoize | 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,... | 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 getLineAndCharacterOfPosition(sourceFile, position) {
return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
} | We assume the first line starts at position 0 and 'position' is non-negative. | getLineAndCharacterOfPosition | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getCommentRanges(text, pos, trailing) {
var result;
var collecting = trailing || pos === 0;
while (pos < text.length) {
var ch = text.charCodeAt(pos);
switch (ch) {
case 13 /* carriageReturn */:
if (text.charCodeAt(pos + 1) ===... | Extract comments from text prefixing the token closest following `pos`.
The return value is an array containing a TextRange for each comment.
Single-line comment ranges include the beginning '//' characters but not the ending line break.
Multi - line comment ranges include the beginning '/* and ending '<asterisk>/' cha... | getCommentRanges | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function scanExactNumberOfHexDigits(count) {
return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false);
} | Scans the given number of hexadecimal digits in the text,
returning -1 if the given number is unavailable. | scanExactNumberOfHexDigits | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function scanMinimumNumberOfHexDigits(count) {
return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true);
} | Scans as many hexadecimal digits as are available in the text,
returning -1 if the given number of digits was unavailable. | scanMinimumNumberOfHexDigits | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function scanEscapeSequence() {
pos++;
if (pos >= end) {
error(ts.Diagnostics.Unexpected_end_of_text);
return "";
}
var ch = text.charCodeAt(pos++);
switch (ch) {
case 48 /* _0 */:
return "\0"... | Sets the current 'tokenValue' and returns a NoSubstitutionTemplateLiteral or
a literal component of a TemplateExpression. | scanEscapeSequence | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function reScanTemplateToken() {
ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'");
pos = tokenPos;
return token = scanTemplateAndSetTokenValue();
} | Unconditionally back up and scan a template expression portion. | reScanTemplateToken | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isRequireCall(expression) {
// of the form 'require("name")'
return expression.kind === 168 /* CallExpression */ &&
expression.expression.kind === 69 /* Identifier */ &&
expression.expression.text === "require" &&
expression.arguments.length === 1 &&
... | Returns true if the node is a CallExpression to the identifier 'require' with
exactly one string literal argument.
This function does not test if the node is in a JavaScript file or not. | isRequireCall | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isExportsPropertyAssignment(expression) {
// of the form 'exports.name = expr' where 'name' and 'expr' are arbitrary
return isInJavaScriptFile(expression) &&
(expression.kind === 181 /* BinaryExpression */) &&
(expression.operatorToken.kind === 56 /* EqualsToken */) &&
... | Returns true if the node is an assignment to a property on the identifier 'exports'.
This function does not test if the node is in a JavaScript file or not. | isExportsPropertyAssignment | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isModuleExportsAssignment(expression) {
// of the form 'module.exports = expr' where 'expr' is arbitrary
return isInJavaScriptFile(expression) &&
(expression.kind === 181 /* BinaryExpression */) &&
(expression.operatorToken.kind === 56 /* EqualsToken */) &&
(... | Returns true if the node is an assignment to the property access expression 'module.exports'.
This function does not test if the node is in a JavaScript file or not. | isModuleExportsAssignment | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function hasDynamicName(declaration) {
return declaration.name && isDynamicName(declaration.name);
} | A declaration has a dynamic name if both of the following are true:
1. The declaration has a computed property name
2. The computed name is *not* expressed as Symbol.<name>, where name
is a property of the Symbol constructor that denotes a built in
Symbol. | hasDynamicName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isWellKnownSymbolSyntactically(node) {
return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
} | Checks if the expression is of the form:
Symbol.name
where Symbol is literally the word "Symbol", and name is any identifierName | isWellKnownSymbolSyntactically | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isESSymbolIdentifier(node) {
return node.kind === 69 /* Identifier */ && node.text === "Symbol";
} | Includes the word "Symbol" with unicode escapes | isESSymbolIdentifier | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getReplacement(c) {
return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0));
} | Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
Note that this doesn't actually wrap the input in double quotes. | getReplacement | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
var leadingComments;
var currentDetachedCommentInfo;
if (removeComments) {
// removeComments is true, only reserve pinned comment at the top of file
// For example:
... | Detached comment is a comment at the top of file or function body that is separated from
the next statement by space. | emitDetachedComments | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function convertToBase64(input) {
var result = "";
var charCodes = getExpandedCharCodes(input);
var i = 0;
var length = charCodes.length;
var byte1, byte2, byte3, byte4;
while (i < length) {
// Convert every 6-bits in the input 3 character points
/... | Converts a string to a base-64 encoded ASCII string. | convertToBase64 | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function collapseTextChangeRangesAcrossMultipleVersions(changes) {
if (changes.length === 0) {
return ts.unchangedTextChangeRange;
}
if (changes.length === 1) {
return changes[0];
}
// We change from talking about { { oldStart, oldLength }, newLength } to ... | Called to merge all the changes that occurred across several versions of a script snapshot
into a single change. i.e. if a user keeps making successive edits to a script we will
have a text change from V1 to V2, V2 to V3, ..., Vn.
This function will then merge those changes into a single change range valid between V1... | collapseTextChangeRangesAcrossMultipleVersions | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function parseUnaryExpressionOrHigher() {
if (isAwaitExpression()) {
return parseAwaitExpression();
}
if (isIncrementExpression()) {
var incrementExpression = parseIncrementExpression();
return token === 38 /* AsteriskAsteriskToken */ ?... | Parse ES7 unary expression and await expression
ES7 UnaryExpression:
1) SimpleUnaryExpression[?yield]
2) IncrementExpression[?yield] ** UnaryExpression[?yield] | parseUnaryExpressionOrHigher | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function parseSimpleUnaryExpression() {
switch (token) {
case 35 /* PlusToken */:
case 36 /* MinusToken */:
case 50 /* TildeToken */:
case 49 /* ExclamationToken */:
return parsePrefixUnaryExpression();
case ... | Parse ES7 simple-unary expression or higher:
ES7 SimpleUnaryExpression:
1) IncrementExpression[?yield]
2) delete UnaryExpression[?yield]
3) void UnaryExpression[?yield]
4) typeof UnaryExpression[?yield]
5) + UnaryExpression[?yield]
6) - UnaryExpression[?yield]
7) ~ UnaryExpression[?y... | parseSimpleUnaryExpression | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isIncrementExpression() {
// This function is called inside parseUnaryExpression to decide
// whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly
switch (token) {
case 35 /* PlusToken */:
case 36 /* MinusToken *... | Check if the current token can possibly be an ES7 increment expression.
ES7 IncrementExpression:
LeftHandSideExpression[?Yield]
LeftHandSideExpression[?Yield][no LineTerminator here]++
LeftHandSideExpression[?Yield][no LineTerminator here]--
++LeftHandSideExpression[?Yield]
--LeftHandSideExpre... | isIncrementExpression | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function parseIncrementExpression() {
if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) {
var node = createNode(179 /* PrefixUnaryExpression */);
node.operator = token;
nextToken();
node.operand = parseLeftHandSideExpr... | Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression.
ES7 IncrementExpression[yield]:
1) LeftHandSideExpression[?yield]
2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++
3) LeftHandSideExpression[?yield] [[no LineTerminator here]]--
4) ++LeftHan... | parseIncrementExpression | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createJSDocComment() {
if (!tags) {
return undefined;
}
var result = createNode(265 /* JSDocComment */, start);
result.tags = tags;
return finishNode(result, end);
} | ".length; pos < end;) {
var ch = content.charCodeAt(pos);
pos++;
if (ch === 64 /* at | createJSDocComment | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function declareSymbol(symbolTable, parent, node, includes, excludes) {
ts.Debug.assert(!ts.hasDynamicName(node));
var isDefaultExport = node.flags & 512 /* Default */;
// The exported symbol for an export default function/class node is always named "default"
var name = i... | Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names.
@param symbolTable - The symbol table which node will be added to.
@param parent - node's parent declaration.
@param node - The declaration to be added to the symbol table
@param includes - The SymbolFlags that node ... | declareSymbol | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function bindReachableStatement(node) {
if (checkUnreachable(node)) {
ts.forEachChild(node, bind);
return;
}
switch (node.kind) {
case 198 /* WhileStatement */:
bindWhileStatement(node);
break;
... | Returns true if node and its subnodes were successfully traversed.
Returning false means that node was not examined and caller needs to dive into the node himself. | bindReachableStatement | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function appendSymbolNameOnly(symbol, writer) {
writer.writeSymbol(getNameOfSymbol(symbol), symbol);
} | Writes only the name of the symbol out to the writer. Uses the original source text
for the name of the symbol if it is available to match how the user inputted the name. | appendSymbolNameOnly | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) {
var parentSymbol;
function appendParentTypeArgumentsAndSymbolName(symbol) {
if (parentSymbol) {
// Write type arguments of instantiated class/interfa... | Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope
Meaning needs to be specified if the enclosing declaration is given | buildSymbolDisplay | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function pushTypeResolution(target, propertyName) {
var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName);
if (resolutionCycleStartIndex >= 0) {
// A cycle was found
var length_2 = resolutionTargets.length;
for (var i ... | Push an entry on the type resolution stack. If an entry with the given target and the given property name
is already on the stack, and no entries in between already have a type, then a circularity has occurred.
In this case, the result values of the existing entry and all entries pushed after it are changed to false,
a... | pushTypeResolution | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getApparentTypeOfTypeParameter(type) {
if (!type.resolvedApparentType) {
var constraintType = getConstraintOfTypeParameter(type);
while (constraintType && constraintType.flags & 512 /* TypeParameter */) {
constraintType = getConstraintOfTypeParame... | The apparent type of a type parameter is the base constraint instantiated with the type parameter
as the type argument for the 'this' type. | getApparentTypeOfTypeParameter | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getGlobalESSymbolConstructorSymbol() {
return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"));
} | Returns a type that is inside a namespace at the global scope, e.g.
getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type | getGlobalESSymbolConstructorSymbol | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
} | Instantiates a global type that is generic with some element type, and returns that instantiation. | createTypeFromGenericGlobalType | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) {
var errorInfo;
var sourceStack;
var targetStack;
var maybeStack;
var expandingFlags;
var depth = 0;
var overflow = false;
... | Checks if 'source' is related to 'target' (e.g.: is a assignable to).
@param source The left-hand-side of the relation.
@param target The right-hand-side of the relation.
@param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'.
Used as both to determine which check... | checkTypeRelatedTo | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isTupleType(type) {
return !!(type.flags & 8192 /* Tuple */);
} | Check if a Type was written as a tuple type literal.
Prefer using isTupleLikeType() unless the use of `elementTypes` is required. | isTupleType | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function reportWideningErrorsInType(type) {
var errorReported = false;
if (type.flags & 16384 /* Union */) {
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
var t = _a[_i];
if (reportWideningErrorsInType(t)) {
... | Reports implicit any errors that occur as a result of widening 'null' and 'undefined'
to 'any'. A call to reportWideningErrorsInType is normally accompanied by a call to
getWidenedType. But in some cases getWidenedType is called without reporting errors
(type argument inference is an example).
The return value indicat... | reportWideningErrorsInType | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getContextualType(node) {
if (isInsideWithStatementBody(node)) {
// We cannot answer semantic questions within a with block, do not proceed any further
return undefined;
}
if (node.contextualType) {
return node.contextualType;
... | Woah! Do you really want to use this function?
Unless you're trying to get the *non-apparent* type for a
value-literal type or you're authoring relevant portions of this algorithm,
you probably meant to use 'getApparentTypeOfContextualType'.
Otherwise this may not be very useful.
In cases where you *are* working on t... | getContextualType | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isInferentialContext(mapper) {
return mapper && mapper.context;
} | Detect if the mapper implies an inference context. Specifically, there are 4 possible values
for a mapper. Let's go through each one of them:
1. undefined - this means we are not doing inferential typing, but we may do contextual typing,
which could cause us to assign a parameter a type
2. identityMapper -... | isInferentialContext | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function isUnhyphenatedJsxName(name) {
// - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers
return name.indexOf("-") < 0;
} | Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers | isUnhyphenatedJsxName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getJsxElementPropertiesName() {
// JSX
var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined);
// JSX.ElementAttributesProperty [symbol]
var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxN... | Given a JSX element that is a class element, finds the Element Instance Type. If the
element is not a class element, or the class element type cannot be determined, returns 'undefined'.
For example, in the element <MyClass>, the element instance type is `MyClass` (not `typeof MyClass`). | getJsxElementPropertiesName | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getJsxGlobalElementClassType() {
if (!jsxElementClassType) {
jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass);
}
return jsxElementClassType;
} | Given a JSX attribute, returns the symbol for the corresponds property
of the element attributes type. Will return unknownSymbol for attributes
that have no matching element attributes type property. | getJsxGlobalElementClassType | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function checkClassPropertyAccess(node, left, type, prop) {
var flags = getDeclarationFlagsFromSymbol(prop);
var declaringClass = getDeclaredTypeOfSymbol(prop.parent);
if (left.kind === 95 /* SuperKeyword */) {
var errorNode = node.kind === 166 /* PropertyAccessExpres... | Check whether the requested property access is valid.
Returns true if node is a valid property access, and false otherwise.
@param node The node to be checked.
@param left The left hand side of the property access (e.g.: the super in `super.foo`).
@param type The type of left.
@param prop The symbol for the right hand ... | checkClassPropertyAccess | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getEffectiveDecoratorFirstArgumentType(node) {
// The first argument to a decorator is its `target`.
if (node.kind === 214 /* ClassDeclaration */) {
// For a class decorator, the `target` is the type of the class (e.g. the
// "static" or "constructor" sid... | Returns the effective type of the first argument to a decorator.
If 'node' is a class declaration or class expression, the effective argument type
is the type of the static side of the class.
If 'node' is a parameter declaration, the effective argument type is either the type
of the static or instance side of the... | getEffectiveDecoratorFirstArgumentType | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getEffectiveDecoratorThirdArgumentType(node) {
// The third argument to a decorator is either its `descriptor` for a method decorator
// or its `parameterIndex` for a paramter decorator
if (node.kind === 214 /* ClassDeclaration */) {
ts.Debug.fail("Class deco... | Returns the effective argument type for the third argument to a decorator.
If 'node' is a parameter, the effective argument type is the number type.
If 'node' is a method or accessor, the effective argument type is a
`TypedPropertyDescriptor<T>` instantiated with the type of the member.
Class and property decorators... | getEffectiveDecoratorThirdArgumentType | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function resolveCall(node, signatures, candidatesOutArray, headMessage) {
var isTaggedTemplate = node.kind === 170 /* TaggedTemplateExpression */;
var isDecorator = node.kind === 139 /* Decorator */;
var typeArguments;
if (!isTaggedTemplate && !isDecorator) {
... | Gets the error node to use when reporting errors for an effective argument. | resolveCall | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function checkCallExpression(node) {
// Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true
checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments);
var signature = getResolvedSignature(node);
if (nod... | Syntactically and semantically checks a call or new expression.
@param node The call/new expression to be checked.
@returns On success, the expression's signature's return type. On failure, anyType. | checkCallExpression | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getTypeOfFirstParameterOfSignature(signature) {
return getTypeAtPosition(signature, 0);
} | Gets the "promised type" of a promise.
@param type The type of the promise.
@remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. | getTypeOfFirstParameterOfSignature | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getAwaitedType(type) {
return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined);
} | Gets the "awaited type" of a type.
@param type The type to await.
@remarks The "awaited type" of an expression is its "promised type" if the expression is a
Promise-like type; otherwise, it is the type of the expression. This is used to reflect
The runtime behavior of the `await` keyword. | getAwaitedType | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function checkAsyncFunctionReturnType(node) {
var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType();
if (globalPromiseConstructorLikeType === emptyObjectType) {
// If we couldn't resolve the global PromiseConstructorLike type we cannot verify
... | Checks the return type of an async function to ensure it is a compatible
Promise implementation.
@param node The signature to check
@param returnType The return type for the function
@remarks
This checks that an async function has a valid Promise-compatible return type,
and returns the *awaited type* of the promise. An... | checkAsyncFunctionReturnType | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getElementTypeOfIterable(type, errorNode) {
if (isTypeAny(type)) {
return undefined;
}
var typeAsIterable = type;
if (!typeAsIterable.iterableElementType) {
// As an optimization, if the type is instantiated directly using the glob... | We want to treat type as an iterable, and get the type it is an iterable of. The iterable
must have the following structure (annotated with the names of the variables below):
{ // iterable
[Symbol.iterator]: { // iteratorFunction
(): Iterator<T>
}
}
T is the type we are after. At every level that invo... | getElementTypeOfIterable | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function getElementTypeOfIterator(type, errorNode) {
if (isTypeAny(type)) {
return undefined;
}
var typeAsIterator = type;
if (!typeAsIterator.iteratorElementType) {
// As an optimization, if the type is instantiated directly using the glob... | This function has very similar logic as getElementTypeOfIterable, except that it operates on
Iterators instead of Iterables. Here is the structure:
{ // iterator
next: { // iteratorNextFunction
(): { // iteratorNextResult
value: T // iteratorNextValue
}
}
} | getElementTypeOfIterator | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) {
ts.Debug.assert(languageVersion < 2 /* ES6 */);
// After we remove all types that are StringLike, we will know if there was a string constituent
// based on whether the remaining type is the same as the initial ... | This function does the following steps:
1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents.
2. Take the element types of the array constituents.
3. Return the union of the element types, and string if there was a string constitutent.
For example:
string -> st... | checkElementTypeOfArrayOrString | javascript | amol-/dukpy | dukpy/jsmodules/typescriptServices.js | https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js | MIT |
function copySymbols(source, meaning) {
if (meaning) {
for (var id in source) {
var symbol = source[id];
copySymbol(symbol, meaning);
}
}
} | Copy the given symbol into symbol tables if the symbol has the given meaning
and it doesn't already existed in the symbol table
@param key a key for storing in symbol table; if undefined, use symbol.name
@param symbol the symbol to be added into symbol table
@param meaning meaning of symbol to filter by before adding t... | copySymbols | 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.