repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
massgov/mayflower | patternlab/styleguide/public/styleguide/js/patternlab-viewer.js | function() {
var obj;
// not that the modal viewer is no longer active
DataSaver.updateValue('modalActive', 'false');
modalViewer.active = false;
//Add active class to modal
$('#sg-modal-container').removeClass('active');
// remove the active class from all of the checkbo... | javascript | function() {
var obj;
// not that the modal viewer is no longer active
DataSaver.updateValue('modalActive', 'false');
modalViewer.active = false;
//Add active class to modal
$('#sg-modal-container').removeClass('active');
// remove the active class from all of the checkbo... | [
"function",
"(",
")",
"{",
"var",
"obj",
";",
"// not that the modal viewer is no longer active",
"DataSaver",
".",
"updateValue",
"(",
"'modalActive'",
",",
"'false'",
")",
";",
"modalViewer",
".",
"active",
"=",
"false",
";",
"//Add active class to modal",
"$",
"(... | close the modal window | [
"close",
"the",
"modal",
"window"
] | 6ae90009c5d611f9fdbcc208f9bd5f1e22926094 | https://github.com/massgov/mayflower/blob/6ae90009c5d611f9fdbcc208f9bd5f1e22926094/patternlab/styleguide/public/styleguide/js/patternlab-viewer.js#L515-L539 | train | |
massgov/mayflower | patternlab/styleguide/public/styleguide/js/patternlab-viewer.js | function(patternData, iframePassback, switchText) {
// if this is a styleguide view close the modal
if (iframePassback) {
modalViewer.hide();
}
// gather the data that will fill the modal window
panelsViewer.gatherPanels(patternData, iframePassback, switchText);
} | javascript | function(patternData, iframePassback, switchText) {
// if this is a styleguide view close the modal
if (iframePassback) {
modalViewer.hide();
}
// gather the data that will fill the modal window
panelsViewer.gatherPanels(patternData, iframePassback, switchText);
} | [
"function",
"(",
"patternData",
",",
"iframePassback",
",",
"switchText",
")",
"{",
"// if this is a styleguide view close the modal",
"if",
"(",
"iframePassback",
")",
"{",
"modalViewer",
".",
"hide",
"(",
")",
";",
"}",
"// gather the data that will fill the modal windo... | refresh the modal if a new pattern is loaded and the modal is active
@param {Object} the patternData sent back from the query
@param {Boolean} if the refresh is of a view-all view and the content should be sent back
@param {Boolean} if the text in the dropdown should be switched | [
"refresh",
"the",
"modal",
"if",
"a",
"new",
"pattern",
"is",
"loaded",
"and",
"the",
"modal",
"is",
"active"
] | 6ae90009c5d611f9fdbcc208f9bd5f1e22926094 | https://github.com/massgov/mayflower/blob/6ae90009c5d611f9fdbcc208f9bd5f1e22926094/patternlab/styleguide/public/styleguide/js/patternlab-viewer.js#L584-L594 | train | |
massgov/mayflower | patternlab/styleguide/public/styleguide/js/patternlab-viewer.js | function(pos) {
// remove active class
els = document.querySelectorAll('#sg-annotations > .sg-annotations-list > li');
for (i = 0; i < els.length; ++i) {
els[i].classList.remove('active');
}
// add active class to called element and scroll to it
for (i = 0; i < els.length; ++i) {... | javascript | function(pos) {
// remove active class
els = document.querySelectorAll('#sg-annotations > .sg-annotations-list > li');
for (i = 0; i < els.length; ++i) {
els[i].classList.remove('active');
}
// add active class to called element and scroll to it
for (i = 0; i < els.length; ++i) {... | [
"function",
"(",
"pos",
")",
"{",
"// remove active class",
"els",
"=",
"document",
".",
"querySelectorAll",
"(",
"'#sg-annotations > .sg-annotations-list > li'",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"els",
".",
"length",
";",
"++",
"i",
")",
... | slides the modal window to a particular annotation
@param {Integer} the number for the element that should be highlighted | [
"slides",
"the",
"modal",
"window",
"to",
"a",
"particular",
"annotation"
] | 6ae90009c5d611f9fdbcc208f9bd5f1e22926094 | https://github.com/massgov/mayflower/blob/6ae90009c5d611f9fdbcc208f9bd5f1e22926094/patternlab/styleguide/public/styleguide/js/patternlab-viewer.js#L609-L625 | train | |
massgov/mayflower | patternlab/styleguide/public/styleguide/js/patternlab-viewer.js | function(switchText) {
// note that the modal is active and set switchText
if ((switchText === undefined) || (switchText)) {
switchText = true;
DataSaver.updateValue('modalActive', 'true');
modalViewer.active = true;
}
// send a message to the pattern
var obj = JSON.strin... | javascript | function(switchText) {
// note that the modal is active and set switchText
if ((switchText === undefined) || (switchText)) {
switchText = true;
DataSaver.updateValue('modalActive', 'true');
modalViewer.active = true;
}
// send a message to the pattern
var obj = JSON.strin... | [
"function",
"(",
"switchText",
")",
"{",
"// note that the modal is active and set switchText",
"if",
"(",
"(",
"switchText",
"===",
"undefined",
")",
"||",
"(",
"switchText",
")",
")",
"{",
"switchText",
"=",
"true",
";",
"DataSaver",
".",
"updateValue",
"(",
"... | ask the pattern for info so we can open the modal window and populate it
@param {Boolean} if the dropdown text should be changed | [
"ask",
"the",
"pattern",
"for",
"info",
"so",
"we",
"can",
"open",
"the",
"modal",
"window",
"and",
"populate",
"it"
] | 6ae90009c5d611f9fdbcc208f9bd5f1e22926094 | https://github.com/massgov/mayflower/blob/6ae90009c5d611f9fdbcc208f9bd5f1e22926094/patternlab/styleguide/public/styleguide/js/patternlab-viewer.js#L638-L651 | train | |
massgov/mayflower | patternlab/styleguide/public/styleguide/js/patternlab-viewer.js | function(templateRendered, patternPartial) {
var els = templateRendered.querySelectorAll('#sg-'+patternPartial+'-tabs li');
for (var i = 0; i < els.length; ++i) {
els[i].onclick = function(e) {
e.preventDefault();
var patternPartial = this.getAttribute('data-patternpartial');
... | javascript | function(templateRendered, patternPartial) {
var els = templateRendered.querySelectorAll('#sg-'+patternPartial+'-tabs li');
for (var i = 0; i < els.length; ++i) {
els[i].onclick = function(e) {
e.preventDefault();
var patternPartial = this.getAttribute('data-patternpartial');
... | [
"function",
"(",
"templateRendered",
",",
"patternPartial",
")",
"{",
"var",
"els",
"=",
"templateRendered",
".",
"querySelectorAll",
"(",
"'#sg-'",
"+",
"patternPartial",
"+",
"'-tabs li'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"els",... | Add click events to the template that was rendered
@param {String} the rendered template for the modal
@param {String} the pattern partial for the modal | [
"Add",
"click",
"events",
"to",
"the",
"template",
"that",
"was",
"rendered"
] | 6ae90009c5d611f9fdbcc208f9bd5f1e22926094 | https://github.com/massgov/mayflower/blob/6ae90009c5d611f9fdbcc208f9bd5f1e22926094/patternlab/styleguide/public/styleguide/js/patternlab-viewer.js#L718-L732 | train | |
massgov/mayflower | patternlab/styleguide/public/styleguide/js/patternlab-viewer.js | function(panels, patternData, iframePassback, switchText) {
// count how many panels have rendered content
var panelContentCount = 0;
for (var i = 0; i < panels.length; ++i) {
if (panels[i].content !== undefined) {
panelContentCount++;
}
}
// see if the count of panels with con... | javascript | function(panels, patternData, iframePassback, switchText) {
// count how many panels have rendered content
var panelContentCount = 0;
for (var i = 0; i < panels.length; ++i) {
if (panels[i].content !== undefined) {
panelContentCount++;
}
}
// see if the count of panels with con... | [
"function",
"(",
"panels",
",",
"patternData",
",",
"iframePassback",
",",
"switchText",
")",
"{",
"// count how many panels have rendered content",
"var",
"panelContentCount",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"panels",
".",
"len... | Check to see if all of the panels have been collected before rendering
@param {String} the collected panels
@param {String} the data from the pattern
@param {Boolean} if this is going to be passed back to the styleguide | [
"Check",
"to",
"see",
"if",
"all",
"of",
"the",
"panels",
"have",
"been",
"collected",
"before",
"rendering"
] | 6ae90009c5d611f9fdbcc208f9bd5f1e22926094 | https://github.com/massgov/mayflower/blob/6ae90009c5d611f9fdbcc208f9bd5f1e22926094/patternlab/styleguide/public/styleguide/js/patternlab-viewer.js#L888-L903 | train | |
massgov/mayflower | patternlab/styleguide/public/styleguide/js/patternlab-viewer.js | sizeiframe | function sizeiframe(size,animate) {
var theSize;
if(size>maxViewportWidth) { //If the entered size is larger than the max allowed viewport size, cap value at max vp size
theSize = maxViewportWidth;
} else if(size<minViewportWidth) { //If the entered size is less than the minimum allowed viewport size... | javascript | function sizeiframe(size,animate) {
var theSize;
if(size>maxViewportWidth) { //If the entered size is larger than the max allowed viewport size, cap value at max vp size
theSize = maxViewportWidth;
} else if(size<minViewportWidth) { //If the entered size is less than the minimum allowed viewport size... | [
"function",
"sizeiframe",
"(",
"size",
",",
"animate",
")",
"{",
"var",
"theSize",
";",
"if",
"(",
"size",
">",
"maxViewportWidth",
")",
"{",
"//If the entered size is larger than the max allowed viewport size, cap value at max vp size",
"theSize",
"=",
"maxViewportWidth",
... | Resize the viewport 'size' is the target size of the viewport 'animate' is a boolean for switching the CSS animation on or off. 'animate' is true by default, but can be set to false for things like nudging and dragging | [
"Resize",
"the",
"viewport",
"size",
"is",
"the",
"target",
"size",
"of",
"the",
"viewport",
"animate",
"is",
"a",
"boolean",
"for",
"switching",
"the",
"CSS",
"animation",
"on",
"or",
"off",
".",
"animate",
"is",
"true",
"by",
"default",
"but",
"can",
"... | 6ae90009c5d611f9fdbcc208f9bd5f1e22926094 | https://github.com/massgov/mayflower/blob/6ae90009c5d611f9fdbcc208f9bd5f1e22926094/patternlab/styleguide/public/styleguide/js/patternlab-viewer.js#L1658-L1685 | train |
mongodb-js/collection-sample | lib/reservoir-sampler.js | reservoirStream | function reservoirStream(collection, size, opts) {
opts = _defaults(opts || {}, {
chunkSize: RESERVOIR_CHUNK_SIZE,
promoteValues: true
});
var reservoir = new Reservoir(size);
var stream = es.through(
function write(data) {
// fill reservoir with ids
reservoir.pushSome(data);
},
... | javascript | function reservoirStream(collection, size, opts) {
opts = _defaults(opts || {}, {
chunkSize: RESERVOIR_CHUNK_SIZE,
promoteValues: true
});
var reservoir = new Reservoir(size);
var stream = es.through(
function write(data) {
// fill reservoir with ids
reservoir.pushSome(data);
},
... | [
"function",
"reservoirStream",
"(",
"collection",
",",
"size",
",",
"opts",
")",
"{",
"opts",
"=",
"_defaults",
"(",
"opts",
"||",
"{",
"}",
",",
"{",
"chunkSize",
":",
"RESERVOIR_CHUNK_SIZE",
",",
"promoteValues",
":",
"true",
"}",
")",
";",
"var",
"res... | Does reservoir sampling and fetches the resulting documents from the
collection.
The query runs with a limit of `RESERVOIR_SAMPLE_LIMIT`. The reservoir
then samples `size` _ids from the query result. These _ids get grouped
into chunks of at most `RESERVOIR_CHUNK_SIZE`. For each chunk, a cursor
is opened to fetch the a... | [
"Does",
"reservoir",
"sampling",
"and",
"fetches",
"the",
"resulting",
"documents",
"from",
"the",
"collection",
"."
] | 54299d76c82e119dd75b7c5e42a17229eebe8129 | https://github.com/mongodb-js/collection-sample/blob/54299d76c82e119dd75b7c5e42a17229eebe8129/lib/reservoir-sampler.js#L34-L69 | train |
mongodb-js/collection-sample | lib/raw-transform.js | transform | function transform(chunk, encoding, cb) {
// only transform for raw bytes
if (raw) {
var response = BSON.deserialize(chunk);
response.cursor.firstBatch.forEach(function(doc) {
this.push(BSON.serialize(doc));
}.bind(this));
return cb();
}
// otherwise go back to the main s... | javascript | function transform(chunk, encoding, cb) {
// only transform for raw bytes
if (raw) {
var response = BSON.deserialize(chunk);
response.cursor.firstBatch.forEach(function(doc) {
this.push(BSON.serialize(doc));
}.bind(this));
return cb();
}
// otherwise go back to the main s... | [
"function",
"transform",
"(",
"chunk",
",",
"encoding",
",",
"cb",
")",
"{",
"// only transform for raw bytes",
"if",
"(",
"raw",
")",
"{",
"var",
"response",
"=",
"BSON",
".",
"deserialize",
"(",
"chunk",
")",
";",
"response",
".",
"cursor",
".",
"firstBa... | split up incoming raw bytes and return documents one by one; NODE-1906 this is only necessary for native sampler | [
"split",
"up",
"incoming",
"raw",
"bytes",
"and",
"return",
"documents",
"one",
"by",
"one",
";",
"NODE",
"-",
"1906",
"this",
"is",
"only",
"necessary",
"for",
"native",
"sampler"
] | 54299d76c82e119dd75b7c5e42a17229eebe8129 | https://github.com/mongodb-js/collection-sample/blob/54299d76c82e119dd75b7c5e42a17229eebe8129/lib/raw-transform.js#L7-L18 | train |
rasmusbe/gulp-wp-pot | index.js | gulpWPpot | function gulpWPpot (options) {
if (options !== undefined && !isObject(options)) {
throw new PluginError('gulp-wp-pot', 'Require a argument of type object.');
}
const files = [];
const stream = through.obj(function (file, enc, cb) {
if (file.isStream()) {
this.emit('error', new PluginError('gulp-... | javascript | function gulpWPpot (options) {
if (options !== undefined && !isObject(options)) {
throw new PluginError('gulp-wp-pot', 'Require a argument of type object.');
}
const files = [];
const stream = through.obj(function (file, enc, cb) {
if (file.isStream()) {
this.emit('error', new PluginError('gulp-... | [
"function",
"gulpWPpot",
"(",
"options",
")",
"{",
"if",
"(",
"options",
"!==",
"undefined",
"&&",
"!",
"isObject",
"(",
"options",
")",
")",
"{",
"throw",
"new",
"PluginError",
"(",
"'gulp-wp-pot'",
",",
"'Require a argument of type object.'",
")",
";",
"}",
... | Run the wp pot generator.
@param {object} options
@return {object} | [
"Run",
"the",
"wp",
"pot",
"generator",
"."
] | 7896dac159b1e63fd89bc16be20ab13ea1524aa9 | https://github.com/rasmusbe/gulp-wp-pot/blob/7896dac159b1e63fd89bc16be20ab13ea1524aa9/index.js#L28-L67 | train |
gr2m/moment-parseformat | lib/parseformat.js | replaceEndian | function replaceEndian (options, matchedPart, first, separator, second, third) {
var parts
var hasSingleDigit = Math.min(first.length, second.length, third.length) === 1
var hasQuadDigit = Math.max(first.length, second.length, third.length) === 4
var preferredOrder = typeof options.preferredOrder === 'string' ?... | javascript | function replaceEndian (options, matchedPart, first, separator, second, third) {
var parts
var hasSingleDigit = Math.min(first.length, second.length, third.length) === 1
var hasQuadDigit = Math.max(first.length, second.length, third.length) === 4
var preferredOrder = typeof options.preferredOrder === 'string' ?... | [
"function",
"replaceEndian",
"(",
"options",
",",
"matchedPart",
",",
"first",
",",
"separator",
",",
"second",
",",
"third",
")",
"{",
"var",
"parts",
"var",
"hasSingleDigit",
"=",
"Math",
".",
"min",
"(",
"first",
".",
"length",
",",
"second",
".",
"le... | if we can't find an endian based on the separator, but there still is a short date with day, month & year, we try to make a smart decision to identify the order | [
"if",
"we",
"can",
"t",
"find",
"an",
"endian",
"based",
"on",
"the",
"separator",
"but",
"there",
"still",
"is",
"a",
"short",
"date",
"with",
"day",
"month",
"&",
"year",
"we",
"try",
"to",
"make",
"a",
"smart",
"decision",
"to",
"identify",
"the",
... | c465304a6b5c2771ac5cf51f2ad5dad78a3450d9 | https://github.com/gr2m/moment-parseformat/blob/c465304a6b5c2771ac5cf51f2ad5dad78a3450d9/lib/parseformat.js#L194-L245 | train |
ringcentral/ringcentral-js-widgets | packages/ringcentral-widgets/components/CircleButton/index.js | CircleButton | function CircleButton(props) {
let icon;
if (props.icon) {
const Icon = props.icon;
icon = (
<Icon
className={classnames(styles.icon, props.iconClassName)}
width={props.iconWidth}
height={props.iconHeight}
x={props.iconX}
y={props.iconY}
/>
);
}
co... | javascript | function CircleButton(props) {
let icon;
if (props.icon) {
const Icon = props.icon;
icon = (
<Icon
className={classnames(styles.icon, props.iconClassName)}
width={props.iconWidth}
height={props.iconHeight}
x={props.iconX}
y={props.iconY}
/>
);
}
co... | [
"function",
"CircleButton",
"(",
"props",
")",
"{",
"let",
"icon",
";",
"if",
"(",
"props",
".",
"icon",
")",
"{",
"const",
"Icon",
"=",
"props",
".",
"icon",
";",
"icon",
"=",
"(",
"<",
"Icon",
"className",
"=",
"{",
"classnames",
"(",
"styles",
"... | Circle Button with SVG | [
"Circle",
"Button",
"with",
"SVG"
] | 31bbd5860ad523f65b6debcc5f27edd23100164d | https://github.com/ringcentral/ringcentral-js-widgets/blob/31bbd5860ad523f65b6debcc5f27edd23100164d/packages/ringcentral-widgets/components/CircleButton/index.js#L9-L68 | train |
ringcentral/ringcentral-js-widgets | packages/ringcentral-widgets/components/RecentActivityPanel/index.js | RecentActivityPanel | function RecentActivityPanel(props) {
const { title, expanded, onPanelToggle } = props;
const toggleButton = {
label: <ToggleIcon expanded={expanded} />,
onClick: onPanelToggle,
placement: 'right'
};
if (!props.currentContact) {
return null;
}
const containerClass = classnames(styles.contain... | javascript | function RecentActivityPanel(props) {
const { title, expanded, onPanelToggle } = props;
const toggleButton = {
label: <ToggleIcon expanded={expanded} />,
onClick: onPanelToggle,
placement: 'right'
};
if (!props.currentContact) {
return null;
}
const containerClass = classnames(styles.contain... | [
"function",
"RecentActivityPanel",
"(",
"props",
")",
"{",
"const",
"{",
"title",
",",
"expanded",
",",
"onPanelToggle",
"}",
"=",
"props",
";",
"const",
"toggleButton",
"=",
"{",
"label",
":",
"<",
"ToggleIcon",
"expanded",
"=",
"{",
"expanded",
"}",
"/",... | RecentActivityPanel component provides a animated slide-out panel. | [
"RecentActivityPanel",
"component",
"provides",
"a",
"animated",
"slide",
"-",
"out",
"panel",
"."
] | 31bbd5860ad523f65b6debcc5f27edd23100164d | https://github.com/ringcentral/ringcentral-js-widgets/blob/31bbd5860ad523f65b6debcc5f27edd23100164d/packages/ringcentral-widgets/components/RecentActivityPanel/index.js#L23-L42 | train |
ax5ui/ax5core | dist/ax5core.js | hasProperty | function hasProperty(obj, propName) {
return obj != null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && propName in obj;
} | javascript | function hasProperty(obj, propName) {
return obj != null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && propName in obj;
} | [
"function",
"hasProperty",
"(",
"obj",
",",
"propName",
")",
"{",
"return",
"obj",
"!=",
"null",
"&&",
"(",
"typeof",
"obj",
"===",
"'undefined'",
"?",
"'undefined'",
":",
"_typeof",
"(",
"obj",
")",
")",
"===",
"'object'",
"&&",
"propName",
"in",
"obj",... | Null safe way of checking whether or not an object,
including its prototype, has a given property | [
"Null",
"safe",
"way",
"of",
"checking",
"whether",
"or",
"not",
"an",
"object",
"including",
"its",
"prototype",
"has",
"a",
"given",
"property"
] | f1f029f85a42d16c439ed6eff5d41c7ccd88dec5 | https://github.com/ax5ui/ax5core/blob/f1f029f85a42d16c439ed6eff5d41c7ccd88dec5/dist/ax5core.js#L3275-L3277 | train |
podio/podio-js | lib/push.js | function (options) {
// Initialize the Faye client if it hasn't been initialized
if (_.isUndefined(this._fayeClient)) {
var pushUrl = new URI(this.apiURL).subdomain('push').path('faye').toString();
this._fayeClient = new Faye.Client(pushUrl);
// We don't support websock... | javascript | function (options) {
// Initialize the Faye client if it hasn't been initialized
if (_.isUndefined(this._fayeClient)) {
var pushUrl = new URI(this.apiURL).subdomain('push').path('faye').toString();
this._fayeClient = new Faye.Client(pushUrl);
// We don't support websock... | [
"function",
"(",
"options",
")",
"{",
"// Initialize the Faye client if it hasn't been initialized",
"if",
"(",
"_",
".",
"isUndefined",
"(",
"this",
".",
"_fayeClient",
")",
")",
"{",
"var",
"pushUrl",
"=",
"new",
"URI",
"(",
"this",
".",
"apiURL",
")",
".",
... | Returns a reference to the Faye client and initializes it if needed | [
"Returns",
"a",
"reference",
"to",
"the",
"Faye",
"client",
"and",
"initializes",
"it",
"if",
"needed"
] | 0c7a8935ffad860af31202565d328ea79a90ebb6 | https://github.com/podio/podio-js/blob/0c7a8935ffad860af31202565d328ea79a90ebb6/lib/push.js#L11-L37 | train | |
restify/plugins | lib/plugins/oauth2TokenParser.js | oauth2TokenParser | function oauth2TokenParser(options) {
function parseOauth2Token(req, res, next) {
req.oauth2 = { accessToken: null};
var tokenFromHeader = parseHeader(req);
if (tokenFromHeader) {
req.oauth2.accessToken = tokenFromHeader;
}
var tokenFromBody = null;
... | javascript | function oauth2TokenParser(options) {
function parseOauth2Token(req, res, next) {
req.oauth2 = { accessToken: null};
var tokenFromHeader = parseHeader(req);
if (tokenFromHeader) {
req.oauth2.accessToken = tokenFromHeader;
}
var tokenFromBody = null;
... | [
"function",
"oauth2TokenParser",
"(",
"options",
")",
"{",
"function",
"parseOauth2Token",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"req",
".",
"oauth2",
"=",
"{",
"accessToken",
":",
"null",
"}",
";",
"var",
"tokenFromHeader",
"=",
"parseHeader",
"(... | Returns a plugin that will parse the client's request for an OAUTH2
access token
Subsequent handlers will see `req.oauth2`, which looks like:
{
oauth2: {
accessToken: 'mF_9.B5f-4.1JqM&p=q'
}
}
@public
@function oauth2TokenParser
@throws {InvalidArgumentError}
@param {Object} options an options object
@returns ... | [
"Returns",
"a",
"plugin",
"that",
"will",
"parse",
"the",
"client",
"s",
"request",
"for",
"an",
"OAUTH2",
"access",
"token"
] | 32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2 | https://github.com/restify/plugins/blob/32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2/lib/plugins/oauth2TokenParser.js#L67-L101 | train |
restify/plugins | lib/plugins/accept.js | acceptParser | function acceptParser(accepts) {
var acceptable = accepts;
if (!Array.isArray(acceptable)) {
acceptable = [acceptable];
}
assert.arrayOfString(acceptable, 'acceptable');
acceptable = acceptable.filter(function (a) {
return (a);
}).map(function (a) {
return ((a.index... | javascript | function acceptParser(accepts) {
var acceptable = accepts;
if (!Array.isArray(acceptable)) {
acceptable = [acceptable];
}
assert.arrayOfString(acceptable, 'acceptable');
acceptable = acceptable.filter(function (a) {
return (a);
}).map(function (a) {
return ((a.index... | [
"function",
"acceptParser",
"(",
"accepts",
")",
"{",
"var",
"acceptable",
"=",
"accepts",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"acceptable",
")",
")",
"{",
"acceptable",
"=",
"[",
"acceptable",
"]",
";",
"}",
"assert",
".",
"arrayOfString"... | Returns a plugin that will check the client's Accept header can be handled
by this server.
Note you can get the set of types allowed from a restify server by doing
`server.acceptable`.
@public
@function acceptParser
@throws {NotAcceptableError}
@param {String} accepts array of accept types.
@returns {Functio... | [
"Returns",
"a",
"plugin",
"that",
"will",
"check",
"the",
"client",
"s",
"Accept",
"header",
"can",
"be",
"handled",
"by",
"this",
"server",
"."
] | 32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2 | https://github.com/restify/plugins/blob/32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2/lib/plugins/accept.js#L24-L53 | train |
restify/plugins | lib/plugins/authorization.js | authorizationParser | function authorizationParser(options) {
function parseAuthorization(req, res, next) {
req.authorization = {};
req.username = 'anonymous';
if (!req.headers.authorization) {
return (next());
}
var pieces = req.headers.authorization.split(' ', 2);
if (!pi... | javascript | function authorizationParser(options) {
function parseAuthorization(req, res, next) {
req.authorization = {};
req.username = 'anonymous';
if (!req.headers.authorization) {
return (next());
}
var pieces = req.headers.authorization.split(' ', 2);
if (!pi... | [
"function",
"authorizationParser",
"(",
"options",
")",
"{",
"function",
"parseAuthorization",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"req",
".",
"authorization",
"=",
"{",
"}",
";",
"req",
".",
"username",
"=",
"'anonymous'",
";",
"if",
"(",
"!"... | Returns a plugin that will parse the client's Authorization header.
Subsequent handlers will see `req.authorization`, which looks like:
{
scheme: <Basic|Signature|...>,
credentials: <Undecoded value of header>,
basic: {
username: $user
password: $password
}
}
`req.username` will also be set, and defaults to 'anonymo... | [
"Returns",
"a",
"plugin",
"that",
"will",
"parse",
"the",
"client",
"s",
"Authorization",
"header",
"."
] | 32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2 | https://github.com/restify/plugins/blob/32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2/lib/plugins/authorization.js#L103-L149 | train |
restify/plugins | lib/pre/reqIdHeaders.js | createReqIdHeaders | function createReqIdHeaders(opts) {
assert.object(opts, 'opts');
assert.arrayOfString(opts.headers, 'opts.headers');
var headers = opts.headers.concat(DEFAULT_HEADERS);
return function reqIdHeaders(req, res, next) {
for (var i = 0; i < headers.length; i++) {
var val = req.header(... | javascript | function createReqIdHeaders(opts) {
assert.object(opts, 'opts');
assert.arrayOfString(opts.headers, 'opts.headers');
var headers = opts.headers.concat(DEFAULT_HEADERS);
return function reqIdHeaders(req, res, next) {
for (var i = 0; i < headers.length; i++) {
var val = req.header(... | [
"function",
"createReqIdHeaders",
"(",
"opts",
")",
"{",
"assert",
".",
"object",
"(",
"opts",
",",
"'opts'",
")",
";",
"assert",
".",
"arrayOfString",
"(",
"opts",
".",
"headers",
",",
"'opts.headers'",
")",
";",
"var",
"headers",
"=",
"opts",
".",
"hea... | Automatically reuse incoming request header as the request id.
@public
@function createReqIdHeaders
@param {Object} opts an options object
@param {Array} opts.headers array of headers from where to pull existing
request id headers
@returns {Function} | [
"Automatically",
"reuse",
"incoming",
"request",
"header",
"as",
"the",
"request",
"id",
"."
] | 32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2 | https://github.com/restify/plugins/blob/32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2/lib/pre/reqIdHeaders.js#L17-L37 | train |
restify/plugins | lib/plugins/query.js | queryParser | function queryParser(options) {
var opts = options || {};
assert.object(opts, 'opts');
function parseQueryString(req, res, next) {
if (!req.getQuery()) {
req.query = {};
return next();
}
req.query = qs.parse(req.getQuery(), opts);
if (opts.mapPara... | javascript | function queryParser(options) {
var opts = options || {};
assert.object(opts, 'opts');
function parseQueryString(req, res, next) {
if (!req.getQuery()) {
req.query = {};
return next();
}
req.query = qs.parse(req.getQuery(), opts);
if (opts.mapPara... | [
"function",
"queryParser",
"(",
"options",
")",
"{",
"var",
"opts",
"=",
"options",
"||",
"{",
"}",
";",
"assert",
".",
"object",
"(",
"opts",
",",
"'opts'",
")",
";",
"function",
"parseQueryString",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if... | Returns a plugin that will parse the query string, and merge the results
into req.query.
Unless options.mapParams is false, they will also be mapped into req.params.
@public
@function queryParser
@param {Object} options an options object
@returns {Function} | [
"Returns",
"a",
"plugin",
"that",
"will",
"parse",
"the",
"query",
"string",
"and",
"merge",
"the",
"results",
"into",
"req",
".",
"query",
"."
] | 32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2 | https://github.com/restify/plugins/blob/32c0c1e64dae2698abd8f4c0307d4fb405c1b6f2/lib/plugins/query.js#L19-L46 | train |
jshttp/range-parser | index.js | rangeParser | function rangeParser (size, str, options) {
if (typeof str !== 'string') {
throw new TypeError('argument str must be a string')
}
var index = str.indexOf('=')
if (index === -1) {
return -2
}
// split the range string
var arr = str.slice(index + 1).split(',')
var ranges = []
// add ranges t... | javascript | function rangeParser (size, str, options) {
if (typeof str !== 'string') {
throw new TypeError('argument str must be a string')
}
var index = str.indexOf('=')
if (index === -1) {
return -2
}
// split the range string
var arr = str.slice(index + 1).split(',')
var ranges = []
// add ranges t... | [
"function",
"rangeParser",
"(",
"size",
",",
"str",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"str",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'argument str must be a string'",
")",
"}",
"var",
"index",
"=",
"str",
".",
"indexOf"... | Parse "Range" header `str` relative to the given file `size`.
@param {Number} size
@param {String} str
@param {Object} [options]
@return {Array}
@public | [
"Parse",
"Range",
"header",
"str",
"relative",
"to",
"the",
"given",
"file",
"size",
"."
] | 9817a4dd666ac9f3905ddb92296e623bee91d04b | https://github.com/jshttp/range-parser/blob/9817a4dd666ac9f3905ddb92296e623bee91d04b/index.js#L27-L85 | train |
jshttp/range-parser | index.js | combineRanges | function combineRanges (ranges) {
var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart)
for (var j = 0, i = 1; i < ordered.length; i++) {
var range = ordered[i]
var current = ordered[j]
if (range.start > current.end + 1) {
// next range
ordered[++j] = range
} else if (range.end... | javascript | function combineRanges (ranges) {
var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart)
for (var j = 0, i = 1; i < ordered.length; i++) {
var range = ordered[i]
var current = ordered[j]
if (range.start > current.end + 1) {
// next range
ordered[++j] = range
} else if (range.end... | [
"function",
"combineRanges",
"(",
"ranges",
")",
"{",
"var",
"ordered",
"=",
"ranges",
".",
"map",
"(",
"mapWithIndex",
")",
".",
"sort",
"(",
"sortByRangeStart",
")",
"for",
"(",
"var",
"j",
"=",
"0",
",",
"i",
"=",
"1",
";",
"i",
"<",
"ordered",
... | Combine overlapping & adjacent ranges.
@private | [
"Combine",
"overlapping",
"&",
"adjacent",
"ranges",
"."
] | 9817a4dd666ac9f3905ddb92296e623bee91d04b | https://github.com/jshttp/range-parser/blob/9817a4dd666ac9f3905ddb92296e623bee91d04b/index.js#L92-L119 | train |
jshttp/range-parser | index.js | mapWithIndex | function mapWithIndex (range, index) {
return {
start: range.start,
end: range.end,
index: index
}
} | javascript | function mapWithIndex (range, index) {
return {
start: range.start,
end: range.end,
index: index
}
} | [
"function",
"mapWithIndex",
"(",
"range",
",",
"index",
")",
"{",
"return",
"{",
"start",
":",
"range",
".",
"start",
",",
"end",
":",
"range",
".",
"end",
",",
"index",
":",
"index",
"}",
"}"
] | Map function to add index value to ranges.
@private | [
"Map",
"function",
"to",
"add",
"index",
"value",
"to",
"ranges",
"."
] | 9817a4dd666ac9f3905ddb92296e623bee91d04b | https://github.com/jshttp/range-parser/blob/9817a4dd666ac9f3905ddb92296e623bee91d04b/index.js#L126-L132 | train |
kintone/plugin-packer | src/sourcelist.js | sourceList | function sourceList(manifest) {
const sourceTypes = [
["desktop", "js"],
["desktop", "css"],
["mobile", "js"],
["config", "js"],
["config", "css"]
];
const list = sourceTypes
.map(t => manifest[t[0]] && manifest[t[0]][t[1]])
.filter(i => !!i)
.reduce((a, b) => a.concat(b), [])
... | javascript | function sourceList(manifest) {
const sourceTypes = [
["desktop", "js"],
["desktop", "css"],
["mobile", "js"],
["config", "js"],
["config", "css"]
];
const list = sourceTypes
.map(t => manifest[t[0]] && manifest[t[0]][t[1]])
.filter(i => !!i)
.reduce((a, b) => a.concat(b), [])
... | [
"function",
"sourceList",
"(",
"manifest",
")",
"{",
"const",
"sourceTypes",
"=",
"[",
"[",
"\"desktop\"",
",",
"\"js\"",
"]",
",",
"[",
"\"desktop\"",
",",
"\"css\"",
"]",
",",
"[",
"\"mobile\"",
",",
"\"js\"",
"]",
",",
"[",
"\"config\"",
",",
"\"js\""... | Create content file list from manifest.json
@param {!Object} manifest
@return {!Array<string>} | [
"Create",
"content",
"file",
"list",
"from",
"manifest",
".",
"json"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/src/sourcelist.js#L9-L28 | train |
kintone/plugin-packer | src/create-contents-zip.js | createContentsZip | function createContentsZip(pluginDir, manifest) {
return new Promise((res, rej) => {
const output = new streamBuffers.WritableStreamBuffer();
const zipFile = new ZipFile();
let size = null;
output.on("finish", () => {
debug(`plugin.zip: ${size} bytes`);
res(output.getContents());
});
... | javascript | function createContentsZip(pluginDir, manifest) {
return new Promise((res, rej) => {
const output = new streamBuffers.WritableStreamBuffer();
const zipFile = new ZipFile();
let size = null;
output.on("finish", () => {
debug(`plugin.zip: ${size} bytes`);
res(output.getContents());
});
... | [
"function",
"createContentsZip",
"(",
"pluginDir",
",",
"manifest",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"res",
",",
"rej",
")",
"=>",
"{",
"const",
"output",
"=",
"new",
"streamBuffers",
".",
"WritableStreamBuffer",
"(",
")",
";",
"const",
"zip... | Create a zipped contents
@param {string} pluginDir
@param {!Object} manifest
@return {!Promise<!Buffer>} | [
"Create",
"a",
"zipped",
"contents"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/src/create-contents-zip.js#L18-L35 | train |
kintone/plugin-packer | site/dom.js | fileMapToBuffer | function fileMapToBuffer(fileMap) {
return Promise.all(
Array.from(fileMap.entries()).map(([path, file]) =>
readArrayBuffer(file).then(buffer => ({ buffer, path }))
)
)
.then(results => {
const zipFile = new yazl.ZipFile();
results.forEach(result => {
zipFile.addBuffer(Buffer.f... | javascript | function fileMapToBuffer(fileMap) {
return Promise.all(
Array.from(fileMap.entries()).map(([path, file]) =>
readArrayBuffer(file).then(buffer => ({ buffer, path }))
)
)
.then(results => {
const zipFile = new yazl.ZipFile();
results.forEach(result => {
zipFile.addBuffer(Buffer.f... | [
"function",
"fileMapToBuffer",
"(",
"fileMap",
")",
"{",
"return",
"Promise",
".",
"all",
"(",
"Array",
".",
"from",
"(",
"fileMap",
".",
"entries",
"(",
")",
")",
".",
"map",
"(",
"(",
"[",
"path",
",",
"file",
"]",
")",
"=>",
"readArrayBuffer",
"("... | Create a buffer of the zip file
@typedef {{file: File, fullPath: string}} FileEntry
@param {Map<string, File>} fileMap
@return {Promise<Buffer>} | [
"Create",
"a",
"buffer",
"of",
"the",
"zip",
"file"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/site/dom.js#L169-L193 | train |
kintone/plugin-packer | src/index.js | zip | function zip(contentsZip, publicKey, signature) {
debug(`zip(): start`);
return new Promise((res, rej) => {
const output = new streamBuffers.WritableStreamBuffer();
const zipFile = new ZipFile();
output.on("finish", () => {
debug(`zip(): output finish event`);
res(output.getContents());
... | javascript | function zip(contentsZip, publicKey, signature) {
debug(`zip(): start`);
return new Promise((res, rej) => {
const output = new streamBuffers.WritableStreamBuffer();
const zipFile = new ZipFile();
output.on("finish", () => {
debug(`zip(): output finish event`);
res(output.getContents());
... | [
"function",
"zip",
"(",
"contentsZip",
",",
"publicKey",
",",
"signature",
")",
"{",
"debug",
"(",
"`",
"`",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"res",
",",
"rej",
")",
"=>",
"{",
"const",
"output",
"=",
"new",
"streamBuffers",
".",
"Writ... | Create plugin.zip
@param {!Buffer} contentsZip
@param {!Buffer} publicKey
@param {!Buffer} signature
@return {!Promise<!Buffer>} | [
"Create",
"plugin",
".",
"zip"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/src/index.js#L49-L66 | train |
kintone/plugin-packer | src/zip.js | rezip | function rezip(contentsZip) {
return preprocessToRezip(contentsZip).then(
({ zipFile, entries, manifestJson, manifestPath }) => {
validateManifest(entries, manifestJson, manifestPath);
return rezipContents(zipFile, entries, manifestJson, manifestPath);
}
);
} | javascript | function rezip(contentsZip) {
return preprocessToRezip(contentsZip).then(
({ zipFile, entries, manifestJson, manifestPath }) => {
validateManifest(entries, manifestJson, manifestPath);
return rezipContents(zipFile, entries, manifestJson, manifestPath);
}
);
} | [
"function",
"rezip",
"(",
"contentsZip",
")",
"{",
"return",
"preprocessToRezip",
"(",
"contentsZip",
")",
".",
"then",
"(",
"(",
"{",
"zipFile",
",",
"entries",
",",
"manifestJson",
",",
"manifestPath",
"}",
")",
"=>",
"{",
"validateManifest",
"(",
"entries... | Extract, validate and rezip contents.zip
@param {!Buffer} contentsZip The zipped plugin contents directory.
@return {!Promise<!Buffer>} | [
"Extract",
"validate",
"and",
"rezip",
"contents",
".",
"zip"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/src/zip.js#L19-L26 | train |
kintone/plugin-packer | src/zip.js | validateContentsZip | function validateContentsZip(contentsZip) {
return preprocessToRezip(contentsZip).then(
({ entries, manifestJson, manifestPath }) =>
validateManifest(entries, manifestJson, manifestPath)
);
} | javascript | function validateContentsZip(contentsZip) {
return preprocessToRezip(contentsZip).then(
({ entries, manifestJson, manifestPath }) =>
validateManifest(entries, manifestJson, manifestPath)
);
} | [
"function",
"validateContentsZip",
"(",
"contentsZip",
")",
"{",
"return",
"preprocessToRezip",
"(",
"contentsZip",
")",
".",
"then",
"(",
"(",
"{",
"entries",
",",
"manifestJson",
",",
"manifestPath",
"}",
")",
"=>",
"validateManifest",
"(",
"entries",
",",
"... | Validate a buffer of contents.zip
@param {!Buffer} contentsZip
@return {!Promise<*>} | [
"Validate",
"a",
"buffer",
"of",
"contents",
".",
"zip"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/src/zip.js#L33-L38 | train |
kintone/plugin-packer | src/zip.js | preprocessToRezip | function preprocessToRezip(contentsZip) {
return zipEntriesFromBuffer(contentsZip).then(result => {
const manifestList = Array.from(result.entries.keys()).filter(
file => path.basename(file) === "manifest.json"
);
if (manifestList.length === 0) {
throw new Error("The zip file has no manifest.j... | javascript | function preprocessToRezip(contentsZip) {
return zipEntriesFromBuffer(contentsZip).then(result => {
const manifestList = Array.from(result.entries.keys()).filter(
file => path.basename(file) === "manifest.json"
);
if (manifestList.length === 0) {
throw new Error("The zip file has no manifest.j... | [
"function",
"preprocessToRezip",
"(",
"contentsZip",
")",
"{",
"return",
"zipEntriesFromBuffer",
"(",
"contentsZip",
")",
".",
"then",
"(",
"result",
"=>",
"{",
"const",
"manifestList",
"=",
"Array",
".",
"from",
"(",
"result",
".",
"entries",
".",
"keys",
"... | Create an intermediate representation for contents.zip
@typedef {{zipFile: !yauzl.ZipFile,entries: !Map<string, !yauzl.ZipEntry>, manifestJson: Object, manifestPath: string}} PreprocessedContentsZip
@param {!Buffer} contentsZip
@return {Promise<PreprocessedContentsZip>} | [
"Create",
"an",
"intermediate",
"representation",
"for",
"contents",
".",
"zip"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/src/zip.js#L46-L62 | train |
kintone/plugin-packer | src/cli.js | validateRelativePath | function validateRelativePath(pluginDir) {
return str => {
try {
const stat = fs.statSync(path.join(pluginDir, str));
return stat.isFile();
} catch (e) {
return false;
}
};
} | javascript | function validateRelativePath(pluginDir) {
return str => {
try {
const stat = fs.statSync(path.join(pluginDir, str));
return stat.isFile();
} catch (e) {
return false;
}
};
} | [
"function",
"validateRelativePath",
"(",
"pluginDir",
")",
"{",
"return",
"str",
"=>",
"{",
"try",
"{",
"const",
"stat",
"=",
"fs",
".",
"statSync",
"(",
"path",
".",
"join",
"(",
"pluginDir",
",",
"str",
")",
")",
";",
"return",
"stat",
".",
"isFile",... | Return validator for `relative-path` format
@param {string} pluginDir
@return {function(string): boolean} | [
"Return",
"validator",
"for",
"relative",
"-",
"path",
"format"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/src/cli.js#L163-L172 | train |
kintone/plugin-packer | src/cli.js | validateMaxFileSize | function validateMaxFileSize(pluginDir) {
return (maxBytes, filePath) => {
try {
const stat = fs.statSync(path.join(pluginDir, filePath));
return stat.size <= maxBytes;
} catch (e) {
return false;
}
};
} | javascript | function validateMaxFileSize(pluginDir) {
return (maxBytes, filePath) => {
try {
const stat = fs.statSync(path.join(pluginDir, filePath));
return stat.size <= maxBytes;
} catch (e) {
return false;
}
};
} | [
"function",
"validateMaxFileSize",
"(",
"pluginDir",
")",
"{",
"return",
"(",
"maxBytes",
",",
"filePath",
")",
"=>",
"{",
"try",
"{",
"const",
"stat",
"=",
"fs",
".",
"statSync",
"(",
"path",
".",
"join",
"(",
"pluginDir",
",",
"filePath",
")",
")",
"... | Return validator for `maxFileSize` keyword
@param {string} pluginDir
@return {function(number, string): boolean} | [
"Return",
"validator",
"for",
"maxFileSize",
"keyword"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/src/cli.js#L180-L189 | train |
kintone/plugin-packer | src/hex2a.js | hex2a | function hex2a(hex) {
return Array.from(hex)
.map(s => {
if (s >= "0" && s <= "9") {
return String.fromCharCode(s.charCodeAt(0) + N_TO_A);
} else if (s >= "a" && s <= "f") {
return String.fromCharCode(s.charCodeAt(0) + A_TO_K);
}
throw new Error(`invalid char: ${s}`);
}... | javascript | function hex2a(hex) {
return Array.from(hex)
.map(s => {
if (s >= "0" && s <= "9") {
return String.fromCharCode(s.charCodeAt(0) + N_TO_A);
} else if (s >= "a" && s <= "f") {
return String.fromCharCode(s.charCodeAt(0) + A_TO_K);
}
throw new Error(`invalid char: ${s}`);
}... | [
"function",
"hex2a",
"(",
"hex",
")",
"{",
"return",
"Array",
".",
"from",
"(",
"hex",
")",
".",
"map",
"(",
"s",
"=>",
"{",
"if",
"(",
"s",
">=",
"\"0\"",
"&&",
"s",
"<=",
"\"9\"",
")",
"{",
"return",
"String",
".",
"fromCharCode",
"(",
"s",
"... | `tr '0-9a-f' 'a-p'` in JS
@param {string} hex like '8a7f7d'
@return {string} | [
"tr",
"0",
"-",
"9a",
"-",
"f",
"a",
"-",
"p",
"in",
"JS"
] | 585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb | https://github.com/kintone/plugin-packer/blob/585e081ad8f1ddefe8f1b6e6b41eebfd20a7a2bb/src/hex2a.js#L12-L23 | train |
xenophilicibex/react-kronos | src/styles.js | index | function index(options) {
return {
kronos: {
position: 'relative',
display: 'flex',
color: 'hsl(0, 0%, 50%)',
'& *': {
fontFamily: options.font,
boxSizing: 'border-box',
userSelect: 'none',
},
},
input: {
border: '1px solid transparent',
bo... | javascript | function index(options) {
return {
kronos: {
position: 'relative',
display: 'flex',
color: 'hsl(0, 0%, 50%)',
'& *': {
fontFamily: options.font,
boxSizing: 'border-box',
userSelect: 'none',
},
},
input: {
border: '1px solid transparent',
bo... | [
"function",
"index",
"(",
"options",
")",
"{",
"return",
"{",
"kronos",
":",
"{",
"position",
":",
"'relative'",
",",
"display",
":",
"'flex'",
",",
"color",
":",
"'hsl(0, 0%, 50%)'",
",",
"'& *'",
":",
"{",
"fontFamily",
":",
"options",
".",
"font",
","... | Styles for each page | [
"Styles",
"for",
"each",
"page"
] | 4883ebb347fb85359d6a8bb0f47c5f29fec4a645 | https://github.com/xenophilicibex/react-kronos/blob/4883ebb347fb85359d6a8bb0f47c5f29fec4a645/src/styles.js#L70-L106 | train |
basisjs/basisjs | src/basis/data/object.js | function(name, source){
var oldSource = this.sources[name];
if (name in this.fields.sources == false)
{
/** @cut */ basis.dev.warn('basis.data.object.Merge#setSource: can\'t set source with name `' + name + '` as not specified by fields configuration');
return;
}
// ignor... | javascript | function(name, source){
var oldSource = this.sources[name];
if (name in this.fields.sources == false)
{
/** @cut */ basis.dev.warn('basis.data.object.Merge#setSource: can\'t set source with name `' + name + '` as not specified by fields configuration');
return;
}
// ignor... | [
"function",
"(",
"name",
",",
"source",
")",
"{",
"var",
"oldSource",
"=",
"this",
".",
"sources",
"[",
"name",
"]",
";",
"if",
"(",
"name",
"in",
"this",
".",
"fields",
".",
"sources",
"==",
"false",
")",
"{",
"/** @cut */",
"basis",
".",
"dev",
"... | Set new value for some source name.
@param {string} name Source name.
@param {DataObject} source Value for source name. | [
"Set",
"new",
"value",
"for",
"some",
"source",
"name",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/data/object.js#L396-L459 | train | |
basisjs/basisjs | src/basis/cssom.js | compatibleStyleSheetInsertRule | function compatibleStyleSheetInsertRule(rule, index){
// fetch selector and style from rule description
var m = rule.match(/^([^{]+)\{(.*)\}\s*$/);
if (m)
{
var selectors = m[1].trim().split(/\s*,\s*/);
for (var i = 0; i < selectors.length; i++)
this.addRule(selectors[i], m[2] || nul... | javascript | function compatibleStyleSheetInsertRule(rule, index){
// fetch selector and style from rule description
var m = rule.match(/^([^{]+)\{(.*)\}\s*$/);
if (m)
{
var selectors = m[1].trim().split(/\s*,\s*/);
for (var i = 0; i < selectors.length; i++)
this.addRule(selectors[i], m[2] || nul... | [
"function",
"compatibleStyleSheetInsertRule",
"(",
"rule",
",",
"index",
")",
"{",
"// fetch selector and style from rule description",
"var",
"m",
"=",
"rule",
".",
"match",
"(",
"/",
"^([^{]+)\\{(.*)\\}\\s*$",
"/",
")",
";",
"if",
"(",
"m",
")",
"{",
"var",
"s... | working with stylesheets | [
"working",
"with",
"stylesheets"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/cssom.js#L77-L89 | train |
basisjs/basisjs | src/basis/cssom.js | getStyleSheet | function getStyleSheet(id, createIfNotExists){
if (!id)
id = 'DefaultGenericStyleSheet';
if (!cssStyleSheets[id])
if (createIfNotExists)
cssStyleSheets[id] = new StyleSheet(addStyleSheet());
return cssStyleSheets[id];
} | javascript | function getStyleSheet(id, createIfNotExists){
if (!id)
id = 'DefaultGenericStyleSheet';
if (!cssStyleSheets[id])
if (createIfNotExists)
cssStyleSheets[id] = new StyleSheet(addStyleSheet());
return cssStyleSheets[id];
} | [
"function",
"getStyleSheet",
"(",
"id",
",",
"createIfNotExists",
")",
"{",
"if",
"(",
"!",
"id",
")",
"id",
"=",
"'DefaultGenericStyleSheet'",
";",
"if",
"(",
"!",
"cssStyleSheets",
"[",
"id",
"]",
")",
"if",
"(",
"createIfNotExists",
")",
"cssStyleSheets",... | Returns generic stylesheet by it's id.
@param {string=} id
@param {boolean=} createIfNotExists
@return {basis.cssom.StyleSheet} | [
"Returns",
"generic",
"stylesheet",
"by",
"it",
"s",
"id",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/cssom.js#L132-L141 | train |
basisjs/basisjs | src/basis/cssom.js | setStyleProperty | function setStyleProperty(node, property, value){
var mapping = styleMapping[property];
var key = mapping ? mapping.key : camelize(property.replace(/^-ms-/, 'ms-'));
if (!key)
return;
if (mapping && mapping.getter)
value = mapping.getter(value);
var imp = !!IMPORTANT_REGEXP.test(value... | javascript | function setStyleProperty(node, property, value){
var mapping = styleMapping[property];
var key = mapping ? mapping.key : camelize(property.replace(/^-ms-/, 'ms-'));
if (!key)
return;
if (mapping && mapping.getter)
value = mapping.getter(value);
var imp = !!IMPORTANT_REGEXP.test(value... | [
"function",
"setStyleProperty",
"(",
"node",
",",
"property",
",",
"value",
")",
"{",
"var",
"mapping",
"=",
"styleMapping",
"[",
"property",
"]",
";",
"var",
"key",
"=",
"mapping",
"?",
"mapping",
".",
"key",
":",
"camelize",
"(",
"property",
".",
"repl... | Apply new style property value for node.
@param {Element} node Node which style to be changed.
@param {string} property Name of property.
@param {string} value Value of property.
@return {*} Returns style property value after assignment. | [
"Apply",
"new",
"style",
"property",
"value",
"for",
"node",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/cssom.js#L187-L248 | train |
basisjs/basisjs | src/basis/cssom.js | setStyle | function setStyle(node, style){
for (var key in style)
setStyleProperty(node, key, style[key]);
return node;
} | javascript | function setStyle(node, style){
for (var key in style)
setStyleProperty(node, key, style[key]);
return node;
} | [
"function",
"setStyle",
"(",
"node",
",",
"style",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"style",
")",
"setStyleProperty",
"(",
"node",
",",
"key",
",",
"style",
"[",
"key",
"]",
")",
";",
"return",
"node",
";",
"}"
] | Apply new style properties for node.
@param {Element} node Node which style to be changed.
@param {object} style Object contains new values for node style properties.
@return {Element} | [
"Apply",
"new",
"style",
"properties",
"for",
"node",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/cssom.js#L256-L261 | train |
basisjs/basisjs | src/basis/ui/scrolltable.js | function(){
var headerElement = this.header.element;
var footerElement = this.footer ? this.footer.element : null;
//
// Sync header html
//
var headerOuterHTML = domUtils.outerHTML(headerElement);
if (this.shadowHeaderHTML_ != headerOuterHTML)
{
this.shadowHeade... | javascript | function(){
var headerElement = this.header.element;
var footerElement = this.footer ? this.footer.element : null;
//
// Sync header html
//
var headerOuterHTML = domUtils.outerHTML(headerElement);
if (this.shadowHeaderHTML_ != headerOuterHTML)
{
this.shadowHeade... | [
"function",
"(",
")",
"{",
"var",
"headerElement",
"=",
"this",
".",
"header",
".",
"element",
";",
"var",
"footerElement",
"=",
"this",
".",
"footer",
"?",
"this",
".",
"footer",
".",
"element",
":",
"null",
";",
"//",
"// Sync header html",
"//",
"var"... | Make relayout of table. Should never be used in common cases. Call requestRelayout instead. | [
"Make",
"relayout",
"of",
"table",
".",
"Should",
"never",
"be",
"used",
"in",
"common",
"cases",
".",
"Call",
"requestRelayout",
"instead",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/ui/scrolltable.js#L182-L240 | train | |
basisjs/basisjs | src/basis/template/declaration/utils.js | getLocation | function getLocation(template, loc){
if (loc)
return (template.sourceUrl || '') + ':' + loc.start.line + ':' + (loc.start.column + 1);
} | javascript | function getLocation(template, loc){
if (loc)
return (template.sourceUrl || '') + ':' + loc.start.line + ':' + (loc.start.column + 1);
} | [
"function",
"getLocation",
"(",
"template",
",",
"loc",
")",
"{",
"if",
"(",
"loc",
")",
"return",
"(",
"template",
".",
"sourceUrl",
"||",
"''",
")",
"+",
"':'",
"+",
"loc",
".",
"start",
".",
"line",
"+",
"':'",
"+",
"(",
"loc",
".",
"start",
"... | location and debug | [
"location",
"and",
"debug"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/template/declaration/utils.js#L80-L83 | train |
basisjs/basisjs | src/basis/dom.js | handleInsert | function handleInsert(node, newNode, refChild){
return newNode != null
? node.insertBefore(isNode(newNode) ? newNode : createText(newNode), refChild || null)
: null;
} | javascript | function handleInsert(node, newNode, refChild){
return newNode != null
? node.insertBefore(isNode(newNode) ? newNode : createText(newNode), refChild || null)
: null;
} | [
"function",
"handleInsert",
"(",
"node",
",",
"newNode",
",",
"refChild",
")",
"{",
"return",
"newNode",
"!=",
"null",
"?",
"node",
".",
"insertBefore",
"(",
"isNode",
"(",
"newNode",
")",
"?",
"newNode",
":",
"createText",
"(",
"newNode",
")",
",",
"ref... | Insert newNode into node. If newNode is instance of Node, it insert without change; otherwise it converts to TextNode.
@param {Node} node Target node
@param {Node|*} newNode Inserting node or object.
@param {Node=} refChild Child of node.
@return {Node} | [
"Insert",
"newNode",
"into",
"node",
".",
"If",
"newNode",
"is",
"instance",
"of",
"Node",
"it",
"insert",
"without",
"change",
";",
"otherwise",
"it",
"converts",
"to",
"TextNode",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L178-L182 | train |
basisjs/basisjs | src/basis/dom.js | function(filter, result){
var node;
if (!result)
result = [];
this.reset();
while (node = this.next(filter))
result.push(node);
return result;
} | javascript | function(filter, result){
var node;
if (!result)
result = [];
this.reset();
while (node = this.next(filter))
result.push(node);
return result;
} | [
"function",
"(",
"filter",
",",
"result",
")",
"{",
"var",
"node",
";",
"if",
"(",
"!",
"result",
")",
"result",
"=",
"[",
"]",
";",
"this",
".",
"reset",
"(",
")",
";",
"while",
"(",
"node",
"=",
"this",
".",
"next",
"(",
"filter",
")",
")",
... | Returns all nodes.
@param {function(object):boolean} filter Override internal filter
@return {Node|object} | [
"Returns",
"all",
"nodes",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L283-L295 | train | |
basisjs/basisjs | src/basis/dom.js | function(filter){
filter = filter || this.filter;
var cursor = this.cursor_ || this.root_;
do
{
var node = cursor[this.a]; // next child
while (!node)
{
if (cursor === this.root_)
return this.cursor_ = null;
node = cursor[this.b]; // nex... | javascript | function(filter){
filter = filter || this.filter;
var cursor = this.cursor_ || this.root_;
do
{
var node = cursor[this.a]; // next child
while (!node)
{
if (cursor === this.root_)
return this.cursor_ = null;
node = cursor[this.b]; // nex... | [
"function",
"(",
"filter",
")",
"{",
"filter",
"=",
"filter",
"||",
"this",
".",
"filter",
";",
"var",
"cursor",
"=",
"this",
".",
"cursor_",
"||",
"this",
".",
"root_",
";",
"do",
"{",
"var",
"node",
"=",
"cursor",
"[",
"this",
".",
"a",
"]",
";... | Returns next node from cursor.
@param {function(object):boolean} filter Override internal filter
@return {Node|object} | [
"Returns",
"next",
"node",
"from",
"cursor",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L302-L324 | train | |
basisjs/basisjs | src/basis/dom.js | function(filter){
filter = filter || this.filter;
var cursor = this.cursor_;
var prevSibling = this.c; // previous sibling
var prevChild = this.d; // previous child
do
{
var node = cursor ? cursor[prevSibling] : this.root_[prevChild];
if (node)
{
... | javascript | function(filter){
filter = filter || this.filter;
var cursor = this.cursor_;
var prevSibling = this.c; // previous sibling
var prevChild = this.d; // previous child
do
{
var node = cursor ? cursor[prevSibling] : this.root_[prevChild];
if (node)
{
... | [
"function",
"(",
"filter",
")",
"{",
"filter",
"=",
"filter",
"||",
"this",
".",
"filter",
";",
"var",
"cursor",
"=",
"this",
".",
"cursor_",
";",
"var",
"prevSibling",
"=",
"this",
".",
"c",
";",
"// previous sibling",
"var",
"prevChild",
"=",
"this",
... | Returns previous node from cursor.
@param {function(object):boolean} filter Override internal filter
@return {Node|object} | [
"Returns",
"previous",
"node",
"from",
"cursor",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L331-L360 | train | |
basisjs/basisjs | src/basis/dom.js | tag | function tag(node, tagName){
var element = get(node) || document;
if (tagName == '*' && element.all)
return arrayFrom(element.all);
else
return arrayFrom(element.getElementsByTagName(tagName || '*'));
} | javascript | function tag(node, tagName){
var element = get(node) || document;
if (tagName == '*' && element.all)
return arrayFrom(element.all);
else
return arrayFrom(element.getElementsByTagName(tagName || '*'));
} | [
"function",
"tag",
"(",
"node",
",",
"tagName",
")",
"{",
"var",
"element",
"=",
"get",
"(",
"node",
")",
"||",
"document",
";",
"if",
"(",
"tagName",
"==",
"'*'",
"&&",
"element",
".",
"all",
")",
"return",
"arrayFrom",
"(",
"element",
".",
"all",
... | Returns all descendant elements tagName name for node.
@param {string|Node} node Context element.
@param {string} tagName Tag name.
@return {Array.<Element>} | [
"Returns",
"all",
"descendant",
"elements",
"tagName",
"name",
"for",
"node",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L419-L426 | train |
basisjs/basisjs | src/basis/dom.js | axis | function axis(root, axis, filter){
var result = [];
var walker;
var cursor;
filter = typeof filter == 'string' ? getter(filter) : filter || basis.fn.$true;
if (axis & (AXIS_SELF | AXIS_ANCESTOR_OR_SELF | AXIS_DESCENDANT_OR_SELF))
if (filter(root))
result.push(root);
switch (axis... | javascript | function axis(root, axis, filter){
var result = [];
var walker;
var cursor;
filter = typeof filter == 'string' ? getter(filter) : filter || basis.fn.$true;
if (axis & (AXIS_SELF | AXIS_ANCESTOR_OR_SELF | AXIS_DESCENDANT_OR_SELF))
if (filter(root))
result.push(root);
switch (axis... | [
"function",
"axis",
"(",
"root",
",",
"axis",
",",
"filter",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"walker",
";",
"var",
"cursor",
";",
"filter",
"=",
"typeof",
"filter",
"==",
"'string'",
"?",
"getter",
"(",
"filter",
")",
":",
"fi... | Navigation
Returns nodes axis in XPath like way.
@param {Node} root Relative point for axis.
@param {number} axis Axis constant.
@param {function(node:Node):boolean} filter Filter function. If it's returns true node will be in result list.
@return {Array.<Node>} | [
"Navigation",
"Returns",
"nodes",
"axis",
"in",
"XPath",
"like",
"way",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L439-L514 | train |
basisjs/basisjs | src/basis/dom.js | findAncestor | function findAncestor(node, matchFunction, bound){
while (node && node !== bound)
{
if (matchFunction(node))
break;
node = node.parentNode;
}
return node || null;
} | javascript | function findAncestor(node, matchFunction, bound){
while (node && node !== bound)
{
if (matchFunction(node))
break;
node = node.parentNode;
}
return node || null;
} | [
"function",
"findAncestor",
"(",
"node",
",",
"matchFunction",
",",
"bound",
")",
"{",
"while",
"(",
"node",
"&&",
"node",
"!==",
"bound",
")",
"{",
"if",
"(",
"matchFunction",
"(",
"node",
")",
")",
"break",
";",
"node",
"=",
"node",
".",
"parentNode"... | Returns ancestor that matchFunction returns true for.
@param {Node} node Start node for traversal.
@param {function(node:Node):boolean} matchFunction Checking function.
@param {Node=} bound Don't traversal after bound node.
@return {Node} First ancestor node that pass matchFunction. | [
"Returns",
"ancestor",
"that",
"matchFunction",
"returns",
"true",
"for",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L523-L533 | train |
basisjs/basisjs | src/basis/dom.js | createFragment | function createFragment(){
var result = document.createDocumentFragment();
var len = arguments.length;
var array = createFragment.array = [];
for (var i = 0; i < len; i++)
array.push(handleInsert(result, arguments[i]));
return result;
} | javascript | function createFragment(){
var result = document.createDocumentFragment();
var len = arguments.length;
var array = createFragment.array = [];
for (var i = 0; i < len; i++)
array.push(handleInsert(result, arguments[i]));
return result;
} | [
"function",
"createFragment",
"(",
")",
"{",
"var",
"result",
"=",
"document",
".",
"createDocumentFragment",
"(",
")",
";",
"var",
"len",
"=",
"arguments",
".",
"length",
";",
"var",
"array",
"=",
"createFragment",
".",
"array",
"=",
"[",
"]",
";",
"for... | Returns new DocumentFragmentNode with arguments as childs.
@param {...Node|string} nodes
@return {DocumentFragment} The new DocumentFragment | [
"Returns",
"new",
"DocumentFragmentNode",
"with",
"arguments",
"as",
"childs",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L553-L562 | train |
basisjs/basisjs | src/basis/dom.js | createElement | function createElement(config){
var isConfig = config != undefined && typeof config != 'string';
var description = (isConfig ? config.description : config) || '';
var elementName = 'div'; // modern browsers become case sensetive for tag names for xhtml
var element;
// fetch tag name
var m = de... | javascript | function createElement(config){
var isConfig = config != undefined && typeof config != 'string';
var description = (isConfig ? config.description : config) || '';
var elementName = 'div'; // modern browsers become case sensetive for tag names for xhtml
var element;
// fetch tag name
var m = de... | [
"function",
"createElement",
"(",
"config",
")",
"{",
"var",
"isConfig",
"=",
"config",
"!=",
"undefined",
"&&",
"typeof",
"config",
"!=",
"'string'",
";",
"var",
"description",
"=",
"(",
"isConfig",
"?",
"config",
".",
"description",
":",
"config",
")",
"... | Creates a new Element with arguments as childs.
@param {string|object} config CSS-selector like definition or object for extended Element creation.
@param {...Node|object} children Child nodes
@return {!Element} The new Element. | [
"Creates",
"a",
"new",
"Element",
"with",
"arguments",
"as",
"childs",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L598-L690 | train |
basisjs/basisjs | src/basis/dom.js | insert | function insert(node, source, insertPoint, refChild){
node = get(node) || node; // TODO: remove
switch (insertPoint) {
case undefined: // insertPoint omitted
case INSERT_END:
refChild = null;
break;
case INSERT_BEGIN:
refChild = node[FIRST_CHILD];
break;
case... | javascript | function insert(node, source, insertPoint, refChild){
node = get(node) || node; // TODO: remove
switch (insertPoint) {
case undefined: // insertPoint omitted
case INSERT_END:
refChild = null;
break;
case INSERT_BEGIN:
refChild = node[FIRST_CHILD];
break;
case... | [
"function",
"insert",
"(",
"node",
",",
"source",
",",
"insertPoint",
",",
"refChild",
")",
"{",
"node",
"=",
"get",
"(",
"node",
")",
"||",
"node",
";",
"// TODO: remove",
"switch",
"(",
"insertPoint",
")",
"{",
"case",
"undefined",
":",
"// insertPoint o... | DOM manipulations
Insert source into specified insertPoint position of node.
@param {Node|object} node Destination node.
@param {Node|Array.<Node>|object|Array.<object>} source One or more nodes to be inserted.
@param {string|number=} insertPoint Number as value means position in nodes childNodes.
Also it might be on... | [
"DOM",
"manipulations",
"Insert",
"source",
"into",
"specified",
"insertPoint",
"position",
"of",
"node",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L705-L747 | train |
basisjs/basisjs | src/basis/dom.js | replace | function replace(oldNode, newNode){
return oldNode[PARENT_NODE] ? oldNode[PARENT_NODE].replaceChild(newNode, oldNode) : oldNode;
} | javascript | function replace(oldNode, newNode){
return oldNode[PARENT_NODE] ? oldNode[PARENT_NODE].replaceChild(newNode, oldNode) : oldNode;
} | [
"function",
"replace",
"(",
"oldNode",
",",
"newNode",
")",
"{",
"return",
"oldNode",
"[",
"PARENT_NODE",
"]",
"?",
"oldNode",
"[",
"PARENT_NODE",
"]",
".",
"replaceChild",
"(",
"newNode",
",",
"oldNode",
")",
":",
"oldNode",
";",
"}"
] | Replace oldNode for newNode and returns oldNode.
@param {Node} oldNode
@param {Node} newNode
@return {Node} | [
"Replace",
"oldNode",
"for",
"newNode",
"and",
"returns",
"oldNode",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L764-L766 | train |
basisjs/basisjs | src/basis/dom.js | swap | function swap(nodeA, nodeB){
if (nodeA === nodeB || comparePosition(nodeA, nodeB) & (POSITION_CONTAINED_BY | POSITION_CONTAINS | POSITION_DISCONNECTED))
return false;
replace(nodeA, testElement);
replace(nodeB, nodeA);
replace(testElement, nodeB);
return true;
} | javascript | function swap(nodeA, nodeB){
if (nodeA === nodeB || comparePosition(nodeA, nodeB) & (POSITION_CONTAINED_BY | POSITION_CONTAINS | POSITION_DISCONNECTED))
return false;
replace(nodeA, testElement);
replace(nodeB, nodeA);
replace(testElement, nodeB);
return true;
} | [
"function",
"swap",
"(",
"nodeA",
",",
"nodeB",
")",
"{",
"if",
"(",
"nodeA",
"===",
"nodeB",
"||",
"comparePosition",
"(",
"nodeA",
",",
"nodeB",
")",
"&",
"(",
"POSITION_CONTAINED_BY",
"|",
"POSITION_CONTAINS",
"|",
"POSITION_DISCONNECTED",
")",
")",
"retu... | Change placing of nodes and returns the result of operation.
@param {Node} nodeA
@param {Node} nodeB
@return {boolean} | [
"Change",
"placing",
"of",
"nodes",
"and",
"returns",
"the",
"result",
"of",
"operation",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L774-L783 | train |
basisjs/basisjs | src/basis/dom.js | clone | function clone(node, noChildren){
var result = node.cloneNode(!noChildren);
if (result.attachEvent) // clear event handlers for IE
axis(result, AXIS_DESCENDANT_OR_SELF).forEach(eventUtils.clearHandlers);
return result;
} | javascript | function clone(node, noChildren){
var result = node.cloneNode(!noChildren);
if (result.attachEvent) // clear event handlers for IE
axis(result, AXIS_DESCENDANT_OR_SELF).forEach(eventUtils.clearHandlers);
return result;
} | [
"function",
"clone",
"(",
"node",
",",
"noChildren",
")",
"{",
"var",
"result",
"=",
"node",
".",
"cloneNode",
"(",
"!",
"noChildren",
")",
";",
"if",
"(",
"result",
".",
"attachEvent",
")",
"// clear event handlers for IE",
"axis",
"(",
"result",
",",
"AX... | Clone node.
@param {Node} node
@param {boolean} noChildren If true than clone only node with no children.
@return {Node} | [
"Clone",
"node",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L791-L796 | train |
basisjs/basisjs | src/basis/dom.js | clear | function clear(node){
node = get(node);
while (node[LAST_CHILD])
node.removeChild(node[LAST_CHILD]);
return node;
} | javascript | function clear(node){
node = get(node);
while (node[LAST_CHILD])
node.removeChild(node[LAST_CHILD]);
return node;
} | [
"function",
"clear",
"(",
"node",
")",
"{",
"node",
"=",
"get",
"(",
"node",
")",
";",
"while",
"(",
"node",
"[",
"LAST_CHILD",
"]",
")",
"node",
".",
"removeChild",
"(",
"node",
"[",
"LAST_CHILD",
"]",
")",
";",
"return",
"node",
";",
"}"
] | Removes all child nodes of node and returns this node.
@param {Node} node
@return {Node} | [
"Removes",
"all",
"child",
"nodes",
"of",
"node",
"and",
"returns",
"this",
"node",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L803-L810 | train |
basisjs/basisjs | src/basis/dom.js | focus | function focus(node, select){
// try catch block here because browsers throw unexpected exeption in some cases
try {
node = get(node);
node.focus();
if (select && node.select) // && typeof node.select == 'function'
// temporary removed because IE returns 'objec... | javascript | function focus(node, select){
// try catch block here because browsers throw unexpected exeption in some cases
try {
node = get(node);
node.focus();
if (select && node.select) // && typeof node.select == 'function'
// temporary removed because IE returns 'objec... | [
"function",
"focus",
"(",
"node",
",",
"select",
")",
"{",
"// try catch block here because browsers throw unexpected exeption in some cases",
"try",
"{",
"node",
"=",
"get",
"(",
"node",
")",
";",
"node",
".",
"focus",
"(",
")",
";",
"if",
"(",
"select",
"&&",
... | Input selection stuff
Set focus for node.
@param {Element} node
@param {boolean=} select Call select() method of node. | [
"Input",
"selection",
"stuff",
"Set",
"focus",
"for",
"node",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/dom.js#L890-L899 | train |
basisjs/basisjs | src/basis/utils/utf16.js | toBytes | function toBytes(input){
var output = [];
var len = input.length;
for (var i = 0; i < len; i++)
{
var c = input.charCodeAt(i);
output.push(c & 0xFF, c >> 8);
}
return output;
} | javascript | function toBytes(input){
var output = [];
var len = input.length;
for (var i = 0; i < len; i++)
{
var c = input.charCodeAt(i);
output.push(c & 0xFF, c >> 8);
}
return output;
} | [
"function",
"toBytes",
"(",
"input",
")",
"{",
"var",
"output",
"=",
"[",
"]",
";",
"var",
"len",
"=",
"input",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"c",
"=",
"input",
... | utf16 string -> utf16 bytes array | [
"utf16",
"string",
"-",
">",
"utf16",
"bytes",
"array"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/utils/utf16.js#L11-L22 | train |
basisjs/basisjs | src/basis/utils/utf16.js | fromBytes | function fromBytes(input){
var output = '';
var len = input.length;
var i = 0;
var b1;
var b2;
while (i < len)
{
b1 = input[i++] || 0;
b2 = input[i++] || 0;
output += String.fromCharCode((b2 << 8) | b1);
}
return output;
} | javascript | function fromBytes(input){
var output = '';
var len = input.length;
var i = 0;
var b1;
var b2;
while (i < len)
{
b1 = input[i++] || 0;
b2 = input[i++] || 0;
output += String.fromCharCode((b2 << 8) | b1);
}
return output;
} | [
"function",
"fromBytes",
"(",
"input",
")",
"{",
"var",
"output",
"=",
"''",
";",
"var",
"len",
"=",
"input",
".",
"length",
";",
"var",
"i",
"=",
"0",
";",
"var",
"b1",
";",
"var",
"b2",
";",
"while",
"(",
"i",
"<",
"len",
")",
"{",
"b1",
"=... | utf16 bytes array -> utf16 string | [
"utf16",
"bytes",
"array",
"-",
">",
"utf16",
"string"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/utils/utf16.js#L25-L39 | train |
basisjs/basisjs | src/basis/utils/utf16.js | toUTF8 | function toUTF8(input){
var output = '';
var len = input.length;
for (var i = 0; i < len; i++)
{
var c = input.charCodeAt(i);
if (c < 128)
output += chars[c];
else
if (c < 2048)
output += chars[(c >> 6) | 192] +
chars[(c & 63) | 128];
... | javascript | function toUTF8(input){
var output = '';
var len = input.length;
for (var i = 0; i < len; i++)
{
var c = input.charCodeAt(i);
if (c < 128)
output += chars[c];
else
if (c < 2048)
output += chars[(c >> 6) | 192] +
chars[(c & 63) | 128];
... | [
"function",
"toUTF8",
"(",
"input",
")",
"{",
"var",
"output",
"=",
"''",
";",
"var",
"len",
"=",
"input",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"c",
"=",
"input",
".",
... | utf16 string -> utf8 string | [
"utf16",
"string",
"-",
">",
"utf8",
"string"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/utils/utf16.js#L42-L62 | train |
basisjs/basisjs | src/basis/utils/utf16.js | toUTF8Bytes | function toUTF8Bytes(input){
// utf16 -> utf8
input = toUTF8(input);
// string -> array of bytes
var len = input.length;
var output = new Array(len);
for (var i = 0; i < len; i++)
output[i] = input.charCodeAt(i);
return output;
} | javascript | function toUTF8Bytes(input){
// utf16 -> utf8
input = toUTF8(input);
// string -> array of bytes
var len = input.length;
var output = new Array(len);
for (var i = 0; i < len; i++)
output[i] = input.charCodeAt(i);
return output;
} | [
"function",
"toUTF8Bytes",
"(",
"input",
")",
"{",
"// utf16 -> utf8",
"input",
"=",
"toUTF8",
"(",
"input",
")",
";",
"// string -> array of bytes",
"var",
"len",
"=",
"input",
".",
"length",
";",
"var",
"output",
"=",
"new",
"Array",
"(",
"len",
")",
";"... | utf16 string -> utf8 bytes array | [
"utf16",
"string",
"-",
">",
"utf8",
"bytes",
"array"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/utils/utf16.js#L65-L77 | train |
basisjs/basisjs | src/basis/utils/utf16.js | fromUTF8 | function fromUTF8(input){
var output = '';
var len = input.length;
var i = 0;
var c1;
var c2;
var c3;
while (i < len)
{
c1 = input.charCodeAt(i++);
if (c1 < 128)
output += chars[c1];
else
{
c2 = input.charCodeAt(i++);
if (c1 & 32)
... | javascript | function fromUTF8(input){
var output = '';
var len = input.length;
var i = 0;
var c1;
var c2;
var c3;
while (i < len)
{
c1 = input.charCodeAt(i++);
if (c1 < 128)
output += chars[c1];
else
{
c2 = input.charCodeAt(i++);
if (c1 & 32)
... | [
"function",
"fromUTF8",
"(",
"input",
")",
"{",
"var",
"output",
"=",
"''",
";",
"var",
"len",
"=",
"input",
".",
"length",
";",
"var",
"i",
"=",
"0",
";",
"var",
"c1",
";",
"var",
"c2",
";",
"var",
"c3",
";",
"while",
"(",
"i",
"<",
"len",
"... | utf8 string -> utf16 string | [
"utf8",
"string",
"-",
">",
"utf16",
"string"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/utils/utf16.js#L80-L106 | train |
basisjs/basisjs | src/basis/ui.js | extendBinding | function extendBinding(binding, extension){
/** @cut */ var info = basis.dev.getInfo(extension, 'map');
binding.bindingId = bindingSeed++;
for (var key in extension)
{
var def = null;
var value = extension[key];
// NOTE: check for Node, because first extendBinding invoke before Node... | javascript | function extendBinding(binding, extension){
/** @cut */ var info = basis.dev.getInfo(extension, 'map');
binding.bindingId = bindingSeed++;
for (var key in extension)
{
var def = null;
var value = extension[key];
// NOTE: check for Node, because first extendBinding invoke before Node... | [
"function",
"extendBinding",
"(",
"binding",
",",
"extension",
")",
"{",
"/** @cut */",
"var",
"info",
"=",
"basis",
".",
"dev",
".",
"getInfo",
"(",
"extension",
",",
"'map'",
")",
";",
"binding",
".",
"bindingId",
"=",
"bindingSeed",
"++",
";",
"for",
... | Function that extends list of binding by extension.
@param {object} binding
@param {object} extension | [
"Function",
"that",
"extends",
"list",
"of",
"binding",
"by",
"extension",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/ui.js#L62-L144 | train |
basisjs/basisjs | src/basis/ui.js | function(actionName, event){
var action = this.action[actionName];
if (action)
action.call(this, event);
/** @cut */ if (!action)
/** @cut */ basis.dev.warn('template call `' + actionName + '` action, but it isn\'t defined in action list');
} | javascript | function(actionName, event){
var action = this.action[actionName];
if (action)
action.call(this, event);
/** @cut */ if (!action)
/** @cut */ basis.dev.warn('template call `' + actionName + '` action, but it isn\'t defined in action list');
} | [
"function",
"(",
"actionName",
",",
"event",
")",
"{",
"var",
"action",
"=",
"this",
".",
"action",
"[",
"actionName",
"]",
";",
"if",
"(",
"action",
")",
"action",
".",
"call",
"(",
"this",
",",
"event",
")",
";",
"/** @cut */",
"if",
"(",
"!",
"a... | Handler on template actions.
@param {string} actionName
@param {object} event | [
"Handler",
"on",
"template",
"actions",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/ui.js#L610-L618 | train | |
basisjs/basisjs | src/basis/ui.js | function(select){
var focusElement = this.tmpl ? this.tmpl.focus || this.element : null;
if (focusElement)
{
if (focusTimer)
focusTimer = basis.clearImmediate(focusTimer);
focusTimer = basis.setImmediate(function(){
try {
focusElement.f... | javascript | function(select){
var focusElement = this.tmpl ? this.tmpl.focus || this.element : null;
if (focusElement)
{
if (focusTimer)
focusTimer = basis.clearImmediate(focusTimer);
focusTimer = basis.setImmediate(function(){
try {
focusElement.f... | [
"function",
"(",
"select",
")",
"{",
"var",
"focusElement",
"=",
"this",
".",
"tmpl",
"?",
"this",
".",
"tmpl",
".",
"focus",
"||",
"this",
".",
"element",
":",
"null",
";",
"if",
"(",
"focusElement",
")",
"{",
"if",
"(",
"focusTimer",
")",
"focusTim... | Set focus on element in template, if possible.
@param {boolean=} select | [
"Set",
"focus",
"on",
"element",
"in",
"template",
"if",
"possible",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/ui.js#L624-L640 | train | |
basisjs/basisjs | src/basis/ui.js | function(){
var focusElement = this.tmpl ? this.tmpl.focus || this.element : null;
if (focusElement)
try {
focusElement.blur();
} catch(e) {}
} | javascript | function(){
var focusElement = this.tmpl ? this.tmpl.focus || this.element : null;
if (focusElement)
try {
focusElement.blur();
} catch(e) {}
} | [
"function",
"(",
")",
"{",
"var",
"focusElement",
"=",
"this",
".",
"tmpl",
"?",
"this",
".",
"tmpl",
".",
"focus",
"||",
"this",
".",
"element",
":",
"null",
";",
"if",
"(",
"focusElement",
")",
"try",
"{",
"focusElement",
".",
"blur",
"(",
")",
"... | Remove focus from element. | [
"Remove",
"focus",
"from",
"element",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/ui.js#L645-L652 | train | |
basisjs/basisjs | src/basis/ui.js | function(super_){
return {
// methods
insertBefore: function(newChild, refChild){
/** @cut */ if (this.noChildNodesElement_)
/** @cut */ {
/** @cut */ delete this.noChildNodesElement_;
/** @cut */ basis.dev.warn('basis.ui: Template has no childNodesElement container, ... | javascript | function(super_){
return {
// methods
insertBefore: function(newChild, refChild){
/** @cut */ if (this.noChildNodesElement_)
/** @cut */ {
/** @cut */ delete this.noChildNodesElement_;
/** @cut */ basis.dev.warn('basis.ui: Template has no childNodesElement container, ... | [
"function",
"(",
"super_",
")",
"{",
"return",
"{",
"// methods",
"insertBefore",
":",
"function",
"(",
"newChild",
",",
"refChild",
")",
"{",
"/** @cut */",
"if",
"(",
"this",
".",
"noChildNodesElement_",
")",
"/** @cut */",
"{",
"/** @cut */",
"delete",
"thi... | Template mixin for containers classes
@mixin | [
"Template",
"mixin",
"for",
"containers",
"classes"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/ui.js#L696-L785 | train | |
basisjs/basisjs | src/basis/tracker.js | track | function track(event){
try {
// TODO look up for event.data.transformer before setting data
tracker.set(event);
} catch(e) {
/** @cut */ basis.dev.error(namespace + '.track(): Error during tracking event processing', event, e);
}
} | javascript | function track(event){
try {
// TODO look up for event.data.transformer before setting data
tracker.set(event);
} catch(e) {
/** @cut */ basis.dev.error(namespace + '.track(): Error during tracking event processing', event, e);
}
} | [
"function",
"track",
"(",
"event",
")",
"{",
"try",
"{",
"// TODO look up for event.data.transformer before setting data",
"tracker",
".",
"set",
"(",
"event",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"/** @cut */",
"basis",
".",
"dev",
".",
"error",
"(",
... | Maps an event name to a list of tracking objects
@param {TrackingDataObject} event a tracking object
@private
@return | [
"Maps",
"an",
"event",
"name",
"to",
"a",
"list",
"of",
"tracking",
"objects"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L58-L65 | train |
basisjs/basisjs | src/basis/tracker.js | getCssSelectorFromPath | function getCssSelectorFromPath(path, selector){
return parsePath(path).map(function(role){
if (!role.role)
return '';
var start = escapeQuotes(role.role);
var end = (role.subrole ? '/' + escapeQuotes(role.subrole) : '') + '"]';
if (role.roleId)
{
if (selector && role.roleId == '*')
... | javascript | function getCssSelectorFromPath(path, selector){
return parsePath(path).map(function(role){
if (!role.role)
return '';
var start = escapeQuotes(role.role);
var end = (role.subrole ? '/' + escapeQuotes(role.subrole) : '') + '"]';
if (role.roleId)
{
if (selector && role.roleId == '*')
... | [
"function",
"getCssSelectorFromPath",
"(",
"path",
",",
"selector",
")",
"{",
"return",
"parsePath",
"(",
"path",
")",
".",
"map",
"(",
"function",
"(",
"role",
")",
"{",
"if",
"(",
"!",
"role",
".",
"role",
")",
"return",
"''",
";",
"var",
"start",
... | `show` event
Transforms given path to a css selector
@param {string} path
@param {string} selector
@private
@return {string} | [
"show",
"event",
"Transforms",
"given",
"path",
"to",
"a",
"css",
"selector"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L139-L161 | train |
basisjs/basisjs | src/basis/tracker.js | checkShow | function checkShow(){
/**
* Checks visibility of an element on a page in a browser
* @param {HTMLElement} element some DOM node
* @private
* @return {boolean}
*/
function isVisible(element){
if (getComputedStyle(element, 'visibility') != 'visible')
return false;
var box = getBoundingRe... | javascript | function checkShow(){
/**
* Checks visibility of an element on a page in a browser
* @param {HTMLElement} element some DOM node
* @private
* @return {boolean}
*/
function isVisible(element){
if (getComputedStyle(element, 'visibility') != 'visible')
return false;
var box = getBoundingRe... | [
"function",
"checkShow",
"(",
")",
"{",
"/**\n * Checks visibility of an element on a page in a browser\n * @param {HTMLElement} element some DOM node\n * @private\n * @return {boolean}\n */",
"function",
"isVisible",
"(",
"element",
")",
"{",
"if",
"(",
"getComputedStyle",
"... | Tracks visibilty changes for nodes marked with show event in custom tracking maps
@private
@return | [
"Tracks",
"visibilty",
"changes",
"for",
"nodes",
"marked",
"with",
"show",
"event",
"in",
"custom",
"tracking",
"maps"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L168-L213 | train |
basisjs/basisjs | src/basis/tracker.js | isVisible | function isVisible(element){
if (getComputedStyle(element, 'visibility') != 'visible')
return false;
var box = getBoundingRect(element);
if (!box.width || !box.height)
return false;
return true;
} | javascript | function isVisible(element){
if (getComputedStyle(element, 'visibility') != 'visible')
return false;
var box = getBoundingRect(element);
if (!box.width || !box.height)
return false;
return true;
} | [
"function",
"isVisible",
"(",
"element",
")",
"{",
"if",
"(",
"getComputedStyle",
"(",
"element",
",",
"'visibility'",
")",
"!=",
"'visible'",
")",
"return",
"false",
";",
"var",
"box",
"=",
"getBoundingRect",
"(",
"element",
")",
";",
"if",
"(",
"!",
"b... | Checks visibility of an element on a page in a browser
@param {HTMLElement} element some DOM node
@private
@return {boolean} | [
"Checks",
"visibility",
"of",
"an",
"element",
"on",
"a",
"page",
"in",
"a",
"browser"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L175-L185 | train |
basisjs/basisjs | src/basis/tracker.js | getSelectorList | function getSelectorList(eventName){
if (hasOwnProperty.call(eventMap, eventName))
return eventMap[eventName];
var selectorList = eventMap[eventName] = [];
var inputTimeout = null;
switch (eventName) {
case SHOW_EVENT:
selectorList.visible = {};
setInterval(checkShow, VISIBLE_CHECK_INTERVA... | javascript | function getSelectorList(eventName){
if (hasOwnProperty.call(eventMap, eventName))
return eventMap[eventName];
var selectorList = eventMap[eventName] = [];
var inputTimeout = null;
switch (eventName) {
case SHOW_EVENT:
selectorList.visible = {};
setInterval(checkShow, VISIBLE_CHECK_INTERVA... | [
"function",
"getSelectorList",
"(",
"eventName",
")",
"{",
"if",
"(",
"hasOwnProperty",
".",
"call",
"(",
"eventMap",
",",
"eventName",
")",
")",
"return",
"eventMap",
"[",
"eventName",
"]",
";",
"var",
"selectorList",
"=",
"eventMap",
"[",
"eventName",
"]",... | Fills up the eventMap, also adds a handler for each browser event, mentioned in custom tracking maps
@param {string} eventName browser event.type or SHOW_EVENT
@private
@return {Array} | [
"Fills",
"up",
"the",
"eventMap",
"also",
"adds",
"a",
"handler",
"for",
"each",
"browser",
"event",
"mentioned",
"in",
"custom",
"tracking",
"maps"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L333-L377 | train |
basisjs/basisjs | src/basis/tracker.js | getEventList | function getEventList(selector){
var selectorStr = stringifyPath(selector);
if (hasOwnProperty.call(selectorMap, selectorStr))
return selectorMap[selectorStr];
var eventList = selectorMap[selectorStr] = [];
eventList.selectorStr = selectorStr;
eventList.selector = selector;
return eventList;
} | javascript | function getEventList(selector){
var selectorStr = stringifyPath(selector);
if (hasOwnProperty.call(selectorMap, selectorStr))
return selectorMap[selectorStr];
var eventList = selectorMap[selectorStr] = [];
eventList.selectorStr = selectorStr;
eventList.selector = selector;
return eventList;
} | [
"function",
"getEventList",
"(",
"selector",
")",
"{",
"var",
"selectorStr",
"=",
"stringifyPath",
"(",
"selector",
")",
";",
"if",
"(",
"hasOwnProperty",
".",
"call",
"(",
"selectorMap",
",",
"selectorStr",
")",
")",
"return",
"selectorMap",
"[",
"selectorStr... | if there is no such selector in the `selectorMap`, creates empty array
@param {string} selector
@private
@return {Array} | [
"if",
"there",
"is",
"no",
"such",
"selector",
"in",
"the",
"selectorMap",
"creates",
"empty",
"array"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L385-L397 | train |
basisjs/basisjs | src/basis/tracker.js | stringifyRole | function stringifyRole(role){
if (typeof role == 'string')
return role;
if (!role)
return '';
return [
role.role || '',
role.roleId ? '(' + role.roleId + ')' : '',
role.subrole ? '/' + role.subrole : ''
].join('');
} | javascript | function stringifyRole(role){
if (typeof role == 'string')
return role;
if (!role)
return '';
return [
role.role || '',
role.roleId ? '(' + role.roleId + ')' : '',
role.subrole ? '/' + role.subrole : ''
].join('');
} | [
"function",
"stringifyRole",
"(",
"role",
")",
"{",
"if",
"(",
"typeof",
"role",
"==",
"'string'",
")",
"return",
"role",
";",
"if",
"(",
"!",
"role",
")",
"return",
"''",
";",
"return",
"[",
"role",
".",
"role",
"||",
"''",
",",
"role",
".",
"role... | Inverse to parseRole function.
Is used in devpanel.
@param {string|RoleObject} role
@return {string} | [
"Inverse",
"to",
"parseRole",
"function",
".",
"Is",
"used",
"in",
"devpanel",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L478-L490 | train |
basisjs/basisjs | src/basis/tracker.js | parsePath | function parsePath(value){
if (!Array.isArray(value))
value = String(value || '').trim().split(/\s+/);
return value.map(function(part){
if (typeof part == 'string')
return parseRole(part);
return part || {
role: '',
roleId: '',
subrole: ''
};
});
} | javascript | function parsePath(value){
if (!Array.isArray(value))
value = String(value || '').trim().split(/\s+/);
return value.map(function(part){
if (typeof part == 'string')
return parseRole(part);
return part || {
role: '',
roleId: '',
subrole: ''
};
});
} | [
"function",
"parsePath",
"(",
"value",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"value",
"=",
"String",
"(",
"value",
"||",
"''",
")",
".",
"trim",
"(",
")",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"retu... | Parses a string or a list to a list of role objects.
Private except for tests.
@param {string|Array.<string>} value
@return {Array.<RoleObject>} | [
"Parses",
"a",
"string",
"or",
"a",
"list",
"to",
"a",
"list",
"of",
"role",
"objects",
".",
"Private",
"except",
"for",
"tests",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L498-L512 | train |
basisjs/basisjs | src/basis/tracker.js | isPathMatchSelector | function isPathMatchSelector(path, selector){
function isMatch(path, selector){
path = typeof path == 'string' ? parseRole(path) : path || '';
selector = typeof selector == 'string' ? parseRole(selector) : selector || '';
return selector.role == path.role &&
(selector.roleId == '*' || selector... | javascript | function isPathMatchSelector(path, selector){
function isMatch(path, selector){
path = typeof path == 'string' ? parseRole(path) : path || '';
selector = typeof selector == 'string' ? parseRole(selector) : selector || '';
return selector.role == path.role &&
(selector.roleId == '*' || selector... | [
"function",
"isPathMatchSelector",
"(",
"path",
",",
"selector",
")",
"{",
"function",
"isMatch",
"(",
"path",
",",
"selector",
")",
"{",
"path",
"=",
"typeof",
"path",
"==",
"'string'",
"?",
"parseRole",
"(",
"path",
")",
":",
"path",
"||",
"''",
";",
... | private except for tests
@param {Array.<RoleObject>} path
@param {string|RoleObject} selector
@return {boolean} | [
"private",
"except",
"for",
"tests"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L533-L557 | train |
basisjs/basisjs | src/basis/tracker.js | getInfo | function getInfo(path){
var result = [];
if (typeof path == 'string')
path = parsePath(path);
for (var key in selectorMap)
if (isPathMatchSelector(path, selectorMap[key].selector))
result.push.apply(result, selectorMap[key].map(function(item){
return basis.object.extend({
selecto... | javascript | function getInfo(path){
var result = [];
if (typeof path == 'string')
path = parsePath(path);
for (var key in selectorMap)
if (isPathMatchSelector(path, selectorMap[key].selector))
result.push.apply(result, selectorMap[key].map(function(item){
return basis.object.extend({
selecto... | [
"function",
"getInfo",
"(",
"path",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"path",
"==",
"'string'",
")",
"path",
"=",
"parsePath",
"(",
"path",
")",
";",
"for",
"(",
"var",
"key",
"in",
"selectorMap",
")",
"if",
"(",
... | Relies on `selectorMap`
Is used in devpanel.
@param {string|Array.<RoleObject>} path
@return {Array.<Object>|boolean} here Object is a tracking data object | [
"Relies",
"on",
"selectorMap",
"Is",
"used",
"in",
"devpanel",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L565-L581 | train |
basisjs/basisjs | src/basis/tracker.js | getPathByNode | function getPathByNode(node){
var cursor = node;
var path = [];
var role;
while (cursor && cursor !== document)
{
if (role = cursor.getAttribute('role-marker'))
path.unshift(parseRole(role));
cursor = cursor.parentNode;
}
return path;
} | javascript | function getPathByNode(node){
var cursor = node;
var path = [];
var role;
while (cursor && cursor !== document)
{
if (role = cursor.getAttribute('role-marker'))
path.unshift(parseRole(role));
cursor = cursor.parentNode;
}
return path;
} | [
"function",
"getPathByNode",
"(",
"node",
")",
"{",
"var",
"cursor",
"=",
"node",
";",
"var",
"path",
"=",
"[",
"]",
";",
"var",
"role",
";",
"while",
"(",
"cursor",
"&&",
"cursor",
"!==",
"document",
")",
"{",
"if",
"(",
"role",
"=",
"cursor",
"."... | Works similar to `parsePath` but for DOM nodes, not for strings
Is used in devpanel.
@param {HTMLElement} node
@return {Array.<RoleObject>} | [
"Works",
"similar",
"to",
"parsePath",
"but",
"for",
"DOM",
"nodes",
"not",
"for",
"strings",
"Is",
"used",
"in",
"devpanel",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L589-L602 | train |
basisjs/basisjs | src/basis/tracker.js | loadMap | function loadMap(map){
if (!map)
{
/** @cut */ basis.dev.warn(namespace + '.loadMap(): Wrong value for map');
return;
}
for (var key in map)
{
var eventsMap = map[key];
if (!eventsMap)
{
/** @cut */ basis.dev.warn(namespace + '.loadMap(): Value of map should be an object for path: ... | javascript | function loadMap(map){
if (!map)
{
/** @cut */ basis.dev.warn(namespace + '.loadMap(): Wrong value for map');
return;
}
for (var key in map)
{
var eventsMap = map[key];
if (!eventsMap)
{
/** @cut */ basis.dev.warn(namespace + '.loadMap(): Value of map should be an object for path: ... | [
"function",
"loadMap",
"(",
"map",
")",
"{",
"if",
"(",
"!",
"map",
")",
"{",
"/** @cut */",
"basis",
".",
"dev",
".",
"warn",
"(",
"namespace",
"+",
"'.loadMap(): Wrong value for map'",
")",
";",
"return",
";",
"}",
"for",
"(",
"var",
"key",
"in",
"ma... | main API
Registers all selectors from a given map
@param {Object} map
@return | [
"main",
"API",
"Registers",
"all",
"selectors",
"from",
"a",
"given",
"map"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L613-L640 | train |
basisjs/basisjs | src/basis/tracker.js | addDispatcher | function addDispatcher(dispatcher, events, transformer){
if (!dispatcher || typeof dispatcher.addHandler != 'function')
{
/** @cut */ basis.dev.warn(namespace + '.addDispatcher(): First argument should have `addHandler` method');
return;
}
if (typeof events == 'string')
events = events.split(/\s+/)... | javascript | function addDispatcher(dispatcher, events, transformer){
if (!dispatcher || typeof dispatcher.addHandler != 'function')
{
/** @cut */ basis.dev.warn(namespace + '.addDispatcher(): First argument should have `addHandler` method');
return;
}
if (typeof events == 'string')
events = events.split(/\s+/)... | [
"function",
"addDispatcher",
"(",
"dispatcher",
",",
"events",
",",
"transformer",
")",
"{",
"if",
"(",
"!",
"dispatcher",
"||",
"typeof",
"dispatcher",
".",
"addHandler",
"!=",
"'function'",
")",
"{",
"/** @cut */",
"basis",
".",
"dev",
".",
"warn",
"(",
... | A way to add custom data to a tracking data object
@param {{ addHandler: function(object) }} dispatcher basis.net.transportDispatcher or another basis.event.Emitter or any object with addHandler function
@param {string|Array} events list of events recognizable by `dispatcher`
@param {function(event, item):object} trans... | [
"A",
"way",
"to",
"add",
"custom",
"data",
"to",
"a",
"tracking",
"data",
"object"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/tracker.js#L649-L689 | train |
basisjs/basisjs | src/basis/utils/utf8.js | fromBytes | function fromBytes(input){
var len = input.length;
var output = '';
for (var i = 0; i < len; i++)
output += chars[input[i]];
return output;
} | javascript | function fromBytes(input){
var len = input.length;
var output = '';
for (var i = 0; i < len; i++)
output += chars[input[i]];
return output;
} | [
"function",
"fromBytes",
"(",
"input",
")",
"{",
"var",
"len",
"=",
"input",
".",
"length",
";",
"var",
"output",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"output",
"+=",
"chars",
"[",
"input"... | utf8 bytes array | [
"utf8",
"bytes",
"array"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/utils/utf8.js#L23-L31 | train |
basisjs/basisjs | src/basis/entity.js | getDelta | function getDelta(inserted, deleted){
var delta = {};
var result;
if (inserted && inserted.length)
result = delta.inserted = inserted;
if (deleted && deleted.length)
result = delta.deleted = deleted;
if (result)
return delta;
} | javascript | function getDelta(inserted, deleted){
var delta = {};
var result;
if (inserted && inserted.length)
result = delta.inserted = inserted;
if (deleted && deleted.length)
result = delta.deleted = deleted;
if (result)
return delta;
} | [
"function",
"getDelta",
"(",
"inserted",
",",
"deleted",
")",
"{",
"var",
"delta",
"=",
"{",
"}",
";",
"var",
"result",
";",
"if",
"(",
"inserted",
"&&",
"inserted",
".",
"length",
")",
"result",
"=",
"delta",
".",
"inserted",
"=",
"inserted",
";",
"... | EntitySets
Returns delta object
@return {object|undefined} | [
"EntitySets",
"Returns",
"delta",
"object"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/entity.js#L220-L232 | train |
basisjs/basisjs | src/basis/data/dataset/Subtract.js | function(minuend, subtrahend){
var delta;
var operandsChanged = false;
var oldMinuend = this.minuend;
var oldSubtrahend = this.subtrahend;
minuend = resolveDataset(this, this.setMinuend, minuend, 'minuendRA_');
subtrahend = resolveDataset(this, this.setSubtrahend, subtrahend, 'subtrahendRA_');
... | javascript | function(minuend, subtrahend){
var delta;
var operandsChanged = false;
var oldMinuend = this.minuend;
var oldSubtrahend = this.subtrahend;
minuend = resolveDataset(this, this.setMinuend, minuend, 'minuendRA_');
subtrahend = resolveDataset(this, this.setSubtrahend, subtrahend, 'subtrahendRA_');
... | [
"function",
"(",
"minuend",
",",
"subtrahend",
")",
"{",
"var",
"delta",
";",
"var",
"operandsChanged",
"=",
"false",
";",
"var",
"oldMinuend",
"=",
"this",
".",
"minuend",
";",
"var",
"oldSubtrahend",
"=",
"this",
".",
"subtrahend",
";",
"minuend",
"=",
... | Set new minuend & subtrahend.
@param {basis.data.ReadOnlyDataset=} minuend
@param {basis.data.ReadOnlyDataset=} subtrahend
@return {object|boolean} Delta if changes happend | [
"Set",
"new",
"minuend",
"&",
"subtrahend",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/data/dataset/Subtract.js#L140-L221 | train | |
basisjs/basisjs | src/basis/template.js | resolveResource | function resolveResource(ref, baseURI){
// ref ~ "#123"
if (/^#\d+$/.test(ref))
return templateList[ref.substr(1)];
// ref ~ "id:foo"
if (/^id:/.test(ref))
return resolveSourceByDocumentId(ref.substr(3));
// ref ~ "foo.bar.baz"
if (/^[a-z0-9\.]+$/i.test(ref) && !/\.tmpl$/.test(ref)... | javascript | function resolveResource(ref, baseURI){
// ref ~ "#123"
if (/^#\d+$/.test(ref))
return templateList[ref.substr(1)];
// ref ~ "id:foo"
if (/^id:/.test(ref))
return resolveSourceByDocumentId(ref.substr(3));
// ref ~ "foo.bar.baz"
if (/^[a-z0-9\.]+$/i.test(ref) && !/\.tmpl$/.test(ref)... | [
"function",
"resolveResource",
"(",
"ref",
",",
"baseURI",
")",
"{",
"// ref ~ \"#123\"",
"if",
"(",
"/",
"^#\\d+$",
"/",
".",
"test",
"(",
"ref",
")",
")",
"return",
"templateList",
"[",
"ref",
".",
"substr",
"(",
"1",
")",
"]",
";",
"// ref ~ \"id:foo\... | Resolve source by given reference.
@param {string} ref
@param {string=} baseURI | [
"Resolve",
"source",
"by",
"given",
"reference",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/template.js#L80-L95 | train |
basisjs/basisjs | src/basis/template.js | templateSourceUpdate | function templateSourceUpdate(){
if (this.destroyBuilder)
buildTemplate.call(this);
var cursor = this;
while (cursor = cursor.attaches_)
cursor.handler.call(cursor.context);
} | javascript | function templateSourceUpdate(){
if (this.destroyBuilder)
buildTemplate.call(this);
var cursor = this;
while (cursor = cursor.attaches_)
cursor.handler.call(cursor.context);
} | [
"function",
"templateSourceUpdate",
"(",
")",
"{",
"if",
"(",
"this",
".",
"destroyBuilder",
")",
"buildTemplate",
".",
"call",
"(",
"this",
")",
";",
"var",
"cursor",
"=",
"this",
";",
"while",
"(",
"cursor",
"=",
"cursor",
".",
"attaches_",
")",
"curso... | Template
Function calls when bb-value template source is changing | [
"Template",
"Function",
"calls",
"when",
"bb",
"-",
"value",
"template",
"source",
"is",
"changing"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/template.js#L105-L112 | train |
basisjs/basisjs | src/basis/template.js | buildTemplate | function buildTemplate(){
// build new declaration
var declaration = getDeclFromSource(this.source, this.baseURI, false, {
isolate: this.getIsolatePrefix()
});
// make functions and assign to template
var destroyBuilder = this.destroyBuilder;
var instances = {};
var funcs = this.build... | javascript | function buildTemplate(){
// build new declaration
var declaration = getDeclFromSource(this.source, this.baseURI, false, {
isolate: this.getIsolatePrefix()
});
// make functions and assign to template
var destroyBuilder = this.destroyBuilder;
var instances = {};
var funcs = this.build... | [
"function",
"buildTemplate",
"(",
")",
"{",
"// build new declaration",
"var",
"declaration",
"=",
"getDeclFromSource",
"(",
"this",
".",
"source",
",",
"this",
".",
"baseURI",
",",
"false",
",",
"{",
"isolate",
":",
"this",
".",
"getIsolatePrefix",
"(",
")",
... | Internal function to build declaration by template source,
attach it to template and setup synchronization. | [
"Internal",
"function",
"to",
"build",
"declaration",
"by",
"template",
"source",
"attach",
"it",
"to",
"template",
"and",
"setup",
"synchronization",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/template.js#L118-L182 | train |
basisjs/basisjs | src/basis/template.js | function(object, actionCallback, updateCallback, bindings, bindingInterface){
buildTemplate.call(this);
return this.createInstance(object, actionCallback, updateCallback, bindings, bindingInterface);
} | javascript | function(object, actionCallback, updateCallback, bindings, bindingInterface){
buildTemplate.call(this);
return this.createInstance(object, actionCallback, updateCallback, bindings, bindingInterface);
} | [
"function",
"(",
"object",
",",
"actionCallback",
",",
"updateCallback",
",",
"bindings",
",",
"bindingInterface",
")",
"{",
"buildTemplate",
".",
"call",
"(",
"this",
")",
";",
"return",
"this",
".",
"createInstance",
"(",
"object",
",",
"actionCallback",
","... | Create DOM structure and return object with references for it's nodes.
@param {object=} object Object which templateAction method will be called on events.
@param {function=} actionCallback
@param {function=} updateCallback
@param {object=} bindings
@param {object=} bindingInterface Object like { attach: function(objec... | [
"Create",
"DOM",
"structure",
"and",
"return",
"object",
"with",
"references",
"for",
"it",
"s",
"nodes",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/template.js#L310-L313 | train | |
basisjs/basisjs | src/basis/template.js | function(source){
var oldSource = this.source;
if (oldSource != source)
{
if (typeof source == 'string')
{
var m = source.match(/^([a-z]+):/);
if (m)
{
source = source.substr(m[0].length);
switch (m[1])
{
... | javascript | function(source){
var oldSource = this.source;
if (oldSource != source)
{
if (typeof source == 'string')
{
var m = source.match(/^([a-z]+):/);
if (m)
{
source = source.substr(m[0].length);
switch (m[1])
{
... | [
"function",
"(",
"source",
")",
"{",
"var",
"oldSource",
"=",
"this",
".",
"source",
";",
"if",
"(",
"oldSource",
"!=",
"source",
")",
"{",
"if",
"(",
"typeof",
"source",
"==",
"'string'",
")",
"{",
"var",
"m",
"=",
"source",
".",
"match",
"(",
"/"... | Set new content source for template.
@param {string|bb-value} source New content source for template. | [
"Set",
"new",
"content",
"source",
"for",
"template",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/template.js#L335-L383 | train | |
basisjs/basisjs | src/basis/template.js | function(config){
this.ruleRet_ = [];
this.templates_ = [];
this.rule = config.rule;
var events = config.events;
if (events && events.length)
{
this.ruleEvents = {};
for (var i = 0, eventName; eventName = events[i]; i++)
this.ruleEvents[eventName] = true;
... | javascript | function(config){
this.ruleRet_ = [];
this.templates_ = [];
this.rule = config.rule;
var events = config.events;
if (events && events.length)
{
this.ruleEvents = {};
for (var i = 0, eventName; eventName = events[i]; i++)
this.ruleEvents[eventName] = true;
... | [
"function",
"(",
"config",
")",
"{",
"this",
".",
"ruleRet_",
"=",
"[",
"]",
";",
"this",
".",
"templates_",
"=",
"[",
"]",
";",
"this",
".",
"rule",
"=",
"config",
".",
"rule",
";",
"var",
"events",
"=",
"config",
".",
"events",
";",
"if",
"(",
... | return empty string as template source | [
"return",
"empty",
"string",
"as",
"template",
"source"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/template.js#L455-L469 | train | |
basisjs/basisjs | src/basis/template.js | switcher | function switcher(events, rule){
if (!rule)
{
rule = events;
events = null;
}
if (typeof events == 'string')
events = events.split(/\s+/);
return new TemplateSwitchConfig({
rule: rule,
events: events
});
} | javascript | function switcher(events, rule){
if (!rule)
{
rule = events;
events = null;
}
if (typeof events == 'string')
events = events.split(/\s+/);
return new TemplateSwitchConfig({
rule: rule,
events: events
});
} | [
"function",
"switcher",
"(",
"events",
",",
"rule",
")",
"{",
"if",
"(",
"!",
"rule",
")",
"{",
"rule",
"=",
"events",
";",
"events",
"=",
"null",
";",
"}",
"if",
"(",
"typeof",
"events",
"==",
"'string'",
")",
"events",
"=",
"events",
".",
"split"... | Helper to create TemplateSwitchConfig instance
@param {string|string[]} events
@param {function()} rule | [
"Helper",
"to",
"create",
"TemplateSwitchConfig",
"instance"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/template.js#L495-L509 | train |
basisjs/basisjs | src/basis/event.js | createDispatcher | function createDispatcher(eventName){
var eventFunction = events[eventName];
if (!eventFunction)
{
eventFunction = function(){
var cursor = this;
var args;
var fn;
while (cursor = cursor.handler)
{
// callback call
fn = cursor.callbacks[eve... | javascript | function createDispatcher(eventName){
var eventFunction = events[eventName];
if (!eventFunction)
{
eventFunction = function(){
var cursor = this;
var args;
var fn;
while (cursor = cursor.handler)
{
// callback call
fn = cursor.callbacks[eve... | [
"function",
"createDispatcher",
"(",
"eventName",
")",
"{",
"var",
"eventFunction",
"=",
"events",
"[",
"eventName",
"]",
";",
"if",
"(",
"!",
"eventFunction",
")",
"{",
"eventFunction",
"=",
"function",
"(",
")",
"{",
"var",
"cursor",
"=",
"this",
";",
... | Creates new type of event or returns existing one, if it was created before.
@param {string} eventName
@return {function(..eventArgs)} | [
"Creates",
"new",
"type",
"of",
"event",
"or",
"returns",
"existing",
"one",
"if",
"it",
"was",
"created",
"before",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/event.js#L34-L114 | train |
basisjs/basisjs | src/basis/event.js | function(callbacks, context){
/** @cut */ if (!callbacks)
/** @cut */ basis.dev.warn(namespace + '.Emitter#addHandler: callbacks is not an object (', callbacks, ')');
context = context || this;
// warn about duplicates
/** @cut */ var cursor = this;
/** @cut */ while (cursor = cu... | javascript | function(callbacks, context){
/** @cut */ if (!callbacks)
/** @cut */ basis.dev.warn(namespace + '.Emitter#addHandler: callbacks is not an object (', callbacks, ')');
context = context || this;
// warn about duplicates
/** @cut */ var cursor = this;
/** @cut */ while (cursor = cu... | [
"function",
"(",
"callbacks",
",",
"context",
")",
"{",
"/** @cut */",
"if",
"(",
"!",
"callbacks",
")",
"/** @cut */",
"basis",
".",
"dev",
".",
"warn",
"(",
"namespace",
"+",
"'.Emitter#addHandler: callbacks is not an object ('",
",",
"callbacks",
",",
"')'",
... | Adds new event handler to object.
@param {object} callbacks Callback set.
@param {object=} context Context object. | [
"Adds",
"new",
"event",
"handler",
"to",
"object",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/event.js#L238-L261 | train | |
basisjs/basisjs | src/basis/router.js | checkUrl | function checkUrl(){
var newPath = location.hash.substr(1) || '';
if (newPath != currentPath)
{
// check for recursion
if (preventRecursion(newPath))
return;
// save current path
currentPath = newPath;
var routesToLeave = [];
var routesToEnter = [];
var r... | javascript | function checkUrl(){
var newPath = location.hash.substr(1) || '';
if (newPath != currentPath)
{
// check for recursion
if (preventRecursion(newPath))
return;
// save current path
currentPath = newPath;
var routesToLeave = [];
var routesToEnter = [];
var r... | [
"function",
"checkUrl",
"(",
")",
"{",
"var",
"newPath",
"=",
"location",
".",
"hash",
".",
"substr",
"(",
"1",
")",
"||",
"''",
";",
"if",
"(",
"newPath",
"!=",
"currentPath",
")",
"{",
"// check for recursion",
"if",
"(",
"preventRecursion",
"(",
"newP... | Process current location | [
"Process",
"current",
"location"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/router.js#L601-L651 | train |
basisjs/basisjs | src/basis/router.js | get | function get(params){
var path = params.path;
var config = params.config;
if (path instanceof Route)
return path;
var route;
// If there is no config specified - it should be a plain route, so we try to reuse it
if (!config)
route = plainRoutesByPath[path];
if (!route && param... | javascript | function get(params){
var path = params.path;
var config = params.config;
if (path instanceof Route)
return path;
var route;
// If there is no config specified - it should be a plain route, so we try to reuse it
if (!config)
route = plainRoutesByPath[path];
if (!route && param... | [
"function",
"get",
"(",
"params",
")",
"{",
"var",
"path",
"=",
"params",
".",
"path",
";",
"var",
"config",
"=",
"params",
".",
"config",
";",
"if",
"(",
"path",
"instanceof",
"Route",
")",
"return",
"path",
";",
"var",
"route",
";",
"// If there is n... | Returns route descriptor | [
"Returns",
"route",
"descriptor"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/router.js#L663-L698 | train |
basisjs/basisjs | src/basis/router.js | add | function add(path, callback, context){
var route = get({
path: path,
autocreate: true
});
route.callbacks_.push({
cb_: callback,
context: context,
callback: typeof callback != 'function' ? callback || {} : {
match: callback
}
});
initSchedule.add(route);... | javascript | function add(path, callback, context){
var route = get({
path: path,
autocreate: true
});
route.callbacks_.push({
cb_: callback,
context: context,
callback: typeof callback != 'function' ? callback || {} : {
match: callback
}
});
initSchedule.add(route);... | [
"function",
"add",
"(",
"path",
",",
"callback",
",",
"context",
")",
"{",
"var",
"route",
"=",
"get",
"(",
"{",
"path",
":",
"path",
",",
"autocreate",
":",
"true",
"}",
")",
";",
"route",
".",
"callbacks_",
".",
"push",
"(",
"{",
"cb_",
":",
"c... | Add path to be handled | [
"Add",
"path",
"to",
"be",
"handled"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/router.js#L703-L720 | train |
basisjs/basisjs | src/basis/router.js | remove | function remove(route, callback, context){
var route = get({
path: route
});
if (!route)
return;
for (var i = 0, cb; cb = route.callbacks_[i]; i++)
{
if (cb.cb_ === callback && cb.context === context)
{
route.callbacks_.splice(i, 1);
if (route.value && call... | javascript | function remove(route, callback, context){
var route = get({
path: route
});
if (!route)
return;
for (var i = 0, cb; cb = route.callbacks_[i]; i++)
{
if (cb.cb_ === callback && cb.context === context)
{
route.callbacks_.splice(i, 1);
if (route.value && call... | [
"function",
"remove",
"(",
"route",
",",
"callback",
",",
"context",
")",
"{",
"var",
"route",
"=",
"get",
"(",
"{",
"path",
":",
"route",
"}",
")",
";",
"if",
"(",
"!",
"route",
")",
"return",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"cb",
... | Remove handler for path | [
"Remove",
"handler",
"for",
"path"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/router.js#L725-L766 | train |
basisjs/basisjs | src/basis/router.js | navigate | function navigate(path, replace){
if (replace)
location.replace(location.pathname + '#' + path);
else
location.hash = path;
if (started)
checkUrl();
} | javascript | function navigate(path, replace){
if (replace)
location.replace(location.pathname + '#' + path);
else
location.hash = path;
if (started)
checkUrl();
} | [
"function",
"navigate",
"(",
"path",
",",
"replace",
")",
"{",
"if",
"(",
"replace",
")",
"location",
".",
"replace",
"(",
"location",
".",
"pathname",
"+",
"'#'",
"+",
"path",
")",
";",
"else",
"location",
".",
"hash",
"=",
"path",
";",
"if",
"(",
... | Navigate to specified path | [
"Navigate",
"to",
"specified",
"path"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/router.js#L771-L779 | train |
basisjs/basisjs | src/basis/data/dataset/Merge.js | function(rule){
rule = basis.getter(rule || UNION);
if (this.rule !== rule)
{
var oldRule = this.rule;
this.rule = rule;
this.emit_ruleChanged(oldRule);
return this.applyRule();
}
} | javascript | function(rule){
rule = basis.getter(rule || UNION);
if (this.rule !== rule)
{
var oldRule = this.rule;
this.rule = rule;
this.emit_ruleChanged(oldRule);
return this.applyRule();
}
} | [
"function",
"(",
"rule",
")",
"{",
"rule",
"=",
"basis",
".",
"getter",
"(",
"rule",
"||",
"UNION",
")",
";",
"if",
"(",
"this",
".",
"rule",
"!==",
"rule",
")",
"{",
"var",
"oldRule",
"=",
"this",
".",
"rule",
";",
"this",
".",
"rule",
"=",
"r... | Set new merge rule for dataset. Some types are available in basis.data.Dataset.Merge
@param {function(count:number, sourceCount:number):boolean|string} rule New rule.
@return {Object} Delta of member changes. | [
"Set",
"new",
"merge",
"rule",
"for",
"dataset",
".",
"Some",
"types",
"are",
"available",
"in",
"basis",
".",
"data",
".",
"Dataset",
".",
"Merge"
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/data/dataset/Merge.js#L210-L222 | train | |
basisjs/basisjs | src/basis/data/dataset/Merge.js | function(scope){
var memberMap = this.members_;
var rule = this.rule;
var sourceCount = this.sources.length;
var inserted = [];
var deleted = [];
var memberCounter;
var isMember;
var delta;
if (!scope)
scope = memberMap;
for (var objectId in scope)
{
memberCount... | javascript | function(scope){
var memberMap = this.members_;
var rule = this.rule;
var sourceCount = this.sources.length;
var inserted = [];
var deleted = [];
var memberCounter;
var isMember;
var delta;
if (!scope)
scope = memberMap;
for (var objectId in scope)
{
memberCount... | [
"function",
"(",
"scope",
")",
"{",
"var",
"memberMap",
"=",
"this",
".",
"members_",
";",
"var",
"rule",
"=",
"this",
".",
"rule",
";",
"var",
"sourceCount",
"=",
"this",
".",
"sources",
".",
"length",
";",
"var",
"inserted",
"=",
"[",
"]",
";",
"... | Check all members are they match to rule or not.
@param {Object=} scope Key map that will be checked. If not passed than all members
will be checked.
@return {Object} Delta of member changes. | [
"Check",
"all",
"members",
"are",
"they",
"match",
"to",
"rule",
"or",
"not",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/data/dataset/Merge.js#L230-L273 | train | |
basisjs/basisjs | src/basis/data/dataset/Merge.js | function(source){
// this -> sourceInfo
var merge = this.owner;
var sourcesMap_ = merge.sourcesMap_;
var dataset = resolveDataset(this, merge.updateDataset_, source, 'adapter', merge);
var inserted;
var deleted;
var delta;
if (this.dataset === dataset)
return;
if (dataset)
... | javascript | function(source){
// this -> sourceInfo
var merge = this.owner;
var sourcesMap_ = merge.sourcesMap_;
var dataset = resolveDataset(this, merge.updateDataset_, source, 'adapter', merge);
var inserted;
var deleted;
var delta;
if (this.dataset === dataset)
return;
if (dataset)
... | [
"function",
"(",
"source",
")",
"{",
"// this -> sourceInfo",
"var",
"merge",
"=",
"this",
".",
"owner",
";",
"var",
"sourcesMap_",
"=",
"merge",
".",
"sourcesMap_",
";",
"var",
"dataset",
"=",
"resolveDataset",
"(",
"this",
",",
"merge",
".",
"updateDataset... | Update dataset value by source.
@param {*} source
@private | [
"Update",
"dataset",
"value",
"by",
"source",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/data/dataset/Merge.js#L333-L397 | train | |
basisjs/basisjs | src/basis/data/dataset/Merge.js | function(source){
if (!source || (typeof source != 'object' && typeof source != 'function'))
{
/** @cut */ basis.dev.warn(this.constructor.className + '.addSource: value should be a dataset instance or to be able to resolve in dataset');
return;
}
if (this.hasSource(source))
{
/**... | javascript | function(source){
if (!source || (typeof source != 'object' && typeof source != 'function'))
{
/** @cut */ basis.dev.warn(this.constructor.className + '.addSource: value should be a dataset instance or to be able to resolve in dataset');
return;
}
if (this.hasSource(source))
{
/**... | [
"function",
"(",
"source",
")",
"{",
"if",
"(",
"!",
"source",
"||",
"(",
"typeof",
"source",
"!=",
"'object'",
"&&",
"typeof",
"source",
"!=",
"'function'",
")",
")",
"{",
"/** @cut */",
"basis",
".",
"dev",
".",
"warn",
"(",
"this",
".",
"constructor... | Add source from sources list.
@param {basis.data.ReadOnlyDataset|object|function()} source
@return {boolean} Returns true if new source added. | [
"Add",
"source",
"from",
"sources",
"list",
"."
] | 8571903014b207a09d45ad2d1bfba277bf21289b | https://github.com/basisjs/basisjs/blob/8571903014b207a09d45ad2d1bfba277bf21289b/src/basis/data/dataset/Merge.js#L414-L439 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.