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 |
|---|---|---|---|---|---|---|---|
function onTag(tag, html, options) {
// do nothing
} | default onTag function
@param {String} tag
@param {String} html
@param {Object} options
@return {String} | onTag | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function onIgnoreTag(tag, html, options) {
// do nothing
} | default onIgnoreTag function
@param {String} tag
@param {String} html
@param {Object} options
@return {String} | onIgnoreTag | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function onTagAttr(tag, name, value) {
// do nothing
} | default onTagAttr function
@param {String} tag
@param {String} name
@param {String} value
@return {String} | onTagAttr | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function onIgnoreTagAttr(tag, name, value) {
// do nothing
} | default onIgnoreTagAttr function
@param {String} tag
@param {String} name
@param {String} value
@return {String} | onIgnoreTagAttr | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeHtml(html) {
return html.replace(REGEXP_LT, "<").replace(REGEXP_GT, ">");
} | default escapeHtml function
@param {String} html | escapeHtml | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function safeAttrValue(tag, name, value, cssFilter) {
// unescape attribute value firstly
value = friendlyAttrValue(value);
if (name === "href" || name === "src") {
// filter `href` and `src` attribute
// only allow the value that starts with `http://` | `https://` | `mailto:` | `/` | `#`
value = _.t... | default safeAttrValue function
@param {String} tag
@param {String} name
@param {String} value
@param {Object} cssFilter
@return {String} | safeAttrValue | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeQuote(str) {
return str.replace(REGEXP_QUOTE, """);
} | escape double quote
@param {String} str
@return {String} str | escapeQuote | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function unescapeQuote(str) {
return str.replace(REGEXP_QUOTE_2, '"');
} | unescape double quote
@param {String} str
@return {String} str | unescapeQuote | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeHtmlEntities(str) {
return str.replace(REGEXP_ATTR_VALUE_1, function replaceUnicode(str, code) {
return code[0] === "x" || code[0] === "X"
? String.fromCharCode(parseInt(code.substr(1), 16))
: String.fromCharCode(parseInt(code, 10));
});
} | escape html entities
@param {String} str
@return {String} | escapeHtmlEntities | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeDangerHtml5Entities(str) {
return str
.replace(REGEXP_ATTR_VALUE_COLON, ":")
.replace(REGEXP_ATTR_VALUE_NEWLINE, " ");
} | escape html5 new danger entities
@param {String} str
@return {String} | escapeDangerHtml5Entities | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function clearNonPrintableCharacter(str) {
var str2 = "";
for (var i = 0, len = str.length; i < len; i++) {
str2 += str.charCodeAt(i) < 32 ? " " : str.charAt(i);
}
return _.trim(str2);
} | clear nonprintable characters
@param {String} str
@return {String} | clearNonPrintableCharacter | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function friendlyAttrValue(str) {
str = unescapeQuote(str);
str = escapeHtmlEntities(str);
str = escapeDangerHtml5Entities(str);
str = clearNonPrintableCharacter(str);
return str;
} | get friendly attribute value
@param {String} str
@return {String} | friendlyAttrValue | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function escapeAttrValue(str) {
str = escapeQuote(str);
str = escapeHtml(str);
return str;
} | unescape attribute value
@param {String} str
@return {String} | escapeAttrValue | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function onIgnoreTagStripAll() {
return "";
} | `onIgnoreTag` function for removing all the tags that are not in whitelist | onIgnoreTagStripAll | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function StripTagBody(tags, next) {
if (typeof next !== "function") {
next = function () {};
}
var isRemoveAllTag = !Array.isArray(tags);
function isRemoveTag(tag) {
if (isRemoveAllTag) return true;
return _.indexOf(tags, tag) !== -1;
}
var removeList = [];
var posStart = false;
return {
... | remove tag body
specify a `tags` list, if the tag is not in the `tags` list then process by the specify function (optional)
@param {array} tags
@param {function} next | StripTagBody | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function stripCommentTag(html) {
var retHtml = "";
var lastPos = 0;
while (lastPos < html.length) {
var i = html.indexOf("<!--", lastPos);
if (i === -1) {
retHtml += html.slice(lastPos);
break;
}
retHtml += html.slice(lastPos, i);
var j = html.indexOf("-->", i);
if (j === -1) {... | remove html comments
@param {String} html
@return {String} | stripCommentTag | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function stripBlankChar(html) {
var chars = html.split("");
chars = chars.filter(function (char) {
var c = char.charCodeAt(0);
if (c === 127) return false;
if (c <= 31) {
if (c === 10 || c === 13) return true;
return false;
}
return true;
});
return chars.join("");
} | remove invisible characters
@param {String} html
@return {String} | stripBlankChar | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function filterXSS(html, options) {
var xss = new FilterXSS(options);
return xss.process(html);
} | filter xss function
@param {String} html
@param {Object} options { whiteList, onTag, onTagAttr, onIgnoreTag, onIgnoreTagAttr, safeAttrValue, escapeHtml }
@return {String} | filterXSS | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function getTagName(html) {
var i = _.spaceIndex(html);
var tagName;
if (i === -1) {
tagName = html.slice(1, -1);
} else {
tagName = html.slice(1, i + 1);
}
tagName = _.trim(tagName).toLowerCase();
if (tagName.slice(0, 1) === "/") tagName = tagName.slice(1);
if (tagName.slice(-1) === "/") tagNam... | get tag name
@param {String} html e.g. '<a hef="#">'
@return {String} | getTagName | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function parseTag(html, onTag, escapeHtml) {
"use strict";
var rethtml = "";
var lastPos = 0;
var tagStart = false;
var quoteStart = false;
var currentPos = 0;
var len = html.length;
var currentTagName = "";
var currentHtml = "";
chariterator: for (currentPos = 0; currentPos < len; currentPos++) {... | parse input html and returns processed html
@param {String} html
@param {Function} onTag e.g. function (sourcePosition, position, tag, html, isClosing)
@param {Function} escapeHtml
@return {String} | parseTag | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function addAttr(name, value) {
name = _.trim(name);
name = name.replace(REGEXP_ILLEGAL_ATTR_NAME, "").toLowerCase();
if (name.length < 1) return;
var ret = onAttr(name, value || "");
if (ret) retAttrs.push(ret);
} | parse input attributes and returns processed attributes
@param {String} html e.g. `href="#" target="_blank"`
@param {Function} onAttr e.g. `function (name, value)`
@return {String} | addAttr | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function isNull(obj) {
return obj === undefined || obj === null;
} | returns `true` if the input value is `undefined` or `null`
@param {Object} obj
@return {Boolean} | isNull | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function getAttrs(html) {
var i = _.spaceIndex(html);
if (i === -1) {
return {
html: "",
closing: html[html.length - 2] === "/",
};
}
html = _.trim(html.slice(i + 1, -1));
var isClosing = html[html.length - 1] === "/";
if (isClosing) html = _.trim(html.slice(0, -1));
return {
html:... | get attributes for a tag
@param {String} html
@return {Object}
- {String} html
- {Boolean} closing | getAttrs | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function shallowCopyObject(obj) {
var ret = {};
for (var i in obj) {
ret[i] = obj[i];
}
return ret;
} | shallow copy
@param {Object} obj
@return {Object} | shallowCopyObject | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function FilterXSS(options) {
options = shallowCopyObject(options || {});
if (options.stripIgnoreTag) {
if (options.onIgnoreTag) {
console.error(
'Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time'
);
}
options.onIgnoreTag = DEFAULT.onIgnoreTagS... | FilterXSS class
@param {Object} options
whiteList (or allowList), onTag, onTagAttr, onIgnoreTag,
onIgnoreTagAttr, safeAttrValue, escapeHtml
stripIgnoreTagBody, allowCommentTag, stripBlankChar
css{whiteList, onAttr, onIgnoreAttr} `css=false` means don't use `cssfilter` | FilterXSS | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
_extend = function (dst){
var args = arguments, i = 1, _ext = function (val, key){ dst[key] = val; };
for( ; i < args.length; i++ ){
_each(args[i], _ext);
}
return dst;
} | Merge the contents of two or more objects together into the first object | _extend | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/FileAPI.js | MIT |
function Image(file){
if( file instanceof Image ){
var img = new Image(file.file);
api.extend(img.matrix, file.matrix);
return img;
}
else if( !(this instanceof Image) ){
return new Image(file);
}
this.file = file;
this.size = file.size || 100;
this.matrix = {
sx: 0,
sy: 0,
sw: ... | Remove drag'n'drop
@param {HTMLElement} el
@param {Function} onHover
@param {Function} onDrop | Image | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/FileAPI.js | MIT |
_complete = function (err){
_this._active = !err;
clearTimeout(_failId);
clearTimeout(_successId);
// api.event.off(video, 'loadedmetadata', _complete);
callback && callback(err, _this);
} | Start camera streaming
@param {Function} callback | _complete | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/FileAPI.js | MIT |
doneFn = function (err){
if( err ){
callback(err);
}
else {
// Get camera
var cam = Camera.get(el);
if( options.start ){
cam.start(callback);
}
else {
callback(null, cam);
}
}
} | Publish camera element into container
@static
@param {HTMLElement} el
@param {Object} options
@param {Function} [callback] | doneFn | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/FileAPI.js | MIT |
function _px(val){
return val >= 0 ? val + 'px' : val;
} | Add "px" postfix, if value is a number
@private
@param {*} val
@return {String} | _px | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/FileAPI.js | MIT |
function _detectVideoSignal(video){
var canvas = document.createElement('canvas'), ctx, res = false;
try {
ctx = canvas.getContext('2d');
ctx.drawImage(video, 0, 0, 1, 1);
res = ctx.getImageData(0, 0, 1, 1).data[4] != 255;
}
catch( e ){}
return res;
} | @private
@param {HTMLVideoElement} video
@return {Boolean} | _detectVideoSignal | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/FileAPI.js | MIT |
function _wrap(fn) {
var id = fn.wid = api.uid();
api.Flash._fn[id] = fn;
return 'FileAPI.Flash._fn.' + id;
} | FileAPI fallback to Flash
@flash-developer "Vladimir Demidov" <v.demidov@corp.mail.ru> | _wrap | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/FileAPI.js | MIT |
function sendHttp(config) {
config.method = config.method || 'POST';
config.headers = config.headers || {};
var deferred = config._deferred = config._deferred || $q.defer();
var promise = deferred.promise;
function notifyProgress(e) {
if (deferred.notify) {
deferred.notify(e);
... | !
AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
progress, resize, thumbnail, preview, validation and CORS
@author Danial <danial.farid@gmail.com>
@version 12.2.13 | sendHttp | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-file-upload-all.js | MIT |
calculateAspectRatioFit = function (srcWidth, srcHeight, maxWidth, maxHeight, centerCrop) {
var ratio = centerCrop ? Math.max(maxWidth / srcWidth, maxHeight / srcHeight) :
Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
return {
width: srcWidth * ratio, height: srcHeight * ratio,
marginX... | Conserve aspect ratio of the original region. Useful when shrinking/enlarging
images to fit into a certain area.
Source: http://stackoverflow.com/a/14731922
@param {Number} srcWidth Source area width
@param {Number} srcHeight Source area height
@param {Number} maxWidth Nestable area maximum available width
@param {Nu... | calculateAspectRatioFit | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-file-upload-all.js | MIT |
function addEvent(element, event, handler) {
if (element.addEventListener) {
element.addEventListener(event, handler, false);
} else if (element.attachEvent) {
element.attachEvent("on" + event, handler);
}
} | EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js) | addEvent | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/ng-img-crop.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js | MIT |
getChangedTouches=function(event){
if(angular.isDefined(event.changedTouches)){
return event.changedTouches;
}else{
return event.originalEvent.changedTouches;
}
} | Returns event.changedTouches directly if event is a TouchEvent.
If event is a jQuery event, return changedTouches of event.originalEvent | getChangedTouches | javascript | danialfarid/ng-file-upload | demo/src/main/webapp/js/ng-img-crop.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js | MIT |
function notifyProgress(e) {
if (deferred.notify) {
deferred.notify(e);
}
if (promise.progressFunc) {
$timeout(function () {
promise.progressFunc(e);
});
}
} | !
AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
progress, resize, thumbnail, preview, validation and CORS
@author Danial <danial.farid@gmail.com>
@version <%= pkg.version %> | notifyProgress | javascript | danialfarid/ng-file-upload | src/upload.js | https://github.com/danialfarid/ng-file-upload/blob/master/src/upload.js | MIT |
static k_combinations(set, k) {
var i, j, combs, head, tailcombs;
if (k > set.length || k <= 0) {
return [];
}
if (k === set.length) {
return [set];
}
if (k === 1) {
combs = [];
for (i = 0; i < set.length; i++) {
combs.push([set[i]]);
}
return combs;
}
// Assert ... | K-combinations
Get k-sized combinations of elements in a set.
Usage:
k_combinations(set, k)
Parameters:
set: Array of objects of any type. They are treated as unique.
k: size of combinations to search for.
Return:
Array of found combinations, size of a combination is k.
Examples:
k_combinations([1, 2, 3... | k_combinations | javascript | CharlieHess/slack-poker-bot | util/combinations.js | https://github.com/CharlieHess/slack-poker-bot/blob/master/util/combinations.js | MIT |
static combinations(set) {
var k, i, combs, k_combs;
combs = [];
// Calculate all non-empty k-combinations
for (k = 1; k <= set.length; k++) {
k_combs = Combinations.k_combinations(set, k);
for (i = 0; i < k_combs.length; i++) {
combs.push(k_combs[i]);
}
}
return combs;
} | Combinations
Get all possible combinations of elements in a set.
Usage:
combinations(set)
Examples:
combinations([1, 2, 3])
-> [[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]
combinations([1])
-> [[1]] | combinations | javascript | CharlieHess/slack-poker-bot | util/combinations.js | https://github.com/CharlieHess/slack-poker-bot/blob/master/util/combinations.js | MIT |
U = function (a, b) {
if (!a) {
return '';
}
b = b || 'x';
var c = '';
var d = 0;
var e;
for (d; d < a.length; d += 1) a.charCodeAt(d) >= 55296 && a.charCodeAt(d) <= 56319 ? (e = (65536 + 1024 * (Number(a.charCodeAt(d)) - 55296) + Number(a.charCodeAt(... | @Keyboard.js
@author zhangxinxu
@version
Created: 17-06-13 | U | javascript | yued-fe/lulu | theme/edge/js/common/all.js | https://github.com/yued-fe/lulu/blob/master/theme/edge/js/common/all.js | MIT |
static get observedAttributes () {
return ['open'];
} | @Pagination.js
@author sunmeiye
@version
@Created: 20-06-07
@edit: 20-06-07 | observedAttributes | javascript | yued-fe/lulu | theme/edge/js/common/all.js | https://github.com/yued-fe/lulu/blob/master/theme/edge/js/common/all.js | MIT |
get reverse () {
return this.getAttribute('reverse') !== null || this.classList.contains('reverse');
} | @LightTip.js
@author popeyesailorman(yangfan)
@version
@Created: 20-05-15
@edit: 20-05-15 | reverse | javascript | yued-fe/lulu | theme/edge/js/common/all.js | https://github.com/yued-fe/lulu/blob/master/theme/edge/js/common/all.js | MIT |
remove () {
if (this.parentElement) {
this.parentElement.removeChild(this);
}
this.open = false;
} | @Range.js
@author xboxyan
@version
@created: 20-04-30 | remove | javascript | yued-fe/lulu | theme/edge/js/common/all.js | https://github.com/yued-fe/lulu/blob/master/theme/edge/js/common/all.js | MIT |
get () {
return !!(this.classList.contains(CL) || this.matches(CL));
} | @Color.js
@author zhangxinxu
@version
@created 16-06-03
@edited 20-07-16 @Gwokhov | get | javascript | yued-fe/lulu | theme/edge/js/common/all.js | https://github.com/yued-fe/lulu/blob/master/theme/edge/js/common/all.js | MIT |
get () {
return document.validate.getValidity(this);
} | @Pagination.js
@author XboxYan(yanwenbin)
@version
@Created: 20-04-22
@edit: 20-04-22 | get | javascript | yued-fe/lulu | theme/edge/js/common/all.js | https://github.com/yued-fe/lulu/blob/master/theme/edge/js/common/all.js | MIT |
static get observedAttributes () {
return ['open', 'target'];
} | @Drop.js
@author zhangxinxu
@version
@created 15-06-30
@edited 20-07-08 edit by wanglei | observedAttributes | javascript | yued-fe/lulu | theme/edge/js/common/ui/Drop.js | https://github.com/yued-fe/lulu/blob/master/theme/edge/js/common/ui/Drop.js | MIT |
static allHide (exclude) {
ErrorTip.collectionErrorTip.forEach(obj => {
if (exclude != obj) {
obj.hide();
}
});
} | @ErrorTip.js
@author zhangxinxu
@version
@created: 15-07-01
@edited: 20-07-07 edit by peter.qiyuanhao | allHide | javascript | yued-fe/lulu | theme/edge/js/common/ui/ErrorTip.js | https://github.com/yued-fe/lulu/blob/master/theme/edge/js/common/ui/ErrorTip.js | MIT |
static get observedAttributes () {
return ['title', 'reverse', 'for', 'eventType', 'align'];
} | @Tips.js
@author zhangxinxu
@version
@Created: 15-06-25
@edit: 17-06-19
@edit: 20-06-09 edit by y2x
@edit: 20-11-03 by zxx | observedAttributes | javascript | yued-fe/lulu | theme/edge/js/common/ui/Tips.js | https://github.com/yued-fe/lulu/blob/master/theme/edge/js/common/ui/Tips.js | MIT |
notify = (callback, root, MO) => {
const loop = (nodes, added, removed, connected, pass) => {
for (let i = 0, {length} = nodes; i < length; i++) {
const node = nodes[i];
if (pass || (QSA$1 in node)) {
if (connected) {
if (!added.has(node)) {
added.add(node);... | Start observing a generic document or root element.
@param {Function} callback triggered per each dis/connected node
@param {Element?} root by default, the global document to observe
@param {Function?} MO by default, the global MutationObserver
@returns {MutationObserver} | notify | javascript | yued-fe/lulu | theme/hope/ui/safari-polyfill.js | https://github.com/yued-fe/lulu/blob/master/theme/hope/ui/safari-polyfill.js | MIT |
static get defaults () {
return {
eventtype: 'click',
position: '7-5'
};
} | @Drop.js
@author zhangxinxu
@version
@created 15-06-30
@edited 20-07-08 edit by wanglei
@edited 22-06-16 edit by wanglei | defaults | javascript | yued-fe/lulu | theme/hope/ui/Drop/index.js | https://github.com/yued-fe/lulu/blob/master/theme/hope/ui/Drop/index.js | MIT |
set (value) {
if (this.validate) {
this.validate.setCustomValidity(value);
}
} | / if (!CSS.supports('overflow-anchor:auto') || !CSS.supports('offset:none')) {
/* | set | javascript | yued-fe/lulu | theme/hope/ui/Form/index.js | https://github.com/yued-fe/lulu/blob/master/theme/hope/ui/Form/index.js | MIT |
static get observedAttributes () {
return ['rows', 'height', 'width', 'label', 'font', 'minLength', 'maxLength'];
} | /import promiseInput from '../Input/index.js';
/* | observedAttributes | javascript | yued-fe/lulu | theme/hope/ui/Textarea/index.js | https://github.com/yued-fe/lulu/blob/master/theme/hope/ui/Textarea/index.js | MIT |
LightTip = function() {
this.el = {};
return this;
} | @Range.js
@author xunxuzhang
@version
Created: 15-07-20 | LightTip | javascript | yued-fe/lulu | theme/modern/js/common/all.js | https://github.com/yued-fe/lulu/blob/master/theme/modern/js/common/all.js | MIT |
checkIfIteratorIsSupported = function () {
try {
return !!Symbol.iterator;
} catch (error) {
return false;
}
} | Polyfill URLSearchParams
Inspired from : https://github.com/WebReflection/url-search-params/blob/master/src/url-search-params.js | checkIfIteratorIsSupported | javascript | yued-fe/lulu | theme/pure/js/common/polyfill.js | https://github.com/yued-fe/lulu/blob/master/theme/pure/js/common/polyfill.js | MIT |
serializeParam = function (value) {
return encodeURIComponent(value).replace(/%20/g, '+');
} | Search param name and values should be encoded according to https://url.spec.whatwg.org/#urlencoded-serializing
encodeURIComponent() produces the same result except encoding spaces as `%20` instead of `+`. | serializeParam | javascript | yued-fe/lulu | theme/pure/js/common/polyfill.js | https://github.com/yued-fe/lulu/blob/master/theme/pure/js/common/polyfill.js | MIT |
checkIfURLIsSupported = function () {
try {
var u = new global.URL('b', 'http://a');
u.pathname = 'c%20d';
return (u.href === 'http://a/c%20d') && u.searchParams;
} catch (e) {
return false;
}
} | Polyfill URL
Inspired from : https://github.com/arv/DOM-URL-Polyfill/blob/master/src/url.js | checkIfURLIsSupported | javascript | yued-fe/lulu | theme/pure/js/common/polyfill.js | https://github.com/yued-fe/lulu/blob/master/theme/pure/js/common/polyfill.js | MIT |
function FormData (form) {
var
self = this;
if (!(self instanceof FormData)) {
return new FormData(form);
}
if (form && (!form.tagName || form.tagName !== 'FORM')) { // not a form
return;
}
self._boundary = createBoundary();
... | [FormData description]
@contructor
@param {?HTMLForm} form HTML <form> element to populate the object (optional) | FormData | javascript | yued-fe/lulu | theme/pure/js/common/polyfill.js | https://github.com/yued-fe/lulu/blob/master/theme/pure/js/common/polyfill.js | MIT |
CustomEvent = function (event, params) {
params = params || {
bubbles: false,
cancelable: false,
detail: undefined
};
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
r... | CustomEvent constructor polyfill for IE
@return {[type]} [description] | CustomEvent | javascript | yued-fe/lulu | theme/pure/js/common/polyfill.js | https://github.com/yued-fe/lulu/blob/master/theme/pure/js/common/polyfill.js | MIT |
function has (key) {
return this._data.hasOwnProperty(key);
} | @description placeholder polyfill for IE9
only support one line
no consideration of settings placeholder attr
@author zhangxinxu(.com)
@created 2019-08-09 | has | javascript | yued-fe/lulu | theme/pure/js/common/polyfill.js | https://github.com/yued-fe/lulu/blob/master/theme/pure/js/common/polyfill.js | MIT |
function BufferList(context, bufferData, options) {
this._context = Utils.isAudioContext(context) ?
context :
Utils.throw('BufferList: Invalid BaseAudioContext.');
this._options = {
dataType: BufferDataType.BASE64,
verbose: false,
};
if (options) {
if (options.dataType &&
Utils... | BufferList object mananges the async loading/decoding of multiple
AudioBuffers from multiple URLs.
@constructor
@param {BaseAudioContext} context - Associated BaseAudioContext.
@param {string[]} bufferData - An ordered list of URLs.
@param {Object} options - Options
@param {string} [options.dataType='base64'] - BufferD... | BufferList | javascript | GoogleChrome/omnitone | src/buffer-list.js | https://github.com/GoogleChrome/omnitone/blob/master/src/buffer-list.js | Apache-2.0 |
function FOAConvolver(context, hrirBufferList) {
this._context = context;
this._active = false;
this._isBufferLoaded = false;
this._buildAudioGraph();
if (hrirBufferList) {
this.setHRIRBufferList(hrirBufferList);
}
this.enable();
} | FOAConvolver. A collection of 2 stereo convolvers for 4-channel FOA stream.
@constructor
@param {BaseAudioContext} context The associated AudioContext.
@param {AudioBuffer[]} [hrirBufferList] - An ordered-list of stereo
AudioBuffers for convolution. (i.e. 2 stereo AudioBuffers for FOA) | FOAConvolver | javascript | GoogleChrome/omnitone | src/foa-convolver.js | https://github.com/GoogleChrome/omnitone/blob/master/src/foa-convolver.js | Apache-2.0 |
function FOARenderer(context, config) {
this._context = Utils.isAudioContext(context) ?
context :
Utils.throw('FOARenderer: Invalid BaseAudioContext.');
this._config = {
channelMap: FOARouter.ChannelMap.DEFAULT,
renderingMode: RenderingMode.AMBISONIC,
};
if (config) {
if (config.channe... | Omnitone FOA renderer class. Uses the optimized convolution technique.
@constructor
@param {AudioContext} context - Associated AudioContext.
@param {Object} config
@param {Array} [config.channelMap] - Custom channel routing map. Useful for
handling the inconsistency in browser's multichannel audio decoding.
@param {Arr... | FOARenderer | javascript | GoogleChrome/omnitone | src/foa-renderer.js | https://github.com/GoogleChrome/omnitone/blob/master/src/foa-renderer.js | Apache-2.0 |
function FOARotator(context) {
this._context = context;
this._splitter = this._context.createChannelSplitter(4);
this._inY = this._context.createGain();
this._inZ = this._context.createGain();
this._inX = this._context.createGain();
this._m0 = this._context.createGain();
this._m1 = this._context.createGa... | First-order-ambisonic decoder based on gain node network.
@constructor
@param {AudioContext} context - Associated AudioContext. | FOARotator | javascript | GoogleChrome/omnitone | src/foa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/foa-rotator.js | Apache-2.0 |
function FOARouter(context, channelMap) {
this._context = context;
this._splitter = this._context.createChannelSplitter(4);
this._merger = this._context.createChannelMerger(4);
// input/output proxy.
this.input = this._splitter;
this.output = this._merger;
this.setChannelMap(channelMap || ChannelMap.DE... | Channel router for FOA stream.
@constructor
@param {AudioContext} context - Associated AudioContext.
@param {Number[]} channelMap - Routing destination array. | FOARouter | javascript | GoogleChrome/omnitone | src/foa-router.js | https://github.com/GoogleChrome/omnitone/blob/master/src/foa-router.js | Apache-2.0 |
function HOAConvolver(context, ambisonicOrder, hrirBufferList) {
this._context = context;
this._active = false;
this._isBufferLoaded = false;
// The number of channels K based on the ambisonic order N where K = (N+1)^2.
this._ambisonicOrder = ambisonicOrder;
this._numberOfChannels =
(this._ambisonic... | A convolver network for N-channel HOA stream.
@constructor
@param {AudioContext} context - Associated AudioContext.
@param {Number} ambisonicOrder - Ambisonic order. (2 or 3)
@param {AudioBuffer[]} [hrirBufferList] - An ordered-list of stereo
AudioBuffers for convolution. (SOA: 5 AudioBuffers, TOA: 8 AudioBuffers) | HOAConvolver | javascript | GoogleChrome/omnitone | src/hoa-convolver.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-convolver.js | Apache-2.0 |
function HOARenderer(context, config) {
this._context = Utils.isAudioContext(context) ?
context :
Utils.throw('HOARenderer: Invalid BaseAudioContext.');
this._config = {
ambisonicOrder: 3,
renderingMode: RenderingMode.AMBISONIC,
};
if (config && config.ambisonicOrder) {
if (SupportedAm... | Omnitone HOA renderer class. Uses the optimized convolution technique.
@constructor
@param {AudioContext} context - Associated AudioContext.
@param {Object} config
@param {Number} [config.ambisonicOrder=3] - Ambisonic order.
@param {Array} [config.hrirPathList] - A list of paths to HRIR files. It
overrides the internal... | HOARenderer | javascript | GoogleChrome/omnitone | src/hoa-renderer.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-renderer.js | Apache-2.0 |
function getKroneckerDelta(i, j) {
return i === j ? 1 : 0;
} | Kronecker Delta function.
@param {Number} i
@param {Number} j
@return {Number} | getKroneckerDelta | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function setCenteredElement(matrix, l, i, j, gainValue) {
const index = (j + l) * (2 * l + 1) + (i + l);
// Row-wise indexing.
matrix[l - 1][index].gain.value = gainValue;
} | A helper function to allow us to access a matrix array in the same
manner, assuming it is a (2l+1)x(2l+1) matrix. [2] uses an odd convention of
referring to the rows and columns using centered indices, so the middle row
and column are (0, 0) and the upper left would have negative coordinates.
@param {Number[]} matrix -... | setCenteredElement | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function getCenteredElement(matrix, l, i, j) {
// Row-wise indexing.
const index = (j + l) * (2 * l + 1) + (i + l);
return matrix[l - 1][index].gain.value;
} | This is a helper function to allow us to access a matrix array in the same
manner, assuming it is a (2l+1) x (2l+1) matrix.
@param {Number[]} matrix - N matrices of gainNodes, each with (2n+1) x (2n+1)
elements, where n=1,2,...,N.
@param {Number} l
@param {Number} i
@param {Number} j
@return {Number} | getCenteredElement | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function getP(matrix, i, a, b, l) {
if (b === l) {
return getCenteredElement(matrix, 1, i, 1) *
getCenteredElement(matrix, l - 1, a, l - 1) -
getCenteredElement(matrix, 1, i, -1) *
getCenteredElement(matrix, l - 1, a, -l + 1);
} else if (b === -l) {
return getCenteredElement(matrix, ... | Helper function defined in [2] that is used by the functions U, V, W.
This should not be called on its own, as U, V, and W (and their coefficients)
select the appropriate matrix elements to access arguments |a| and |b|.
@param {Number[]} matrix - N matrices of gainNodes, each with (2n+1) x (2n+1)
elements, where n=1,2,... | getP | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function getU(matrix, m, n, l) {
// Although [1, 2] split U into three cases for m == 0, m < 0, m > 0
// the actual values are the same for all three cases.
return getP(matrix, 0, m, n, l);
} | The functions U, V, and W should only be called if the correspondingly
named coefficient u, v, w from the function ComputeUVWCoeff() is non-zero.
When the coefficient is 0, these would attempt to access matrix elements that
are out of bounds. The vector of rotations, |r|, must have the |l - 1|
previously completed band... | getU | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function getW(matrix, m, n, l) {
// Whenever this happens, w is also 0 so W can be anything.
if (m === 0) {
return 0;
}
return m > 0 ? getP(matrix, 1, m + 1, n, l) + getP(matrix, -1, -m - 1, n, l) :
getP(matrix, 1, m - 1, n, l) - getP(matrix, -1, -m + 1, n, l);
} | The functions U, V, and W should only be called if the correspondingly
named coefficient u, v, w from the function ComputeUVWCoeff() is non-zero.
When the coefficient is 0, these would attempt to access matrix elements that
are out of bounds. The vector of rotations, |r|, must have the |l - 1|
previously completed band... | getW | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function computeUVWCoeff(m, n, l) {
const d = getKroneckerDelta(m, 0);
const reciprocalDenominator =
Math.abs(n) === l ? 1 / (2 * l * (2 * l - 1)) : 1 / ((l + n) * (l - n));
return [
Math.sqrt((l + m) * (l - m) * reciprocalDenominator),
0.5 * (1 - 2 * d) * Math.sqrt((1 + d) *
... | Calculates the coefficients applied to the U, V, and W functions. Because
their equations share many common terms they are computed simultaneously.
@param {Number} m
@param {Number} n
@param {Number} l
@return {Array} 3 coefficients for U, V and W functions. | computeUVWCoeff | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function computeBandRotation(matrix, l) {
// The lth band rotation matrix has rows and columns equal to the number of
// coefficients within that band (-l <= m <= l implies 2l + 1 coefficients).
for (let m = -l; m <= l; m++) {
for (let n = -l; n <= l; n++) {
const uvwCoefficients = computeUVWCoeff(m, n,... | Calculates the (2l+1) x (2l+1) rotation matrix for the band l.
This uses the matrices computed for band 1 and band l-1 to compute the
matrix for band l. |rotations| must contain the previously computed l-1
rotation matrices.
This implementation comes from p. 5 (6346), Table 1 and 2 in [2] taking
into account the correc... | computeBandRotation | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function computeHOAMatrices(matrix) {
// We start by computing the 2nd-order matrix from the 1st-order matrix.
for (let i = 2; i <= matrix.length; i++) {
computeBandRotation(matrix, i);
}
} | Compute the HOA rotation matrix after setting the transform matrix.
@param {Array} matrix - N matrices of gainNodes, each with (2n+1) x (2n+1)
elements, where n=1,2,...,N. | computeHOAMatrices | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function HOARotator(context, ambisonicOrder) {
this._context = context;
this._ambisonicOrder = ambisonicOrder;
// We need to determine the number of channels K based on the ambisonic order
// N where K = (N + 1)^2.
const numberOfChannels = (ambisonicOrder + 1) * (ambisonicOrder + 1);
this._splitter = this... | Higher-order-ambisonic decoder based on gain node network. We expect
the order of the channels to conform to ACN ordering. Below are the helper
methods to compute SH rotation using recursion. The code uses maths described
in the following papers:
[1] R. Green, "Spherical Harmonic Lighting: The Gritty Details", GDC 200... | HOARotator | javascript | GoogleChrome/omnitone | src/hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/src/hoa-rotator.js | Apache-2.0 |
function generateExpectedBusFromFOAIRBuffer(buffer) {
var generatedBus = new AudioBus(2, buffer.length, buffer.sampleRate);
var W = buffer.getChannelData(0);
var Y = buffer.getChannelData(1);
var Z = buffer.getChannelData(2);
var X = buffer.getChannelData(3);
var L = generatedBus.getChannelData(... | Calculate the expected binaural rendering (based on SH-maxRE algorithm)
result from the impulse input and generate an AudioBus instance.
@param {AudioBuffer} buffer FOA SH-maxRE HRIR buffer.
@return {AudioBus} | generateExpectedBusFromFOAIRBuffer | javascript | GoogleChrome/omnitone | test/test-foa-convolver.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-foa-convolver.js | Apache-2.0 |
function generateExpectedBusFromTOAIRBuffer(buffer) {
// TOA IR set is 16 channels.
expect(buffer.numberOfChannels).to.equal(16);
// Derive ambisonic order from number of channels.
var ambisonicOrder = Math.floor(Math.sqrt(buffer.numberOfChannels)) - 1;
// Get pointers to each buffer.
var acnC... | Generate the expected binaural rendering (based on SH-maxRE algorithm)
result from the impulse response and generate an AudioBus instance.
@param {AudioBuffer} buffer TOA SH-maxRE HRIR buffer.
@return {AudioBus} | generateExpectedBusFromTOAIRBuffer | javascript | GoogleChrome/omnitone | test/test-hoa-convolver.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-hoa-convolver.js | Apache-2.0 |
function crossProduct(a, b) {
return [
a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2],
a[0] * b[1] - a[1] * b[0]
];
} | Compute cross-product between two 3-element vectors.
@param {Float32Array} a
@param {Float32Array} b | crossProduct | javascript | GoogleChrome/omnitone | test/test-hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-hoa-rotator.js | Apache-2.0 |
function generateRotationMatrix(azimuth, elevation) {
var forward = [
-Math.sin(azimuth) * Math.cos(elevation), Math.sin(elevation),
-Math.cos(azimuth) * Math.cos(elevation)
];
var right = normalize(crossProduct([0, 1, 0], forward));
var up = normalize(crossProduct(forward, right));
retu... | Generate a col-major 3x3 Euler rotation matrix.
@param {Number} azimuth
@param {Number} elevation | generateRotationMatrix | javascript | GoogleChrome/omnitone | test/test-hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-hoa-rotator.js | Apache-2.0 |
function computeRotationAndTest(index) {
it('#setRotationMatrix: rotate the incoming stream using direction [' +
sphericalDirections[index] + '].',
function(done) {
hoaRotator.setRotationMatrix3(generateRotationMatrix(
sphericalDirections[index][0], sphericalDirections[index]... | TODO: describe this test.
@param {Function} done Test runner callback.
@param {Number} index Direction idex. | computeRotationAndTest | javascript | GoogleChrome/omnitone | test/test-hoa-rotator.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-hoa-rotator.js | Apache-2.0 |
function createConstantBuffer(context, values, length) {
var constantBuffer = context.createBuffer(
values.length, length, context.sampleRate);
for (var channel = 0; channel < constantBuffer.numberOfChannels; channel++) {
var channelData = constantBuffer.getChannelData(channel);
for (var index = 0; i... | Create a buffer for testing. Each channel contains a stream of single,
user-defined value.
@param {AudioContext} context AudioContext.
@param {Array} values User-defined constant value for each
channel.
@param {Number} length Buffer length in samples.
@return {Au... | createConstantBuffer | javascript | GoogleChrome/omnitone | test/test-setup.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-setup.js | Apache-2.0 |
function createImpulseBuffer(context, numberOfChannels, length) {
var impulseBuffer = context.createBuffer(
numberOfChannels, length, context.sampleRate);
for (var channel = 0; channel < impulseBuffer.numberOfChannels; channel++) {
var channelData = impulseBuffer.getChannelData(channel);
channelData[... | Create a impulse buffer for testing. Each channel contains a single unity
value (1.0) at the beginning and the rest of content is all zero.
@param {AudioContext} context AudioContext
@param {Number} numberOfChannels Channel count.
@param {Number} length Buffer length in samples.
@return {AudioBuffer} | createImpulseBuffer | javascript | GoogleChrome/omnitone | test/test-setup.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-setup.js | Apache-2.0 |
function isConstantValueOf(channelData, value) {
var mismatches = {};
for (var i = 0; i < channelData.length; i++) {
if (channelData[i] !== value)
mismatches[i] = channelData[i];
}
return Object.keys(mismatches).length === 0;
} | Check if the array is filled with the specified value only.
@param {Float32Array} channelData The target array for testing.
@param {Number} value A value for the testing.
@return {Boolean} | isConstantValueOf | javascript | GoogleChrome/omnitone | test/test-setup.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-setup.js | Apache-2.0 |
function getDualBandFilterCoefs(crossoverFrequency, sampleRate) {
var k = Math.tan(Math.PI * crossoverFrequency / sampleRate),
k2 = k * k,
denominator = k2 + 2 * k + 1;
return {
lowpassA: [1, 2 * (k2 - 1) / denominator, (k2 - 2 * k + 1) / denominator],
lowpassB: [k2 / denominator, 2 * k2 / deno... | Generate the filter coefficients for the phase matched dual band filter.
@param {NUmber} crossoverFrequency Filter crossover frequency.
@param {NUmber} sampleRate Operating sample rate.
@return {Object} Filter coefficients.
{ lowpassA, lowpassB, hipassA, ... | getDualBandFilterCoefs | javascript | GoogleChrome/omnitone | test/test-setup.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-setup.js | Apache-2.0 |
function kernel_IIRFIlter (channelData, feedforward, feedback) {
var paddingSize = Math.max(feedforward.length, feedback.length);
var workSize = channelData.length + paddingSize;
var x = new Float32Array(workSize);
var y = new Float64Array(workSize);
x.set(channelData, paddingSize);
for (var index = paddi... | Kernel processor for IIR filter. (in-place processing)
@param {Float32Array} channelData A channel data.
@param {Float32Array} feedforward Feedforward coefficients.
@param {Float32Array} feedback Feedback coefficients. | kernel_IIRFIlter | javascript | GoogleChrome/omnitone | test/test-setup.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-setup.js | Apache-2.0 |
function AudioBus (numberOfChannels, length, sampleRate) {
this.numberOfChannels = numberOfChannels;
this.sampleRate = sampleRate;
this.length = length;
this.duration = this.length / this.sampleRate;
this._channelData = [];
for (var i = 0; i < this.numberOfChannels; ++i) {
this._channelData[i] = new Fl... | A collection of Float32Array as AudioBus abstraction.
@param {Number} numberOfChannels Number of channels.
@param {Number} length Buffer length in samples.
@param {Number} sampleRate Operating sample rate. | AudioBus | javascript | GoogleChrome/omnitone | test/test-setup.js | https://github.com/GoogleChrome/omnitone/blob/master/test/test-setup.js | Apache-2.0 |
mockTrace = () => ({
traceAsyncFn: (fn) => fn(mockTrace()),
traceFn: (fn) => fn(mockTrace()),
traceChild: () => mockTrace(),
}) | @typedef {{ file: string, excludedCases: string[] }} TestFile | mockTrace | javascript | vercel/next.js | run-tests.js | https://github.com/vercel/next.js/blob/master/run-tests.js | MIT |
async open (cacheName) {
webidl.brandCheck(this, CacheStorage)
webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.open' })
cacheName = webidl.converters.DOMString(cacheName)
// 2.1
if (this.#caches.has(cacheName)) {
// await caches.open('v1') !== await caches.open('v1')
... | @see https://w3c.github.io/ServiceWorker/#cache-storage-keys
@returns {string[]} | open | javascript | vercel/next.js | .github/actions/next-integration-stat/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js | MIT |
function mixinBody (prototype) {
Object.assign(prototype.prototype, bodyMixinMethods(prototype))
} | @see https://fetch.spec.whatwg.org/#concept-body-consume-body
@param {Response|Request} object
@param {(value: unknown) => unknown} convertBytesToJSValue
@param {Response|Request} instance | mixinBody | javascript | vercel/next.js | .github/actions/next-integration-stat/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js | MIT |
get lengthComputable () {
webidl.brandCheck(this, ProgressEvent)
return this[kState].lengthComputable
} | @see https://w3c.github.io/FileAPI/#readOperation
@param {import('./filereader').FileReader} fr
@param {import('buffer').Blob} blob
@param {string} type
@param {string?} encodingName | lengthComputable | javascript | vercel/next.js | .github/actions/next-integration-stat/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js | MIT |
async linkPackages({
repoDir,
nextSwcVersion: nextSwcVersionSpecified,
parentSpan,
}) {
if (!parentSpan) {
// Not all callers provide a parent span
parentSpan = mockSpan()
}
/** @type {Map<string, string>} */
const pkgPaths = new Map()
/** @type {Map<s... | Runs `pnpm pack` on each package in the `packages` folder of the provided `repoDir`
@param {{ repoDir: string, nextSwcVersion: null | string }} options Required options
@returns {Promise<Map<string, string>>} List packages key is the package name, value is the path to the packed tar file.' | linkPackages | javascript | vercel/next.js | .github/actions/next-stats-action/src/prepare/repo-setup.js | https://github.com/vercel/next.js/blob/master/.github/actions/next-stats-action/src/prepare/repo-setup.js | MIT |
constructor(command, opts) {
this.serialize = defaultSerializer;
this.deserialize = opts?.automaticDeserialization === void 0 || opts.automaticDeserialization ? opts?.deserialize ?? parseResponse : (x) => x;
this.command = command.map((c) => this.serialize(c));
if (opts?.latencyLogging) {
const or... | Create a new command instance.
You can define a custom `deserialize` function. By default we try to deserialize as json. | constructor | javascript | vercel/next.js | .github/actions/upload-turboyet-data/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js | MIT |
length() {
return this.commands.length;
} | Returns the length of pipeline before the execution | length | javascript | vercel/next.js | .github/actions/upload-turboyet-data/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js | MIT |
chain(command) {
this.commands.push(command);
return this;
} | Pushes a command into the pipeline and returns a chainable instance of the
pipeline | chain | javascript | vercel/next.js | .github/actions/upload-turboyet-data/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js | MIT |
get json() {
return {
/**
* @see https://redis.io/commands/json.arrappend
*/
arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
/**
* @see https://redis.io/commands/json.arrindex
*/
arrindex: (...args) => this.chain(new JsonAr... | @see https://redis.io/commands/?group=json | json | javascript | vercel/next.js | .github/actions/upload-turboyet-data/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js | MIT |
constructor(redis, script) {
this.redis = redis;
this.sha1 = this.digest(script);
this.script = script;
} | @see https://redis.io/commands/json.type | constructor | javascript | vercel/next.js | .github/actions/upload-turboyet-data/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js | MIT |
async eval(keys, args) {
return await this.redis.eval(this.script, keys, args);
} | Send an `EVAL` command to redis. | eval | javascript | vercel/next.js | .github/actions/upload-turboyet-data/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js | MIT |
async evalsha(keys, args) {
return await this.redis.evalsha(this.sha1, keys, args);
} | Calculates the sha1 hash of the script and then calls `EVALSHA`. | evalsha | javascript | vercel/next.js | .github/actions/upload-turboyet-data/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js | MIT |
async exec(keys, args) {
const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
return await this.redis.eval(this.script, keys, args);
}
throw error;
});
return res;
} | Optimistically try to run `EVALSHA` first.
If the script is not loaded in redis, it will fall back and try again with `EVAL`.
Following calls will be able to use the cached script | exec | javascript | vercel/next.js | .github/actions/upload-turboyet-data/dist/index.js | https://github.com/vercel/next.js/blob/master/.github/actions/upload-turboyet-data/dist/index.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.