id
int32 0
58k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
19,900
|
jsdoc2md/dmd
|
helpers/ddata.js
|
parentName
|
function parentName (options) {
function instantiate (input) {
if (/^[A-Z]{3}/.test(input)) {
return input.replace(/^([A-Z]+)([A-Z])/, function (str, p1, p2) {
return p1.toLowerCase() + p2
})
} else {
return input.charAt(0).toLowerCase() + input.slice(1)
}
}
/* don't bother with a parentName for exported identifiers */
if (this.isExported) return ''
if (this.memberof && this.kind !== 'constructor') {
var parent = arrayify(options.data.root).find(where({ id: this.memberof }))
if (parent) {
if (this.scope === 'instance') {
var name = parent.typicalname || parent.name
return instantiate(name)
} else if (this.scope === 'static' && !(parent.kind === 'class' || parent.kind === 'constructor')) {
return parent.typicalname || parent.name
} else {
return parent.name
}
} else {
return this.memberof
}
}
}
|
javascript
|
function parentName (options) {
function instantiate (input) {
if (/^[A-Z]{3}/.test(input)) {
return input.replace(/^([A-Z]+)([A-Z])/, function (str, p1, p2) {
return p1.toLowerCase() + p2
})
} else {
return input.charAt(0).toLowerCase() + input.slice(1)
}
}
/* don't bother with a parentName for exported identifiers */
if (this.isExported) return ''
if (this.memberof && this.kind !== 'constructor') {
var parent = arrayify(options.data.root).find(where({ id: this.memberof }))
if (parent) {
if (this.scope === 'instance') {
var name = parent.typicalname || parent.name
return instantiate(name)
} else if (this.scope === 'static' && !(parent.kind === 'class' || parent.kind === 'constructor')) {
return parent.typicalname || parent.name
} else {
return parent.name
}
} else {
return this.memberof
}
}
}
|
[
"function",
"parentName",
"(",
"options",
")",
"{",
"function",
"instantiate",
"(",
"input",
")",
"{",
"if",
"(",
"/",
"^[A-Z]{3}",
"/",
".",
"test",
"(",
"input",
")",
")",
"{",
"return",
"input",
".",
"replace",
"(",
"/",
"^([A-Z]+)([A-Z])",
"/",
",",
"function",
"(",
"str",
",",
"p1",
",",
"p2",
")",
"{",
"return",
"p1",
".",
"toLowerCase",
"(",
")",
"+",
"p2",
"}",
")",
"}",
"else",
"{",
"return",
"input",
".",
"charAt",
"(",
"0",
")",
".",
"toLowerCase",
"(",
")",
"+",
"input",
".",
"slice",
"(",
"1",
")",
"}",
"}",
"/* don't bother with a parentName for exported identifiers */",
"if",
"(",
"this",
".",
"isExported",
")",
"return",
"''",
"if",
"(",
"this",
".",
"memberof",
"&&",
"this",
".",
"kind",
"!==",
"'constructor'",
")",
"{",
"var",
"parent",
"=",
"arrayify",
"(",
"options",
".",
"data",
".",
"root",
")",
".",
"find",
"(",
"where",
"(",
"{",
"id",
":",
"this",
".",
"memberof",
"}",
")",
")",
"if",
"(",
"parent",
")",
"{",
"if",
"(",
"this",
".",
"scope",
"===",
"'instance'",
")",
"{",
"var",
"name",
"=",
"parent",
".",
"typicalname",
"||",
"parent",
".",
"name",
"return",
"instantiate",
"(",
"name",
")",
"}",
"else",
"if",
"(",
"this",
".",
"scope",
"===",
"'static'",
"&&",
"!",
"(",
"parent",
".",
"kind",
"===",
"'class'",
"||",
"parent",
".",
"kind",
"===",
"'constructor'",
")",
")",
"{",
"return",
"parent",
".",
"typicalname",
"||",
"parent",
".",
"name",
"}",
"else",
"{",
"return",
"parent",
".",
"name",
"}",
"}",
"else",
"{",
"return",
"this",
".",
"memberof",
"}",
"}",
"}"
] |
returns the parent name, instantiated if necessary
@this {identifier}
@returns {string}
@static
|
[
"returns",
"the",
"parent",
"name",
"instantiated",
"if",
"necessary"
] |
a4b31ec41f3b3a523c354877ac488da33314fc1f
|
https://github.com/jsdoc2md/dmd/blob/a4b31ec41f3b3a523c354877ac488da33314fc1f/helpers/ddata.js#L670-L699
|
19,901
|
tejacques/crosstab
|
src/crosstab.js
|
function (iters) {
var diff = util.now() - start;
if (!setupComplete) {
if (iters <= 0 && diff > PING_TIMEOUT) {
frozenTabEnvironmentDetected();
util.events.emit('setupComplete');
} else {
timeout = setTimeout(function () {
recursiveTimeout(iters - 1);
}, 5);
}
}
}
|
javascript
|
function (iters) {
var diff = util.now() - start;
if (!setupComplete) {
if (iters <= 0 && diff > PING_TIMEOUT) {
frozenTabEnvironmentDetected();
util.events.emit('setupComplete');
} else {
timeout = setTimeout(function () {
recursiveTimeout(iters - 1);
}, 5);
}
}
}
|
[
"function",
"(",
"iters",
")",
"{",
"var",
"diff",
"=",
"util",
".",
"now",
"(",
")",
"-",
"start",
";",
"if",
"(",
"!",
"setupComplete",
")",
"{",
"if",
"(",
"iters",
"<=",
"0",
"&&",
"diff",
">",
"PING_TIMEOUT",
")",
"{",
"frozenTabEnvironmentDetected",
"(",
")",
";",
"util",
".",
"events",
".",
"emit",
"(",
"'setupComplete'",
")",
";",
"}",
"else",
"{",
"timeout",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"recursiveTimeout",
"(",
"iters",
"-",
"1",
")",
";",
"}",
",",
"5",
")",
";",
"}",
"}",
"}"
] |
There is a nested timeout here. We'll give it 100ms timeout, with iters "yields" to the event loop. So at least iters number of blocks of javascript will be able to run covering at least 100ms
|
[
"There",
"is",
"a",
"nested",
"timeout",
"here",
".",
"We",
"ll",
"give",
"it",
"100ms",
"timeout",
"with",
"iters",
"yields",
"to",
"the",
"event",
"loop",
".",
"So",
"at",
"least",
"iters",
"number",
"of",
"blocks",
"of",
"javascript",
"will",
"be",
"able",
"to",
"run",
"covering",
"at",
"least",
"100ms"
] |
ae48131e46cbae77e7003fa908c7fdafa205c00b
|
https://github.com/tejacques/crosstab/blob/ae48131e46cbae77e7003fa908c7fdafa205c00b/src/crosstab.js#L749-L762
|
|
19,902
|
mongodb-js/mongodb-schema
|
lib/stream.js
|
function(value) {
var T;
if (value && value._bsontype) {
T = value._bsontype;
} else {
T = Object.prototype.toString.call(value).replace(/\[object (\w+)\]/, '$1');
}
if (T === 'Object') {
T = 'Document';
}
return T;
}
|
javascript
|
function(value) {
var T;
if (value && value._bsontype) {
T = value._bsontype;
} else {
T = Object.prototype.toString.call(value).replace(/\[object (\w+)\]/, '$1');
}
if (T === 'Object') {
T = 'Document';
}
return T;
}
|
[
"function",
"(",
"value",
")",
"{",
"var",
"T",
";",
"if",
"(",
"value",
"&&",
"value",
".",
"_bsontype",
")",
"{",
"T",
"=",
"value",
".",
"_bsontype",
";",
"}",
"else",
"{",
"T",
"=",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"value",
")",
".",
"replace",
"(",
"/",
"\\[object (\\w+)\\]",
"/",
",",
"'$1'",
")",
";",
"}",
"if",
"(",
"T",
"===",
"'Object'",
")",
"{",
"T",
"=",
"'Document'",
";",
"}",
"return",
"T",
";",
"}"
] |
Returns the type of value as a string. BSON type aware. Replaces `Object`
with `Document` to avoid naming conflicts with javascript Objects.
@param {Any} value value for which to get the type
@param {Any} path path (in dot notation) for which to get the type
@return {String} type as string, e.g. `ObjectId`, `Document`, `Date`,
`Number`, `Undefined`, `Boolean`, ...
|
[
"Returns",
"the",
"type",
"of",
"value",
"as",
"a",
"string",
".",
"BSON",
"type",
"aware",
".",
"Replaces",
"Object",
"with",
"Document",
"to",
"avoid",
"naming",
"conflicts",
"with",
"javascript",
"Objects",
"."
] |
8a11d3816dae1b5799de7cbe8f577ea5256a015a
|
https://github.com/mongodb-js/mongodb-schema/blob/8a11d3816dae1b5799de7cbe8f577ea5256a015a/lib/stream.js#L193-L204
|
|
19,903
|
mongodb-js/mongodb-schema
|
lib/stream.js
|
function(type, value) {
if (type.name === 'String') {
// crop strings at 10k characters
if (value.length > 10000) {
value = value.slice(0, 10000);
}
}
type.values.pushSome(value);
}
|
javascript
|
function(type, value) {
if (type.name === 'String') {
// crop strings at 10k characters
if (value.length > 10000) {
value = value.slice(0, 10000);
}
}
type.values.pushSome(value);
}
|
[
"function",
"(",
"type",
",",
"value",
")",
"{",
"if",
"(",
"type",
".",
"name",
"===",
"'String'",
")",
"{",
"// crop strings at 10k characters",
"if",
"(",
"value",
".",
"length",
">",
"10000",
")",
"{",
"value",
"=",
"value",
".",
"slice",
"(",
"0",
",",
"10000",
")",
";",
"}",
"}",
"type",
".",
"values",
".",
"pushSome",
"(",
"value",
")",
";",
"}"
] |
handles adding the value to the value reservoir. Will also crop
strings at 10,000 characters.
@param {Object} type the type object from `addToType`
@param {Any} value the value to be added to `type.values`
|
[
"handles",
"adding",
"the",
"value",
"to",
"the",
"value",
"reservoir",
".",
"Will",
"also",
"crop",
"strings",
"at",
"10",
"000",
"characters",
"."
] |
8a11d3816dae1b5799de7cbe8f577ea5256a015a
|
https://github.com/mongodb-js/mongodb-schema/blob/8a11d3816dae1b5799de7cbe8f577ea5256a015a/lib/stream.js#L220-L228
|
|
19,904
|
mongodb-js/mongodb-schema
|
lib/stream.js
|
function(path, value, schema) {
var bsonType = getBSONType(value);
// if semantic type detection is enabled, the type is the semantic type
// or the original bson type if no semantic type was detected. If disabled,
// it is always the bson type.
var typeName = (options.semanticTypes) ?
getSemanticType(value, path) || bsonType : bsonType;
var type = schema[typeName] = _.get(schema, typeName, {
name: typeName,
bsonType: bsonType,
path: path,
count: 0
});
type.count++;
// recurse into arrays by calling `addToType` for each element
if (typeName === 'Array') {
type.types = _.get(type, 'types', {});
type.lengths = _.get(type, 'lengths', []);
type.lengths.push(value.length);
_.each(value, function(v) {
addToType(path, v, type.types);
});
// recurse into nested documents by calling `addToField` for all sub-fields
} else if (typeName === 'Document') {
type.fields = _.get(type, 'fields', {});
_.forOwn(value, function(v, k) {
addToField(path + '.' + k, v, type.fields);
});
// if the `storeValues` option is enabled, store some example values
} else if (options.storeValues) {
type.values = _.get(type, 'values', bsonType === 'String' ?
new Reservoir(100) : new Reservoir(10000));
addToValue(type, value);
}
}
|
javascript
|
function(path, value, schema) {
var bsonType = getBSONType(value);
// if semantic type detection is enabled, the type is the semantic type
// or the original bson type if no semantic type was detected. If disabled,
// it is always the bson type.
var typeName = (options.semanticTypes) ?
getSemanticType(value, path) || bsonType : bsonType;
var type = schema[typeName] = _.get(schema, typeName, {
name: typeName,
bsonType: bsonType,
path: path,
count: 0
});
type.count++;
// recurse into arrays by calling `addToType` for each element
if (typeName === 'Array') {
type.types = _.get(type, 'types', {});
type.lengths = _.get(type, 'lengths', []);
type.lengths.push(value.length);
_.each(value, function(v) {
addToType(path, v, type.types);
});
// recurse into nested documents by calling `addToField` for all sub-fields
} else if (typeName === 'Document') {
type.fields = _.get(type, 'fields', {});
_.forOwn(value, function(v, k) {
addToField(path + '.' + k, v, type.fields);
});
// if the `storeValues` option is enabled, store some example values
} else if (options.storeValues) {
type.values = _.get(type, 'values', bsonType === 'String' ?
new Reservoir(100) : new Reservoir(10000));
addToValue(type, value);
}
}
|
[
"function",
"(",
"path",
",",
"value",
",",
"schema",
")",
"{",
"var",
"bsonType",
"=",
"getBSONType",
"(",
"value",
")",
";",
"// if semantic type detection is enabled, the type is the semantic type",
"// or the original bson type if no semantic type was detected. If disabled,",
"// it is always the bson type.",
"var",
"typeName",
"=",
"(",
"options",
".",
"semanticTypes",
")",
"?",
"getSemanticType",
"(",
"value",
",",
"path",
")",
"||",
"bsonType",
":",
"bsonType",
";",
"var",
"type",
"=",
"schema",
"[",
"typeName",
"]",
"=",
"_",
".",
"get",
"(",
"schema",
",",
"typeName",
",",
"{",
"name",
":",
"typeName",
",",
"bsonType",
":",
"bsonType",
",",
"path",
":",
"path",
",",
"count",
":",
"0",
"}",
")",
";",
"type",
".",
"count",
"++",
";",
"// recurse into arrays by calling `addToType` for each element",
"if",
"(",
"typeName",
"===",
"'Array'",
")",
"{",
"type",
".",
"types",
"=",
"_",
".",
"get",
"(",
"type",
",",
"'types'",
",",
"{",
"}",
")",
";",
"type",
".",
"lengths",
"=",
"_",
".",
"get",
"(",
"type",
",",
"'lengths'",
",",
"[",
"]",
")",
";",
"type",
".",
"lengths",
".",
"push",
"(",
"value",
".",
"length",
")",
";",
"_",
".",
"each",
"(",
"value",
",",
"function",
"(",
"v",
")",
"{",
"addToType",
"(",
"path",
",",
"v",
",",
"type",
".",
"types",
")",
";",
"}",
")",
";",
"// recurse into nested documents by calling `addToField` for all sub-fields",
"}",
"else",
"if",
"(",
"typeName",
"===",
"'Document'",
")",
"{",
"type",
".",
"fields",
"=",
"_",
".",
"get",
"(",
"type",
",",
"'fields'",
",",
"{",
"}",
")",
";",
"_",
".",
"forOwn",
"(",
"value",
",",
"function",
"(",
"v",
",",
"k",
")",
"{",
"addToField",
"(",
"path",
"+",
"'.'",
"+",
"k",
",",
"v",
",",
"type",
".",
"fields",
")",
";",
"}",
")",
";",
"// if the `storeValues` option is enabled, store some example values",
"}",
"else",
"if",
"(",
"options",
".",
"storeValues",
")",
"{",
"type",
".",
"values",
"=",
"_",
".",
"get",
"(",
"type",
",",
"'values'",
",",
"bsonType",
"===",
"'String'",
"?",
"new",
"Reservoir",
"(",
"100",
")",
":",
"new",
"Reservoir",
"(",
"10000",
")",
")",
";",
"addToValue",
"(",
"type",
",",
"value",
")",
";",
"}",
"}"
] |
Takes a field value, determines the correct type, handles recursion into
nested arrays and documents, and passes the value down to `addToValue`.
@param {String} path field path in dot notation
@param {Any} value value of the field
@param {Object} schema the updated schema object
|
[
"Takes",
"a",
"field",
"value",
"determines",
"the",
"correct",
"type",
"handles",
"recursion",
"into",
"nested",
"arrays",
"and",
"documents",
"and",
"passes",
"the",
"value",
"down",
"to",
"addToValue",
"."
] |
8a11d3816dae1b5799de7cbe8f577ea5256a015a
|
https://github.com/mongodb-js/mongodb-schema/blob/8a11d3816dae1b5799de7cbe8f577ea5256a015a/lib/stream.js#L239-L275
|
|
19,905
|
cfpb/capital-framework
|
packages/cf-expandables/src/Expandable.js
|
initialize
|
function initialize() {
const transition = new ExpandableTransition(
this.ui.content
);
this.transition = transition.init();
if ( this.ui.content.classList.contains( ExpandableTransition.CLASSES.EXPANDED ) ) {
this.ui.target.classList.add( this.classes.targetExpanded );
} else {
this.ui.target.classList.add( this.classes.targetCollapsed );
}
const expandableGroup = closest( this.ui.target, '.' + this.classes.group );
this.isAccordionGroup = expandableGroup !== null &&
expandableGroup.classList.contains( this.classes.groupAccordion );
if ( this.isAccordionGroup ) {
Events.on(
'accordionActivated',
_accordionActivatedHandler.bind( this )
);
}
}
|
javascript
|
function initialize() {
const transition = new ExpandableTransition(
this.ui.content
);
this.transition = transition.init();
if ( this.ui.content.classList.contains( ExpandableTransition.CLASSES.EXPANDED ) ) {
this.ui.target.classList.add( this.classes.targetExpanded );
} else {
this.ui.target.classList.add( this.classes.targetCollapsed );
}
const expandableGroup = closest( this.ui.target, '.' + this.classes.group );
this.isAccordionGroup = expandableGroup !== null &&
expandableGroup.classList.contains( this.classes.groupAccordion );
if ( this.isAccordionGroup ) {
Events.on(
'accordionActivated',
_accordionActivatedHandler.bind( this )
);
}
}
|
[
"function",
"initialize",
"(",
")",
"{",
"const",
"transition",
"=",
"new",
"ExpandableTransition",
"(",
"this",
".",
"ui",
".",
"content",
")",
";",
"this",
".",
"transition",
"=",
"transition",
".",
"init",
"(",
")",
";",
"if",
"(",
"this",
".",
"ui",
".",
"content",
".",
"classList",
".",
"contains",
"(",
"ExpandableTransition",
".",
"CLASSES",
".",
"EXPANDED",
")",
")",
"{",
"this",
".",
"ui",
".",
"target",
".",
"classList",
".",
"add",
"(",
"this",
".",
"classes",
".",
"targetExpanded",
")",
";",
"}",
"else",
"{",
"this",
".",
"ui",
".",
"target",
".",
"classList",
".",
"add",
"(",
"this",
".",
"classes",
".",
"targetCollapsed",
")",
";",
"}",
"const",
"expandableGroup",
"=",
"closest",
"(",
"this",
".",
"ui",
".",
"target",
",",
"'.'",
"+",
"this",
".",
"classes",
".",
"group",
")",
";",
"this",
".",
"isAccordionGroup",
"=",
"expandableGroup",
"!==",
"null",
"&&",
"expandableGroup",
".",
"classList",
".",
"contains",
"(",
"this",
".",
"classes",
".",
"groupAccordion",
")",
";",
"if",
"(",
"this",
".",
"isAccordionGroup",
")",
"{",
"Events",
".",
"on",
"(",
"'accordionActivated'",
",",
"_accordionActivatedHandler",
".",
"bind",
"(",
"this",
")",
")",
";",
"}",
"}"
] |
Initialize a new expandable.
|
[
"Initialize",
"a",
"new",
"expandable",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-expandables/src/Expandable.js#L45-L68
|
19,906
|
cfpb/capital-framework
|
packages/cf-expandables/src/Expandable.js
|
expandableClickHandler
|
function expandableClickHandler() {
this.transition.toggleExpandable();
this.toggleTargetState( this.ui.target );
if ( this.isAccordionGroup ) {
if ( this.activeAccordion ) {
this.activeAccordion = false;
} else {
Events.trigger( 'accordionActivated', { target: this } );
this.activeAccordion = true;
}
}
}
|
javascript
|
function expandableClickHandler() {
this.transition.toggleExpandable();
this.toggleTargetState( this.ui.target );
if ( this.isAccordionGroup ) {
if ( this.activeAccordion ) {
this.activeAccordion = false;
} else {
Events.trigger( 'accordionActivated', { target: this } );
this.activeAccordion = true;
}
}
}
|
[
"function",
"expandableClickHandler",
"(",
")",
"{",
"this",
".",
"transition",
".",
"toggleExpandable",
"(",
")",
";",
"this",
".",
"toggleTargetState",
"(",
"this",
".",
"ui",
".",
"target",
")",
";",
"if",
"(",
"this",
".",
"isAccordionGroup",
")",
"{",
"if",
"(",
"this",
".",
"activeAccordion",
")",
"{",
"this",
".",
"activeAccordion",
"=",
"false",
";",
"}",
"else",
"{",
"Events",
".",
"trigger",
"(",
"'accordionActivated'",
",",
"{",
"target",
":",
"this",
"}",
")",
";",
"this",
".",
"activeAccordion",
"=",
"true",
";",
"}",
"}",
"}"
] |
Event handler for when an expandable is clicked.
|
[
"Event",
"handler",
"for",
"when",
"an",
"expandable",
"is",
"clicked",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-expandables/src/Expandable.js#L84-L96
|
19,907
|
cfpb/capital-framework
|
packages/cf-expandables/src/Expandable.js
|
toggleTargetState
|
function toggleTargetState( element ) {
if ( element.classList.contains( this.classes.targetExpanded ) ) {
this.ui.target.classList.add( this.classes.targetCollapsed );
this.ui.target.classList.remove( this.classes.targetExpanded );
} else {
this.ui.target.classList.add( this.classes.targetExpanded );
this.ui.target.classList.remove( this.classes.targetCollapsed );
}
}
|
javascript
|
function toggleTargetState( element ) {
if ( element.classList.contains( this.classes.targetExpanded ) ) {
this.ui.target.classList.add( this.classes.targetCollapsed );
this.ui.target.classList.remove( this.classes.targetExpanded );
} else {
this.ui.target.classList.add( this.classes.targetExpanded );
this.ui.target.classList.remove( this.classes.targetCollapsed );
}
}
|
[
"function",
"toggleTargetState",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"classList",
".",
"contains",
"(",
"this",
".",
"classes",
".",
"targetExpanded",
")",
")",
"{",
"this",
".",
"ui",
".",
"target",
".",
"classList",
".",
"add",
"(",
"this",
".",
"classes",
".",
"targetCollapsed",
")",
";",
"this",
".",
"ui",
".",
"target",
".",
"classList",
".",
"remove",
"(",
"this",
".",
"classes",
".",
"targetExpanded",
")",
";",
"}",
"else",
"{",
"this",
".",
"ui",
".",
"target",
".",
"classList",
".",
"add",
"(",
"this",
".",
"classes",
".",
"targetExpanded",
")",
";",
"this",
".",
"ui",
".",
"target",
".",
"classList",
".",
"remove",
"(",
"this",
".",
"classes",
".",
"targetCollapsed",
")",
";",
"}",
"}"
] |
Toggle an expandable to open or closed.
@param {HTMLNode} element - The expandable target HTML DOM element.
|
[
"Toggle",
"an",
"expandable",
"to",
"open",
"or",
"closed",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-expandables/src/Expandable.js#L102-L110
|
19,908
|
cfpb/capital-framework
|
packages/cf-expandables/src/ExpandableTransition.js
|
expand
|
function expand() {
this.dispatchEvent( 'expandBegin', { target: this } );
if ( !previousHeight || element.scrollHeight > previousHeight ) {
previousHeight = element.scrollHeight;
}
element.style.maxHeight = previousHeight + 'px';
_baseTransition.applyClass( CLASSES.EXPANDED );
return this;
}
|
javascript
|
function expand() {
this.dispatchEvent( 'expandBegin', { target: this } );
if ( !previousHeight || element.scrollHeight > previousHeight ) {
previousHeight = element.scrollHeight;
}
element.style.maxHeight = previousHeight + 'px';
_baseTransition.applyClass( CLASSES.EXPANDED );
return this;
}
|
[
"function",
"expand",
"(",
")",
"{",
"this",
".",
"dispatchEvent",
"(",
"'expandBegin'",
",",
"{",
"target",
":",
"this",
"}",
")",
";",
"if",
"(",
"!",
"previousHeight",
"||",
"element",
".",
"scrollHeight",
">",
"previousHeight",
")",
"{",
"previousHeight",
"=",
"element",
".",
"scrollHeight",
";",
"}",
"element",
".",
"style",
".",
"maxHeight",
"=",
"previousHeight",
"+",
"'px'",
";",
"_baseTransition",
".",
"applyClass",
"(",
"CLASSES",
".",
"EXPANDED",
")",
";",
"return",
"this",
";",
"}"
] |
Expands the expandable content
@returns {ExpandableTransition} An instance.
|
[
"Expands",
"the",
"expandable",
"content"
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-expandables/src/ExpandableTransition.js#L93-L104
|
19,909
|
cfpb/capital-framework
|
scripts/gulp/styles.js
|
stylesComponents
|
function stylesComponents() {
return gulp.src( 'packages/' + ( component || '*' ) + '/src/*.less' )
.pipe( gulpIgnore.exclude( vf => {
/* Exclude Less files that don't share the same name as the directory
they're in. This filters out things like cf-vars.less but still
includes cf-core.less. */
const matches = vf.path.match( /\/([\w-]*)\/src\/([\w-]*)\.less/ );
// We also exclude cf-grid. It needs its own special task. See below.
return matches[2] === 'cf-grid' || matches[1] !== matches[2];
} ) )
.pipe( gulpLess( {
paths: [ 'node_modules/cf-*/src/' ],
compress: true
} ) )
.pipe( gulpPostcss( [
autoprefixer( {
browsers: BROWSER_LIST.LAST_2_PLUS_IE_8_AND_UP
} )
] ) )
.pipe( gulpRename( path => {
path.dirname = component || path.dirname;
path.dirname = path.dirname.replace( '/src', '' );
path.extname = '.min.css';
} ) )
.pipe( gulp.dest( 'packages' ) );
}
|
javascript
|
function stylesComponents() {
return gulp.src( 'packages/' + ( component || '*' ) + '/src/*.less' )
.pipe( gulpIgnore.exclude( vf => {
/* Exclude Less files that don't share the same name as the directory
they're in. This filters out things like cf-vars.less but still
includes cf-core.less. */
const matches = vf.path.match( /\/([\w-]*)\/src\/([\w-]*)\.less/ );
// We also exclude cf-grid. It needs its own special task. See below.
return matches[2] === 'cf-grid' || matches[1] !== matches[2];
} ) )
.pipe( gulpLess( {
paths: [ 'node_modules/cf-*/src/' ],
compress: true
} ) )
.pipe( gulpPostcss( [
autoprefixer( {
browsers: BROWSER_LIST.LAST_2_PLUS_IE_8_AND_UP
} )
] ) )
.pipe( gulpRename( path => {
path.dirname = component || path.dirname;
path.dirname = path.dirname.replace( '/src', '' );
path.extname = '.min.css';
} ) )
.pipe( gulp.dest( 'packages' ) );
}
|
[
"function",
"stylesComponents",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"'packages/'",
"+",
"(",
"component",
"||",
"'*'",
")",
"+",
"'/src/*.less'",
")",
".",
"pipe",
"(",
"gulpIgnore",
".",
"exclude",
"(",
"vf",
"=>",
"{",
"/* Exclude Less files that don't share the same name as the directory\n they're in. This filters out things like cf-vars.less but still\n includes cf-core.less. */",
"const",
"matches",
"=",
"vf",
".",
"path",
".",
"match",
"(",
"/",
"\\/([\\w-]*)\\/src\\/([\\w-]*)\\.less",
"/",
")",
";",
"// We also exclude cf-grid. It needs its own special task. See below.",
"return",
"matches",
"[",
"2",
"]",
"===",
"'cf-grid'",
"||",
"matches",
"[",
"1",
"]",
"!==",
"matches",
"[",
"2",
"]",
";",
"}",
")",
")",
".",
"pipe",
"(",
"gulpLess",
"(",
"{",
"paths",
":",
"[",
"'node_modules/cf-*/src/'",
"]",
",",
"compress",
":",
"true",
"}",
")",
")",
".",
"pipe",
"(",
"gulpPostcss",
"(",
"[",
"autoprefixer",
"(",
"{",
"browsers",
":",
"BROWSER_LIST",
".",
"LAST_2_PLUS_IE_8_AND_UP",
"}",
")",
"]",
")",
")",
".",
"pipe",
"(",
"gulpRename",
"(",
"path",
"=>",
"{",
"path",
".",
"dirname",
"=",
"component",
"||",
"path",
".",
"dirname",
";",
"path",
".",
"dirname",
"=",
"path",
".",
"dirname",
".",
"replace",
"(",
"'/src'",
",",
"''",
")",
";",
"path",
".",
"extname",
"=",
"'.min.css'",
";",
"}",
")",
")",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"'packages'",
")",
")",
";",
"}"
] |
Compile all the individual component files so that users can `npm install`
a single component if they desire.
@returns {PassThrough} A source stream.
|
[
"Compile",
"all",
"the",
"individual",
"component",
"files",
"so",
"that",
"users",
"can",
"npm",
"install",
"a",
"single",
"component",
"if",
"they",
"desire",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/scripts/gulp/styles.js#L15-L40
|
19,910
|
cfpb/capital-framework
|
scripts/gulp/styles.js
|
stylesGrid
|
function stylesGrid() {
return gulp.src( 'packages/cf-grid/src-generated/*.less' )
.pipe( gulpLess( {
paths: [ 'node_modules/cf-*/src/' ],
compress: true
} ) )
.pipe( gulpPostcss( [
autoprefixer( {
grid: true,
browsers: BROWSER_LIST.LAST_2_PLUS_IE_8_AND_UP
} )
] ) )
.pipe( gulpRename( {
basename: 'cf-grid',
extname: '.min.css'
} ) )
.pipe( gulp.dest( 'packages/cf-grid' ) );
}
|
javascript
|
function stylesGrid() {
return gulp.src( 'packages/cf-grid/src-generated/*.less' )
.pipe( gulpLess( {
paths: [ 'node_modules/cf-*/src/' ],
compress: true
} ) )
.pipe( gulpPostcss( [
autoprefixer( {
grid: true,
browsers: BROWSER_LIST.LAST_2_PLUS_IE_8_AND_UP
} )
] ) )
.pipe( gulpRename( {
basename: 'cf-grid',
extname: '.min.css'
} ) )
.pipe( gulp.dest( 'packages/cf-grid' ) );
}
|
[
"function",
"stylesGrid",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"'packages/cf-grid/src-generated/*.less'",
")",
".",
"pipe",
"(",
"gulpLess",
"(",
"{",
"paths",
":",
"[",
"'node_modules/cf-*/src/'",
"]",
",",
"compress",
":",
"true",
"}",
")",
")",
".",
"pipe",
"(",
"gulpPostcss",
"(",
"[",
"autoprefixer",
"(",
"{",
"grid",
":",
"true",
",",
"browsers",
":",
"BROWSER_LIST",
".",
"LAST_2_PLUS_IE_8_AND_UP",
"}",
")",
"]",
")",
")",
".",
"pipe",
"(",
"gulpRename",
"(",
"{",
"basename",
":",
"'cf-grid'",
",",
"extname",
":",
"'.min.css'",
"}",
")",
")",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"'packages/cf-grid'",
")",
")",
";",
"}"
] |
cf-grid needs to compile cf-grid-generated.less.
@returns {PassThrough} A source stream.
|
[
"cf",
"-",
"grid",
"needs",
"to",
"compile",
"cf",
"-",
"grid",
"-",
"generated",
".",
"less",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/scripts/gulp/styles.js#L46-L63
|
19,911
|
cfpb/capital-framework
|
scripts/gulp/styles.js
|
stylesDocs
|
function stylesDocs() {
return gulp.src( 'docs/src/css/main.less' )
.pipe( gulpLess( {
paths: [ 'node_modules/cf-*/src/' ],
compress: true
} ) )
.pipe( gulpPostcss( [
autoprefixer( {
browsers: BROWSER_LIST.LAST_2_PLUS_IE_8_AND_UP
} )
] ) )
.pipe( gulp.dest( 'docs/dist/css/' ) );
}
|
javascript
|
function stylesDocs() {
return gulp.src( 'docs/src/css/main.less' )
.pipe( gulpLess( {
paths: [ 'node_modules/cf-*/src/' ],
compress: true
} ) )
.pipe( gulpPostcss( [
autoprefixer( {
browsers: BROWSER_LIST.LAST_2_PLUS_IE_8_AND_UP
} )
] ) )
.pipe( gulp.dest( 'docs/dist/css/' ) );
}
|
[
"function",
"stylesDocs",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"'docs/src/css/main.less'",
")",
".",
"pipe",
"(",
"gulpLess",
"(",
"{",
"paths",
":",
"[",
"'node_modules/cf-*/src/'",
"]",
",",
"compress",
":",
"true",
"}",
")",
")",
".",
"pipe",
"(",
"gulpPostcss",
"(",
"[",
"autoprefixer",
"(",
"{",
"browsers",
":",
"BROWSER_LIST",
".",
"LAST_2_PLUS_IE_8_AND_UP",
"}",
")",
"]",
")",
")",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"'docs/dist/css/'",
")",
")",
";",
"}"
] |
Process CSS for the docs.
@returns {PassThrough} A source stream.
|
[
"Process",
"CSS",
"for",
"the",
"docs",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/scripts/gulp/styles.js#L69-L81
|
19,912
|
cfpb/capital-framework
|
scripts/gulp/lint.js
|
lintStyles
|
function lintStyles() {
// Pass all command line flags to Stylelint.
const options = minimist( process.argv.slice( 2 ) );
const willFix = options.fix || false;
return gulp.src( [
'packages/**/*.less',
'!packages/cf-*/node_modules/**/*.less',
'!packages/cf-grid/src-generated/*.less'
] )
.pipe( gulpStylelint( {
failAfterError: true,
fix: willFix,
reporters: [ { formatter: 'string', console: true } ]
} ) )
.pipe( gulp.dest( 'packages' ) );
}
|
javascript
|
function lintStyles() {
// Pass all command line flags to Stylelint.
const options = minimist( process.argv.slice( 2 ) );
const willFix = options.fix || false;
return gulp.src( [
'packages/**/*.less',
'!packages/cf-*/node_modules/**/*.less',
'!packages/cf-grid/src-generated/*.less'
] )
.pipe( gulpStylelint( {
failAfterError: true,
fix: willFix,
reporters: [ { formatter: 'string', console: true } ]
} ) )
.pipe( gulp.dest( 'packages' ) );
}
|
[
"function",
"lintStyles",
"(",
")",
"{",
"// Pass all command line flags to Stylelint.",
"const",
"options",
"=",
"minimist",
"(",
"process",
".",
"argv",
".",
"slice",
"(",
"2",
")",
")",
";",
"const",
"willFix",
"=",
"options",
".",
"fix",
"||",
"false",
";",
"return",
"gulp",
".",
"src",
"(",
"[",
"'packages/**/*.less'",
",",
"'!packages/cf-*/node_modules/**/*.less'",
",",
"'!packages/cf-grid/src-generated/*.less'",
"]",
")",
".",
"pipe",
"(",
"gulpStylelint",
"(",
"{",
"failAfterError",
":",
"true",
",",
"fix",
":",
"willFix",
",",
"reporters",
":",
"[",
"{",
"formatter",
":",
"'string'",
",",
"console",
":",
"true",
"}",
"]",
"}",
")",
")",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"'packages'",
")",
")",
";",
"}"
] |
Lints the source LESS files for errors.
@returns {Object} An output stream from gulp.
|
[
"Lints",
"the",
"source",
"LESS",
"files",
"for",
"errors",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/scripts/gulp/lint.js#L67-L82
|
19,913
|
cfpb/capital-framework
|
packages/cf-tables/src/TableSortable.js
|
initialize
|
function initialize() {
this.sortClass = UNDEFINED;
this.sortColumnIndex = UNDEFINED;
this.sortDirection = UNDEFINED;
this.tableData = [];
this.bindProperties();
if ( this.ui.sortButton ) {
this.sortColumnIndex = this.getColumnIndex();
this.sortDirection = DIRECTIONS.UP;
if ( this.ui.sortButton.classList.contains( this.classes.sortDown ) ) {
this.sortDirection = DIRECTIONS.DOWN;
}
this.updateTable();
}
}
|
javascript
|
function initialize() {
this.sortClass = UNDEFINED;
this.sortColumnIndex = UNDEFINED;
this.sortDirection = UNDEFINED;
this.tableData = [];
this.bindProperties();
if ( this.ui.sortButton ) {
this.sortColumnIndex = this.getColumnIndex();
this.sortDirection = DIRECTIONS.UP;
if ( this.ui.sortButton.classList.contains( this.classes.sortDown ) ) {
this.sortDirection = DIRECTIONS.DOWN;
}
this.updateTable();
}
}
|
[
"function",
"initialize",
"(",
")",
"{",
"this",
".",
"sortClass",
"=",
"UNDEFINED",
";",
"this",
".",
"sortColumnIndex",
"=",
"UNDEFINED",
";",
"this",
".",
"sortDirection",
"=",
"UNDEFINED",
";",
"this",
".",
"tableData",
"=",
"[",
"]",
";",
"this",
".",
"bindProperties",
"(",
")",
";",
"if",
"(",
"this",
".",
"ui",
".",
"sortButton",
")",
"{",
"this",
".",
"sortColumnIndex",
"=",
"this",
".",
"getColumnIndex",
"(",
")",
";",
"this",
".",
"sortDirection",
"=",
"DIRECTIONS",
".",
"UP",
";",
"if",
"(",
"this",
".",
"ui",
".",
"sortButton",
".",
"classList",
".",
"contains",
"(",
"this",
".",
"classes",
".",
"sortDown",
")",
")",
"{",
"this",
".",
"sortDirection",
"=",
"DIRECTIONS",
".",
"DOWN",
";",
"}",
"this",
".",
"updateTable",
"(",
")",
";",
"}",
"}"
] |
Function used to create computed and triggered properties.
|
[
"Function",
"used",
"to",
"create",
"computed",
"and",
"triggered",
"properties",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-tables/src/TableSortable.js#L44-L60
|
19,914
|
cfpb/capital-framework
|
packages/cf-tables/src/TableSortable.js
|
bindProperties
|
function bindProperties() {
let sortDirection;
Object.defineProperty( this, 'sortDirection', {
configurable: true,
get: function() {
return sortDirection;
},
set: function( value ) {
if ( value === DIRECTIONS.UP ) {
this.sortClass = this.classes.sortUp;
} else if ( value === DIRECTIONS.DOWN ) {
this.sortClass = this.classes.sortDown;
}
sortDirection = value;
}
} );
}
|
javascript
|
function bindProperties() {
let sortDirection;
Object.defineProperty( this, 'sortDirection', {
configurable: true,
get: function() {
return sortDirection;
},
set: function( value ) {
if ( value === DIRECTIONS.UP ) {
this.sortClass = this.classes.sortUp;
} else if ( value === DIRECTIONS.DOWN ) {
this.sortClass = this.classes.sortDown;
}
sortDirection = value;
}
} );
}
|
[
"function",
"bindProperties",
"(",
")",
"{",
"let",
"sortDirection",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'sortDirection'",
",",
"{",
"configurable",
":",
"true",
",",
"get",
":",
"function",
"(",
")",
"{",
"return",
"sortDirection",
";",
"}",
",",
"set",
":",
"function",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"DIRECTIONS",
".",
"UP",
")",
"{",
"this",
".",
"sortClass",
"=",
"this",
".",
"classes",
".",
"sortUp",
";",
"}",
"else",
"if",
"(",
"value",
"===",
"DIRECTIONS",
".",
"DOWN",
")",
"{",
"this",
".",
"sortClass",
"=",
"this",
".",
"classes",
".",
"sortDown",
";",
"}",
"sortDirection",
"=",
"value",
";",
"}",
"}",
")",
";",
"}"
] |
Function used to create computed and trigger properties.
|
[
"Function",
"used",
"to",
"create",
"computed",
"and",
"trigger",
"properties",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-tables/src/TableSortable.js#L65-L82
|
19,915
|
cfpb/capital-framework
|
packages/cf-tables/src/TableSortable.js
|
updateTableData
|
function updateTableData( columnIndex ) {
let cell;
const rows = this.ui.tableBody.querySelectorAll( 'tr' );
this.tableData = [];
columnIndex = columnIndex || this.sortColumnIndex;
for ( let i = 0, len = rows.length; i < len; ++i ) {
cell = rows[i].cells[columnIndex];
if ( cell ) {
cell = cell.textContent.trim();
}
this.tableData.push( [ cell, rows[i] ] );
}
const sortType = this.ui.sortButton.getAttribute( 'data-sort_type' );
this.tableData.sort( this.tableDataSorter( this.sortDirection, sortType ) );
return this.tableData;
}
|
javascript
|
function updateTableData( columnIndex ) {
let cell;
const rows = this.ui.tableBody.querySelectorAll( 'tr' );
this.tableData = [];
columnIndex = columnIndex || this.sortColumnIndex;
for ( let i = 0, len = rows.length; i < len; ++i ) {
cell = rows[i].cells[columnIndex];
if ( cell ) {
cell = cell.textContent.trim();
}
this.tableData.push( [ cell, rows[i] ] );
}
const sortType = this.ui.sortButton.getAttribute( 'data-sort_type' );
this.tableData.sort( this.tableDataSorter( this.sortDirection, sortType ) );
return this.tableData;
}
|
[
"function",
"updateTableData",
"(",
"columnIndex",
")",
"{",
"let",
"cell",
";",
"const",
"rows",
"=",
"this",
".",
"ui",
".",
"tableBody",
".",
"querySelectorAll",
"(",
"'tr'",
")",
";",
"this",
".",
"tableData",
"=",
"[",
"]",
";",
"columnIndex",
"=",
"columnIndex",
"||",
"this",
".",
"sortColumnIndex",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"len",
"=",
"rows",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"cell",
"=",
"rows",
"[",
"i",
"]",
".",
"cells",
"[",
"columnIndex",
"]",
";",
"if",
"(",
"cell",
")",
"{",
"cell",
"=",
"cell",
".",
"textContent",
".",
"trim",
"(",
")",
";",
"}",
"this",
".",
"tableData",
".",
"push",
"(",
"[",
"cell",
",",
"rows",
"[",
"i",
"]",
"]",
")",
";",
"}",
"const",
"sortType",
"=",
"this",
".",
"ui",
".",
"sortButton",
".",
"getAttribute",
"(",
"'data-sort_type'",
")",
";",
"this",
".",
"tableData",
".",
"sort",
"(",
"this",
".",
"tableDataSorter",
"(",
"this",
".",
"sortDirection",
",",
"sortType",
")",
")",
";",
"return",
"this",
".",
"tableData",
";",
"}"
] |
Function used to get, sort, and update the table data array.
@param {number} columnIndex - The index of the column used for sorting.
@returns {Array} Multidimensional array of column's cell value
and corresponding row element.
|
[
"Function",
"used",
"to",
"get",
"sort",
"and",
"update",
"the",
"table",
"data",
"array",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-tables/src/TableSortable.js#L109-L127
|
19,916
|
cfpb/capital-framework
|
packages/cf-tables/src/TableSortable.js
|
updateTableDom
|
function updateTableDom() {
const tableBody = this.ui.tableBody;
/* Empty the table body to prepare for sorting the rows
TODO: It might make sense to use innerHTML
from a performance and garbage collection standpoint. */
while ( tableBody.lastChild ) {
tableBody.removeChild( tableBody.lastChild );
}
const documentFragment = document.createDocumentFragment();
for ( let i = 0; i < this.tableData.length; i++ ) {
documentFragment.appendChild( this.tableData[i][1] );
}
tableBody.appendChild( documentFragment );
this.trigger( 'table:updated' );
return tableBody;
}
|
javascript
|
function updateTableDom() {
const tableBody = this.ui.tableBody;
/* Empty the table body to prepare for sorting the rows
TODO: It might make sense to use innerHTML
from a performance and garbage collection standpoint. */
while ( tableBody.lastChild ) {
tableBody.removeChild( tableBody.lastChild );
}
const documentFragment = document.createDocumentFragment();
for ( let i = 0; i < this.tableData.length; i++ ) {
documentFragment.appendChild( this.tableData[i][1] );
}
tableBody.appendChild( documentFragment );
this.trigger( 'table:updated' );
return tableBody;
}
|
[
"function",
"updateTableDom",
"(",
")",
"{",
"const",
"tableBody",
"=",
"this",
".",
"ui",
".",
"tableBody",
";",
"/* Empty the table body to prepare for sorting the rows\n TODO: It might make sense to use innerHTML\n from a performance and garbage collection standpoint. */",
"while",
"(",
"tableBody",
".",
"lastChild",
")",
"{",
"tableBody",
".",
"removeChild",
"(",
"tableBody",
".",
"lastChild",
")",
";",
"}",
"const",
"documentFragment",
"=",
"document",
".",
"createDocumentFragment",
"(",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"tableData",
".",
"length",
";",
"i",
"++",
")",
"{",
"documentFragment",
".",
"appendChild",
"(",
"this",
".",
"tableData",
"[",
"i",
"]",
"[",
"1",
"]",
")",
";",
"}",
"tableBody",
".",
"appendChild",
"(",
"documentFragment",
")",
";",
"this",
".",
"trigger",
"(",
"'table:updated'",
")",
";",
"return",
"tableBody",
";",
"}"
] |
Function used to update the table DOM.
@returns {HTMLNode} The table's <tbody> element.
|
[
"Function",
"used",
"to",
"update",
"the",
"table",
"DOM",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-tables/src/TableSortable.js#L133-L152
|
19,917
|
cfpb/capital-framework
|
packages/cf-tables/src/TableRowLinks.js
|
onRowLinkClick
|
function onRowLinkClick( event ) {
let target = event.target;
if ( target && target.tagName === 'A' ) {
return;
}
target = closest( event.target, 'tr' );
const link = target.querySelector( 'a' );
if ( link ) {
window.location = link.getAttribute( 'href' );
}
}
|
javascript
|
function onRowLinkClick( event ) {
let target = event.target;
if ( target && target.tagName === 'A' ) {
return;
}
target = closest( event.target, 'tr' );
const link = target.querySelector( 'a' );
if ( link ) {
window.location = link.getAttribute( 'href' );
}
}
|
[
"function",
"onRowLinkClick",
"(",
"event",
")",
"{",
"let",
"target",
"=",
"event",
".",
"target",
";",
"if",
"(",
"target",
"&&",
"target",
".",
"tagName",
"===",
"'A'",
")",
"{",
"return",
";",
"}",
"target",
"=",
"closest",
"(",
"event",
".",
"target",
",",
"'tr'",
")",
";",
"const",
"link",
"=",
"target",
".",
"querySelector",
"(",
"'a'",
")",
";",
"if",
"(",
"link",
")",
"{",
"window",
".",
"location",
"=",
"link",
".",
"getAttribute",
"(",
"'href'",
")",
";",
"}",
"}"
] |
Handle a click of the table.
@param {MouseEvent} event - Mouse event for click on the table.
|
[
"Handle",
"a",
"click",
"of",
"the",
"table",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-tables/src/TableRowLinks.js#L29-L39
|
19,918
|
cfpb/capital-framework
|
packages/cf-atomic-component/src/components/AtomicComponent.js
|
AtomicComponent
|
function AtomicComponent( element, attributes ) {
this.element = element;
this.initializers = [];
this.uId = this.uniqueId( 'ac' );
assign( this, attributes );
this.processModifiers();
this.ensureElement();
this.setCachedElements();
this.initializers.push( this.initialize );
this.initializers.forEach( function( func ) {
if ( isFunction( func ) ) func.apply( this, arguments );
}, this );
this.trigger( 'component:initialized' );
}
|
javascript
|
function AtomicComponent( element, attributes ) {
this.element = element;
this.initializers = [];
this.uId = this.uniqueId( 'ac' );
assign( this, attributes );
this.processModifiers();
this.ensureElement();
this.setCachedElements();
this.initializers.push( this.initialize );
this.initializers.forEach( function( func ) {
if ( isFunction( func ) ) func.apply( this, arguments );
}, this );
this.trigger( 'component:initialized' );
}
|
[
"function",
"AtomicComponent",
"(",
"element",
",",
"attributes",
")",
"{",
"this",
".",
"element",
"=",
"element",
";",
"this",
".",
"initializers",
"=",
"[",
"]",
";",
"this",
".",
"uId",
"=",
"this",
".",
"uniqueId",
"(",
"'ac'",
")",
";",
"assign",
"(",
"this",
",",
"attributes",
")",
";",
"this",
".",
"processModifiers",
"(",
")",
";",
"this",
".",
"ensureElement",
"(",
")",
";",
"this",
".",
"setCachedElements",
"(",
")",
";",
"this",
".",
"initializers",
".",
"push",
"(",
"this",
".",
"initialize",
")",
";",
"this",
".",
"initializers",
".",
"forEach",
"(",
"function",
"(",
"func",
")",
"{",
"if",
"(",
"isFunction",
"(",
"func",
")",
")",
"func",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
",",
"this",
")",
";",
"this",
".",
"trigger",
"(",
"'component:initialized'",
")",
";",
"}"
] |
Function as the constrcutor for the AtomicComponent.
Sets up initial instance properties and calls
necessary methods to properly instantiatie component.
@param {HTMLElement} element - The element to set as the base element.
@param {Object} attributes - Hash of attributes to set on base element.
|
[
"Function",
"as",
"the",
"constrcutor",
"for",
"the",
"AtomicComponent",
".",
"Sets",
"up",
"initial",
"instance",
"properties",
"and",
"calls",
"necessary",
"methods",
"to",
"properly",
"instantiatie",
"component",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-atomic-component/src/components/AtomicComponent.js#L27-L40
|
19,919
|
cfpb/capital-framework
|
packages/cf-atomic-component/src/components/AtomicComponent.js
|
function( attributes ) {
let property;
for ( property in attributes ) {
if ( attributes.hasOwnProperty( property ) ) {
this.element.setAttribute( property, attributes[property] );
}
}
}
|
javascript
|
function( attributes ) {
let property;
for ( property in attributes ) {
if ( attributes.hasOwnProperty( property ) ) {
this.element.setAttribute( property, attributes[property] );
}
}
}
|
[
"function",
"(",
"attributes",
")",
"{",
"let",
"property",
";",
"for",
"(",
"property",
"in",
"attributes",
")",
"{",
"if",
"(",
"attributes",
".",
"hasOwnProperty",
"(",
"property",
")",
")",
"{",
"this",
".",
"element",
".",
"setAttribute",
"(",
"property",
",",
"attributes",
"[",
"property",
"]",
")",
";",
"}",
"}",
"}"
] |
Function used to set the attributes on an element.
@param {Object} attributes - Hash of attributes to set on base element.
|
[
"Function",
"used",
"to",
"set",
"the",
"attributes",
"on",
"an",
"element",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-atomic-component/src/components/AtomicComponent.js#L165-L173
|
|
19,920
|
cfpb/capital-framework
|
scripts/utils/fs-helper.js
|
getBinary
|
function getBinary( packageName, binaryName, binaryDir ) {
binaryName = binaryName || packageName;
binaryDir = binaryDir || 'bin';
const pkgPath = require.resolve( packageName );
binaryDir = path.resolve(
path.join( path.dirname( pkgPath ), binaryDir, '/' + binaryName )
);
return binaryDir;
}
|
javascript
|
function getBinary( packageName, binaryName, binaryDir ) {
binaryName = binaryName || packageName;
binaryDir = binaryDir || 'bin';
const pkgPath = require.resolve( packageName );
binaryDir = path.resolve(
path.join( path.dirname( pkgPath ), binaryDir, '/' + binaryName )
);
return binaryDir;
}
|
[
"function",
"getBinary",
"(",
"packageName",
",",
"binaryName",
",",
"binaryDir",
")",
"{",
"binaryName",
"=",
"binaryName",
"||",
"packageName",
";",
"binaryDir",
"=",
"binaryDir",
"||",
"'bin'",
";",
"const",
"pkgPath",
"=",
"require",
".",
"resolve",
"(",
"packageName",
")",
";",
"binaryDir",
"=",
"path",
".",
"resolve",
"(",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"(",
"pkgPath",
")",
",",
"binaryDir",
",",
"'/'",
"+",
"binaryName",
")",
")",
";",
"return",
"binaryDir",
";",
"}"
] |
Retrieve a reference path to a binary.
@param {string} packageName - The name of the software package.
@param {string} [binaryName] - The name of the binary to retrieve.
Same as the package name by default.
@param {string} [binaryDir] - The name of the binary directory to use.
`bin` by default.
@returns {string} Path to the binary to run.
|
[
"Retrieve",
"a",
"reference",
"path",
"to",
"a",
"binary",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/scripts/utils/fs-helper.js#L12-L20
|
19,921
|
cfpb/capital-framework
|
packages/cf-atomic-component/src/utilities/transition/MoveTransition.js
|
moveLeft
|
function moveLeft( count ) {
count = count || 1;
const moveClasses = [
CLASSES.MOVE_LEFT,
CLASSES.MOVE_LEFT_2X,
CLASSES.MOVE_LEFT_3X
];
if ( count < 1 || count > moveClasses.length ) {
throw new Error( 'MoveTransition: moveLeft count is out of range!' );
}
_baseTransition.applyClass( moveClasses[count - 1] );
return this;
}
|
javascript
|
function moveLeft( count ) {
count = count || 1;
const moveClasses = [
CLASSES.MOVE_LEFT,
CLASSES.MOVE_LEFT_2X,
CLASSES.MOVE_LEFT_3X
];
if ( count < 1 || count > moveClasses.length ) {
throw new Error( 'MoveTransition: moveLeft count is out of range!' );
}
_baseTransition.applyClass( moveClasses[count - 1] );
return this;
}
|
[
"function",
"moveLeft",
"(",
"count",
")",
"{",
"count",
"=",
"count",
"||",
"1",
";",
"const",
"moveClasses",
"=",
"[",
"CLASSES",
".",
"MOVE_LEFT",
",",
"CLASSES",
".",
"MOVE_LEFT_2X",
",",
"CLASSES",
".",
"MOVE_LEFT_3X",
"]",
";",
"if",
"(",
"count",
"<",
"1",
"||",
"count",
">",
"moveClasses",
".",
"length",
")",
"{",
"throw",
"new",
"Error",
"(",
"'MoveTransition: moveLeft count is out of range!'",
")",
";",
"}",
"_baseTransition",
".",
"applyClass",
"(",
"moveClasses",
"[",
"count",
"-",
"1",
"]",
")",
";",
"return",
"this",
";",
"}"
] |
Move to the left by applying a utility move class.
@param {Number} count
How many times to move left as a multiplication of the element's width.
@returns {MoveTransition} An instance.
|
[
"Move",
"to",
"the",
"left",
"by",
"applying",
"a",
"utility",
"move",
"class",
"."
] |
fe4bee9892c38ac925b02020e49322110eafdcd6
|
https://github.com/cfpb/capital-framework/blob/fe4bee9892c38ac925b02020e49322110eafdcd6/packages/cf-atomic-component/src/utilities/transition/MoveTransition.js#L67-L82
|
19,922
|
bootprint/bootprint
|
index.js
|
Bootprint
|
function Bootprint (withData, targetDir) {
/**
* Run Bootprint and write the result to the specified target directory
* @param options {object} options passed to Customize#run()
* @returns {Promise} a promise for the completion of the build
*/
this.generate = function generate (options) {
return withData.run(options).then(write(targetDir))
}
/**
* Run the file watcher to watch all files loaded into the
* current Bootprint-configuration.
* The watcher run Bootprint every time one the the input files, templates or helpers changes.
* @returns {EventEmitter} an EventEmitter that sends an `update`-event after each
* build, but before the files are written to disc.
*/
this.watch = function () {
return withData.watch().on('update', write(targetDir))
}
}
|
javascript
|
function Bootprint (withData, targetDir) {
/**
* Run Bootprint and write the result to the specified target directory
* @param options {object} options passed to Customize#run()
* @returns {Promise} a promise for the completion of the build
*/
this.generate = function generate (options) {
return withData.run(options).then(write(targetDir))
}
/**
* Run the file watcher to watch all files loaded into the
* current Bootprint-configuration.
* The watcher run Bootprint every time one the the input files, templates or helpers changes.
* @returns {EventEmitter} an EventEmitter that sends an `update`-event after each
* build, but before the files are written to disc.
*/
this.watch = function () {
return withData.watch().on('update', write(targetDir))
}
}
|
[
"function",
"Bootprint",
"(",
"withData",
",",
"targetDir",
")",
"{",
"/**\n * Run Bootprint and write the result to the specified target directory\n * @param options {object} options passed to Customize#run()\n * @returns {Promise} a promise for the completion of the build\n */",
"this",
".",
"generate",
"=",
"function",
"generate",
"(",
"options",
")",
"{",
"return",
"withData",
".",
"run",
"(",
"options",
")",
".",
"then",
"(",
"write",
"(",
"targetDir",
")",
")",
"}",
"/**\n * Run the file watcher to watch all files loaded into the\n * current Bootprint-configuration.\n * The watcher run Bootprint every time one the the input files, templates or helpers changes.\n * @returns {EventEmitter} an EventEmitter that sends an `update`-event after each\n * build, but before the files are written to disc.\n */",
"this",
".",
"watch",
"=",
"function",
"(",
")",
"{",
"return",
"withData",
".",
"watch",
"(",
")",
".",
"on",
"(",
"'update'",
",",
"write",
"(",
"targetDir",
")",
")",
"}",
"}"
] |
The old Bootprint interface
@constructor
|
[
"The",
"old",
"Bootprint",
"interface"
] |
8fed46d0add665a9d70c4edb497b9d366762e864
|
https://github.com/bootprint/bootprint/blob/8fed46d0add665a9d70c4edb497b9d366762e864/index.js#L35-L55
|
19,923
|
bootprint/bootprint
|
index.js
|
loadFromFileOrHttp
|
function loadFromFileOrHttp (fileOrUrlOrData) {
// If this is not a string,
// it is probably already the raw data.
if (typeof fileOrUrlOrData !== 'string') {
return Q(fileOrUrlOrData)
}
// otherwise load data from url or file
if (fileOrUrlOrData.match(/^https?:\/\//)) {
// Use the "request" package to download data
return httpGet(fileOrUrlOrData, {
redirect: true,
headers: {
'User-Agent': 'Bootprint/' + require('./package').version
}
}).then(function (result) {
if (result.status !== 200) {
var error = new Error('HTTP request failed with code ' + result.status)
error.result = result
throw error
}
return yaml.safeLoad(result.data, {json: true})
}, function (error) {
if (error.status) {
throw new Error('Got ' + error.status + ' ' + error.data + ' when requesting ' + error.url, 'E_HTTP')
} else {
throw error
}
})
} else {
return Q.nfcall(fs.readFile, fileOrUrlOrData, 'utf8').then(function (data) {
return yaml.safeLoad(data, {json: true})
})
}
}
|
javascript
|
function loadFromFileOrHttp (fileOrUrlOrData) {
// If this is not a string,
// it is probably already the raw data.
if (typeof fileOrUrlOrData !== 'string') {
return Q(fileOrUrlOrData)
}
// otherwise load data from url or file
if (fileOrUrlOrData.match(/^https?:\/\//)) {
// Use the "request" package to download data
return httpGet(fileOrUrlOrData, {
redirect: true,
headers: {
'User-Agent': 'Bootprint/' + require('./package').version
}
}).then(function (result) {
if (result.status !== 200) {
var error = new Error('HTTP request failed with code ' + result.status)
error.result = result
throw error
}
return yaml.safeLoad(result.data, {json: true})
}, function (error) {
if (error.status) {
throw new Error('Got ' + error.status + ' ' + error.data + ' when requesting ' + error.url, 'E_HTTP')
} else {
throw error
}
})
} else {
return Q.nfcall(fs.readFile, fileOrUrlOrData, 'utf8').then(function (data) {
return yaml.safeLoad(data, {json: true})
})
}
}
|
[
"function",
"loadFromFileOrHttp",
"(",
"fileOrUrlOrData",
")",
"{",
"// If this is not a string,",
"// it is probably already the raw data.",
"if",
"(",
"typeof",
"fileOrUrlOrData",
"!==",
"'string'",
")",
"{",
"return",
"Q",
"(",
"fileOrUrlOrData",
")",
"}",
"// otherwise load data from url or file",
"if",
"(",
"fileOrUrlOrData",
".",
"match",
"(",
"/",
"^https?:\\/\\/",
"/",
")",
")",
"{",
"// Use the \"request\" package to download data",
"return",
"httpGet",
"(",
"fileOrUrlOrData",
",",
"{",
"redirect",
":",
"true",
",",
"headers",
":",
"{",
"'User-Agent'",
":",
"'Bootprint/'",
"+",
"require",
"(",
"'./package'",
")",
".",
"version",
"}",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"result",
".",
"status",
"!==",
"200",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"'HTTP request failed with code '",
"+",
"result",
".",
"status",
")",
"error",
".",
"result",
"=",
"result",
"throw",
"error",
"}",
"return",
"yaml",
".",
"safeLoad",
"(",
"result",
".",
"data",
",",
"{",
"json",
":",
"true",
"}",
")",
"}",
",",
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
".",
"status",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Got '",
"+",
"error",
".",
"status",
"+",
"' '",
"+",
"error",
".",
"data",
"+",
"' when requesting '",
"+",
"error",
".",
"url",
",",
"'E_HTTP'",
")",
"}",
"else",
"{",
"throw",
"error",
"}",
"}",
")",
"}",
"else",
"{",
"return",
"Q",
".",
"nfcall",
"(",
"fs",
".",
"readFile",
",",
"fileOrUrlOrData",
",",
"'utf8'",
")",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"return",
"yaml",
".",
"safeLoad",
"(",
"data",
",",
"{",
"json",
":",
"true",
"}",
")",
"}",
")",
"}",
"}"
] |
Helper method for loading the bootprint-data
@param fileOrUrlOrData
@returns {*}
@private
|
[
"Helper",
"method",
"for",
"loading",
"the",
"bootprint",
"-",
"data"
] |
8fed46d0add665a9d70c4edb497b9d366762e864
|
https://github.com/bootprint/bootprint/blob/8fed46d0add665a9d70c4edb497b9d366762e864/index.js#L63-L96
|
19,924
|
micromatch/nanomatch
|
index.js
|
nanomatch
|
function nanomatch(list, patterns, options) {
patterns = utils.arrayify(patterns);
list = utils.arrayify(list);
const len = patterns.length;
if (list.length === 0 || len === 0) {
return [];
}
if (len === 1) {
return nanomatch.match(list, patterns[0], options);
}
let negated = false;
const omit = [];
const keep = [];
let idx = -1;
while (++idx < len) {
const pattern = patterns[idx];
if (typeof pattern === 'string' && pattern.charCodeAt(0) === 33 /* ! */) {
omit.push.apply(omit, nanomatch.match(list, pattern.slice(1), options));
negated = true;
} else {
keep.push.apply(keep, nanomatch.match(list, pattern, options));
}
}
// minimatch.match parity
if (negated && keep.length === 0) {
if (options && options.unixify === false) {
keep = list.slice();
} else {
const unixify = utils.unixify(options);
for (var i = 0; i < list.length; i++) {
keep.push(unixify(list[i]));
}
}
}
const matches = utils.diff(keep, omit);
if (!options || options.nodupes !== false) {
return utils.unique(matches);
}
return matches;
}
|
javascript
|
function nanomatch(list, patterns, options) {
patterns = utils.arrayify(patterns);
list = utils.arrayify(list);
const len = patterns.length;
if (list.length === 0 || len === 0) {
return [];
}
if (len === 1) {
return nanomatch.match(list, patterns[0], options);
}
let negated = false;
const omit = [];
const keep = [];
let idx = -1;
while (++idx < len) {
const pattern = patterns[idx];
if (typeof pattern === 'string' && pattern.charCodeAt(0) === 33 /* ! */) {
omit.push.apply(omit, nanomatch.match(list, pattern.slice(1), options));
negated = true;
} else {
keep.push.apply(keep, nanomatch.match(list, pattern, options));
}
}
// minimatch.match parity
if (negated && keep.length === 0) {
if (options && options.unixify === false) {
keep = list.slice();
} else {
const unixify = utils.unixify(options);
for (var i = 0; i < list.length; i++) {
keep.push(unixify(list[i]));
}
}
}
const matches = utils.diff(keep, omit);
if (!options || options.nodupes !== false) {
return utils.unique(matches);
}
return matches;
}
|
[
"function",
"nanomatch",
"(",
"list",
",",
"patterns",
",",
"options",
")",
"{",
"patterns",
"=",
"utils",
".",
"arrayify",
"(",
"patterns",
")",
";",
"list",
"=",
"utils",
".",
"arrayify",
"(",
"list",
")",
";",
"const",
"len",
"=",
"patterns",
".",
"length",
";",
"if",
"(",
"list",
".",
"length",
"===",
"0",
"||",
"len",
"===",
"0",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"len",
"===",
"1",
")",
"{",
"return",
"nanomatch",
".",
"match",
"(",
"list",
",",
"patterns",
"[",
"0",
"]",
",",
"options",
")",
";",
"}",
"let",
"negated",
"=",
"false",
";",
"const",
"omit",
"=",
"[",
"]",
";",
"const",
"keep",
"=",
"[",
"]",
";",
"let",
"idx",
"=",
"-",
"1",
";",
"while",
"(",
"++",
"idx",
"<",
"len",
")",
"{",
"const",
"pattern",
"=",
"patterns",
"[",
"idx",
"]",
";",
"if",
"(",
"typeof",
"pattern",
"===",
"'string'",
"&&",
"pattern",
".",
"charCodeAt",
"(",
"0",
")",
"===",
"33",
"/* ! */",
")",
"{",
"omit",
".",
"push",
".",
"apply",
"(",
"omit",
",",
"nanomatch",
".",
"match",
"(",
"list",
",",
"pattern",
".",
"slice",
"(",
"1",
")",
",",
"options",
")",
")",
";",
"negated",
"=",
"true",
";",
"}",
"else",
"{",
"keep",
".",
"push",
".",
"apply",
"(",
"keep",
",",
"nanomatch",
".",
"match",
"(",
"list",
",",
"pattern",
",",
"options",
")",
")",
";",
"}",
"}",
"// minimatch.match parity",
"if",
"(",
"negated",
"&&",
"keep",
".",
"length",
"===",
"0",
")",
"{",
"if",
"(",
"options",
"&&",
"options",
".",
"unixify",
"===",
"false",
")",
"{",
"keep",
"=",
"list",
".",
"slice",
"(",
")",
";",
"}",
"else",
"{",
"const",
"unixify",
"=",
"utils",
".",
"unixify",
"(",
"options",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"i",
"++",
")",
"{",
"keep",
".",
"push",
"(",
"unixify",
"(",
"list",
"[",
"i",
"]",
")",
")",
";",
"}",
"}",
"}",
"const",
"matches",
"=",
"utils",
".",
"diff",
"(",
"keep",
",",
"omit",
")",
";",
"if",
"(",
"!",
"options",
"||",
"options",
".",
"nodupes",
"!==",
"false",
")",
"{",
"return",
"utils",
".",
"unique",
"(",
"matches",
")",
";",
"}",
"return",
"matches",
";",
"}"
] |
The main function takes a list of strings and one or more
glob patterns to use for matching.
```js
const nm = require('nanomatch');
nm(list, patterns[, options]);
console.log(nm(['a.js', 'a.txt'], ['*.js']));
//=> [ 'a.js' ]
```
@param {Array} `list` A list of strings to match
@param {String|Array} `patterns` One or more glob patterns to use for matching.
@param {Object} `options` See available [options](#options) for changing how matches are performed
@return {Array} Returns an array of matches
@summary false
@api public
|
[
"The",
"main",
"function",
"takes",
"a",
"list",
"of",
"strings",
"and",
"one",
"or",
"more",
"glob",
"patterns",
"to",
"use",
"for",
"matching",
"."
] |
a983ca01207f0e01a5ef5368aa9bd60e882135e9
|
https://github.com/micromatch/nanomatch/blob/a983ca01207f0e01a5ef5368aa9bd60e882135e9/index.js#L39-L86
|
19,925
|
micromatch/nanomatch
|
index.js
|
compose
|
function compose(patterns, options, matcher) {
let matchers;
return memoize('compose', String(patterns), options, function() {
return function(file) {
// delay composition until it's invoked the first time,
// after that it won't be called again
if (!matchers) {
matchers = [];
for (var i = 0; i < patterns.length; i++) {
matchers.push(matcher(patterns[i], options));
}
}
let len = matchers.length;
while (len--) {
if (matchers[len](file) === true) {
return true;
}
}
return false;
};
});
}
|
javascript
|
function compose(patterns, options, matcher) {
let matchers;
return memoize('compose', String(patterns), options, function() {
return function(file) {
// delay composition until it's invoked the first time,
// after that it won't be called again
if (!matchers) {
matchers = [];
for (var i = 0; i < patterns.length; i++) {
matchers.push(matcher(patterns[i], options));
}
}
let len = matchers.length;
while (len--) {
if (matchers[len](file) === true) {
return true;
}
}
return false;
};
});
}
|
[
"function",
"compose",
"(",
"patterns",
",",
"options",
",",
"matcher",
")",
"{",
"let",
"matchers",
";",
"return",
"memoize",
"(",
"'compose'",
",",
"String",
"(",
"patterns",
")",
",",
"options",
",",
"function",
"(",
")",
"{",
"return",
"function",
"(",
"file",
")",
"{",
"// delay composition until it's invoked the first time,",
"// after that it won't be called again",
"if",
"(",
"!",
"matchers",
")",
"{",
"matchers",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"patterns",
".",
"length",
";",
"i",
"++",
")",
"{",
"matchers",
".",
"push",
"(",
"matcher",
"(",
"patterns",
"[",
"i",
"]",
",",
"options",
")",
")",
";",
"}",
"}",
"let",
"len",
"=",
"matchers",
".",
"length",
";",
"while",
"(",
"len",
"--",
")",
"{",
"if",
"(",
"matchers",
"[",
"len",
"]",
"(",
"file",
")",
"===",
"true",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
";",
"}",
")",
";",
"}"
] |
Compose a matcher function with the given patterns.
This allows matcher functions to be compiled once and
called multiple times.
|
[
"Compose",
"a",
"matcher",
"function",
"with",
"the",
"given",
"patterns",
".",
"This",
"allows",
"matcher",
"functions",
"to",
"be",
"compiled",
"once",
"and",
"called",
"multiple",
"times",
"."
] |
a983ca01207f0e01a5ef5368aa9bd60e882135e9
|
https://github.com/micromatch/nanomatch/blob/a983ca01207f0e01a5ef5368aa9bd60e882135e9/index.js#L777-L800
|
19,926
|
danielstjules/blankshield
|
blankshield.js
|
blankshield
|
function blankshield(target) {
if (typeof target.length === 'undefined') {
addEventListener(target, 'click', clickListener);
} else if (typeof target !== 'string' && !(target instanceof String)) {
for (var i = 0; i < target.length; i++) {
addEventListener(target[i], 'click', clickListener);
}
}
}
|
javascript
|
function blankshield(target) {
if (typeof target.length === 'undefined') {
addEventListener(target, 'click', clickListener);
} else if (typeof target !== 'string' && !(target instanceof String)) {
for (var i = 0; i < target.length; i++) {
addEventListener(target[i], 'click', clickListener);
}
}
}
|
[
"function",
"blankshield",
"(",
"target",
")",
"{",
"if",
"(",
"typeof",
"target",
".",
"length",
"===",
"'undefined'",
")",
"{",
"addEventListener",
"(",
"target",
",",
"'click'",
",",
"clickListener",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"target",
"!==",
"'string'",
"&&",
"!",
"(",
"target",
"instanceof",
"String",
")",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"target",
".",
"length",
";",
"i",
"++",
")",
"{",
"addEventListener",
"(",
"target",
"[",
"i",
"]",
",",
"'click'",
",",
"clickListener",
")",
";",
"}",
"}",
"}"
] |
blankshield is the main function exported by the library. It accepts an
anchor element or array of elements, adding an event listener to each to
help mitigate a potential reverse tabnabbing attack. For performance, any
supplied object with a length attribute is assumed to be an array.
@param {HTMLAnchorElement|HTMLAnchorElement[]} target
|
[
"blankshield",
"is",
"the",
"main",
"function",
"exported",
"by",
"the",
"library",
".",
"It",
"accepts",
"an",
"anchor",
"element",
"or",
"array",
"of",
"elements",
"adding",
"an",
"event",
"listener",
"to",
"each",
"to",
"help",
"mitigate",
"a",
"potential",
"reverse",
"tabnabbing",
"attack",
".",
"For",
"performance",
"any",
"supplied",
"object",
"with",
"a",
"length",
"attribute",
"is",
"assumed",
"to",
"be",
"an",
"array",
"."
] |
6e208bf25a44bf50d1a5e85ae96fee0c015d05bc
|
https://github.com/danielstjules/blankshield/blob/6e208bf25a44bf50d1a5e85ae96fee0c015d05bc/blankshield.js#L32-L40
|
19,927
|
danielstjules/blankshield
|
blankshield.js
|
clickListener
|
function clickListener(e) {
var target, targetName, href, usedModifier;
// Use global event object for IE8 and below to get target
e = e || window.event;
// Won't work for IE8 and below for cases when e.srcElement
// refers not to the anchor, but to the element inside it e.g. an image
target = e.currentTarget || e.srcElement;
// Ignore anchors without an href
href = target.getAttribute('href');
if (!href) return;
// Ignore anchors without an unsafe target or modifier key
usedModifier = (e.ctrlKey || e.shiftKey || e.metaKey);
targetName = target.getAttribute('target');
if (!usedModifier && (!targetName || safeTarget(targetName))) {
return;
}
blankshield.open(href);
// IE8 and below don't support preventDefault
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
return false;
}
|
javascript
|
function clickListener(e) {
var target, targetName, href, usedModifier;
// Use global event object for IE8 and below to get target
e = e || window.event;
// Won't work for IE8 and below for cases when e.srcElement
// refers not to the anchor, but to the element inside it e.g. an image
target = e.currentTarget || e.srcElement;
// Ignore anchors without an href
href = target.getAttribute('href');
if (!href) return;
// Ignore anchors without an unsafe target or modifier key
usedModifier = (e.ctrlKey || e.shiftKey || e.metaKey);
targetName = target.getAttribute('target');
if (!usedModifier && (!targetName || safeTarget(targetName))) {
return;
}
blankshield.open(href);
// IE8 and below don't support preventDefault
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
return false;
}
|
[
"function",
"clickListener",
"(",
"e",
")",
"{",
"var",
"target",
",",
"targetName",
",",
"href",
",",
"usedModifier",
";",
"// Use global event object for IE8 and below to get target",
"e",
"=",
"e",
"||",
"window",
".",
"event",
";",
"// Won't work for IE8 and below for cases when e.srcElement",
"// refers not to the anchor, but to the element inside it e.g. an image",
"target",
"=",
"e",
".",
"currentTarget",
"||",
"e",
".",
"srcElement",
";",
"// Ignore anchors without an href",
"href",
"=",
"target",
".",
"getAttribute",
"(",
"'href'",
")",
";",
"if",
"(",
"!",
"href",
")",
"return",
";",
"// Ignore anchors without an unsafe target or modifier key",
"usedModifier",
"=",
"(",
"e",
".",
"ctrlKey",
"||",
"e",
".",
"shiftKey",
"||",
"e",
".",
"metaKey",
")",
";",
"targetName",
"=",
"target",
".",
"getAttribute",
"(",
"'target'",
")",
";",
"if",
"(",
"!",
"usedModifier",
"&&",
"(",
"!",
"targetName",
"||",
"safeTarget",
"(",
"targetName",
")",
")",
")",
"{",
"return",
";",
"}",
"blankshield",
".",
"open",
"(",
"href",
")",
";",
"// IE8 and below don't support preventDefault",
"if",
"(",
"e",
".",
"preventDefault",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
"else",
"{",
"e",
".",
"returnValue",
"=",
"false",
";",
"}",
"return",
"false",
";",
"}"
] |
An event listener that can be attached to a click event to protect against
reverse tabnabbing. It retrieves the target anchors href, and if the link
was intended to open in a new tab or window, the browser's default
behavior is canceled. Instead, the destination url is opened using
"window.open" from an injected iframe, and the iframe is removed. Except
for IE < 11, which uses "window.open" followed by setting the child
window's opener to null.
@param {Event} e The click event for a given anchor
|
[
"An",
"event",
"listener",
"that",
"can",
"be",
"attached",
"to",
"a",
"click",
"event",
"to",
"protect",
"against",
"reverse",
"tabnabbing",
".",
"It",
"retrieves",
"the",
"target",
"anchors",
"href",
"and",
"if",
"the",
"link",
"was",
"intended",
"to",
"open",
"in",
"a",
"new",
"tab",
"or",
"window",
"the",
"browser",
"s",
"default",
"behavior",
"is",
"canceled",
".",
"Instead",
"the",
"destination",
"url",
"is",
"opened",
"using",
"window",
".",
"open",
"from",
"an",
"injected",
"iframe",
"and",
"the",
"iframe",
"is",
"removed",
".",
"Except",
"for",
"IE",
"<",
"11",
"which",
"uses",
"window",
".",
"open",
"followed",
"by",
"setting",
"the",
"child",
"window",
"s",
"opener",
"to",
"null",
"."
] |
6e208bf25a44bf50d1a5e85ae96fee0c015d05bc
|
https://github.com/danielstjules/blankshield/blob/6e208bf25a44bf50d1a5e85ae96fee0c015d05bc/blankshield.js#L94-L124
|
19,928
|
danielstjules/blankshield
|
blankshield.js
|
addEventListener
|
function addEventListener(target, type, listener) {
var onType, prevListener;
// Modern browsers
if (target.addEventListener) {
return target.addEventListener(type, listener, false);
}
// Older browsers
onType = 'on' + type;
if (target.attachEvent) {
target.attachEvent(onType, listener);
} else if (target[onType]) {
prevListener = target[onType];
target[onType] = function() {
listener();
prevListener();
};
} else {
target[onType] = listener;
}
}
|
javascript
|
function addEventListener(target, type, listener) {
var onType, prevListener;
// Modern browsers
if (target.addEventListener) {
return target.addEventListener(type, listener, false);
}
// Older browsers
onType = 'on' + type;
if (target.attachEvent) {
target.attachEvent(onType, listener);
} else if (target[onType]) {
prevListener = target[onType];
target[onType] = function() {
listener();
prevListener();
};
} else {
target[onType] = listener;
}
}
|
[
"function",
"addEventListener",
"(",
"target",
",",
"type",
",",
"listener",
")",
"{",
"var",
"onType",
",",
"prevListener",
";",
"// Modern browsers",
"if",
"(",
"target",
".",
"addEventListener",
")",
"{",
"return",
"target",
".",
"addEventListener",
"(",
"type",
",",
"listener",
",",
"false",
")",
";",
"}",
"// Older browsers",
"onType",
"=",
"'on'",
"+",
"type",
";",
"if",
"(",
"target",
".",
"attachEvent",
")",
"{",
"target",
".",
"attachEvent",
"(",
"onType",
",",
"listener",
")",
";",
"}",
"else",
"if",
"(",
"target",
"[",
"onType",
"]",
")",
"{",
"prevListener",
"=",
"target",
"[",
"onType",
"]",
";",
"target",
"[",
"onType",
"]",
"=",
"function",
"(",
")",
"{",
"listener",
"(",
")",
";",
"prevListener",
"(",
")",
";",
"}",
";",
"}",
"else",
"{",
"target",
"[",
"onType",
"]",
"=",
"listener",
";",
"}",
"}"
] |
A cross-browser addEventListener function that adds a listener for the
supplied event type to the specified target.
@param {object} target
@param {string} type
@param {function} listener
|
[
"A",
"cross",
"-",
"browser",
"addEventListener",
"function",
"that",
"adds",
"a",
"listener",
"for",
"the",
"supplied",
"event",
"type",
"to",
"the",
"specified",
"target",
"."
] |
6e208bf25a44bf50d1a5e85ae96fee0c015d05bc
|
https://github.com/danielstjules/blankshield/blob/6e208bf25a44bf50d1a5e85ae96fee0c015d05bc/blankshield.js#L134-L155
|
19,929
|
bsiddiqui/bookshelf-paranoia
|
index.js
|
skipDeleted
|
function skipDeleted (model, attrs, options) {
if (!options.isEager || options.parentResponse) {
let softDelete = this.model
? this.model.prototype.softDelete
: this.softDelete
if (softDelete && !options.withDeleted) {
if (settings.nullValue === null) {
options.query.whereNull(`${result(this, 'tableName')}.${settings.field}`)
} else {
options.query.where(`${result(this, 'tableName')}.${settings.field}`, settings.nullValue)
}
}
}
}
|
javascript
|
function skipDeleted (model, attrs, options) {
if (!options.isEager || options.parentResponse) {
let softDelete = this.model
? this.model.prototype.softDelete
: this.softDelete
if (softDelete && !options.withDeleted) {
if (settings.nullValue === null) {
options.query.whereNull(`${result(this, 'tableName')}.${settings.field}`)
} else {
options.query.where(`${result(this, 'tableName')}.${settings.field}`, settings.nullValue)
}
}
}
}
|
[
"function",
"skipDeleted",
"(",
"model",
",",
"attrs",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
".",
"isEager",
"||",
"options",
".",
"parentResponse",
")",
"{",
"let",
"softDelete",
"=",
"this",
".",
"model",
"?",
"this",
".",
"model",
".",
"prototype",
".",
"softDelete",
":",
"this",
".",
"softDelete",
"if",
"(",
"softDelete",
"&&",
"!",
"options",
".",
"withDeleted",
")",
"{",
"if",
"(",
"settings",
".",
"nullValue",
"===",
"null",
")",
"{",
"options",
".",
"query",
".",
"whereNull",
"(",
"`",
"${",
"result",
"(",
"this",
",",
"'tableName'",
")",
"}",
"${",
"settings",
".",
"field",
"}",
"`",
")",
"}",
"else",
"{",
"options",
".",
"query",
".",
"where",
"(",
"`",
"${",
"result",
"(",
"this",
",",
"'tableName'",
")",
"}",
"${",
"settings",
".",
"field",
"}",
"`",
",",
"settings",
".",
"nullValue",
")",
"}",
"}",
"}",
"}"
] |
Check if the operation needs to be patched for not retrieving
soft deleted rows
@param {Object} model An instantiated bookshelf model
@param {Object} attrs The attributes that's being queried
@param {Object} options The operation option
@param {Boolean} [options.withDeleted=false] Override the default behavior
and allow querying soft deleted objects
|
[
"Check",
"if",
"the",
"operation",
"needs",
"to",
"be",
"patched",
"for",
"not",
"retrieving",
"soft",
"deleted",
"rows"
] |
1e5185f4bc5b20de27cacb1117890bec72b364d2
|
https://github.com/bsiddiqui/bookshelf-paranoia/blob/1e5185f4bc5b20de27cacb1117890bec72b364d2/index.js#L44-L58
|
19,930
|
bsiddiqui/bookshelf-paranoia
|
index.js
|
function (options) {
options = options || {}
if (this.softDelete && !options.hardDelete) {
let query = this.query()
// Add default values to options
options = merge(
{
method: 'update',
patch: true,
softDelete: true,
query: query
},
options
)
const date = options.date ? new Date(options.date) : new Date()
// Attributes to be passed to events
let attrs = { [settings.field]: date }
// Null out sentinel column, since NULL is not considered by SQL unique indexes
if (settings.sentinel) {
attrs[settings.sentinel] = null
}
// Make sure the field is formatted the same as other date columns
attrs = this.format(attrs)
return Promise.resolve()
.then(() => {
// Don't need to trigger hooks if there's no events registered
if (!settings.events) return
let events = []
// Emulate all pre update events
if (settings.events.destroying) {
events.push(
this.triggerThen('destroying', this, options).bind(this)
)
}
if (settings.events.saving) {
events.push(
this.triggerThen('saving', this, attrs, options).bind(this)
)
}
if (settings.events.updating) {
events.push(
this.triggerThen('updating', this, attrs, options).bind(this)
)
}
// Resolve all promises in parallel like bookshelf does
return Promise.all(events)
})
.then(() => {
// Check if we need to use a transaction
if (options.transacting) {
query = query.transacting(options.transacting)
}
return query
.update(attrs, this.idAttribute)
.where(this.format(this.attributes))
.where(`${result(this, 'tableName')}.${settings.field}`, settings.nullValue)
})
.then((resp) => {
// Check if the caller required a row to be deleted and if
// events weren't totally disabled
if (resp === 0 && options.require) {
throw new this.constructor.NoRowsDeletedError('No Rows Deleted')
} else if (!settings.events) {
return
}
// Add previous attr for reference and reset the model to pristine state
this.set(attrs)
options.previousAttributes = this._previousAttributes
this._reset()
let events = []
// Emulate all post update events
if (settings.events.destroyed) {
events.push(
this.triggerThen('destroyed', this, options).bind(this)
)
}
if (settings.events.saved) {
events.push(
this.triggerThen('saved', this, resp, options).bind(this)
)
}
if (settings.events.updated) {
events.push(
this.triggerThen('updated', this, resp, options).bind(this)
)
}
return Promise.all(events)
})
.then(() => this)
} else {
return modelPrototype.destroy.call(this, options)
}
}
|
javascript
|
function (options) {
options = options || {}
if (this.softDelete && !options.hardDelete) {
let query = this.query()
// Add default values to options
options = merge(
{
method: 'update',
patch: true,
softDelete: true,
query: query
},
options
)
const date = options.date ? new Date(options.date) : new Date()
// Attributes to be passed to events
let attrs = { [settings.field]: date }
// Null out sentinel column, since NULL is not considered by SQL unique indexes
if (settings.sentinel) {
attrs[settings.sentinel] = null
}
// Make sure the field is formatted the same as other date columns
attrs = this.format(attrs)
return Promise.resolve()
.then(() => {
// Don't need to trigger hooks if there's no events registered
if (!settings.events) return
let events = []
// Emulate all pre update events
if (settings.events.destroying) {
events.push(
this.triggerThen('destroying', this, options).bind(this)
)
}
if (settings.events.saving) {
events.push(
this.triggerThen('saving', this, attrs, options).bind(this)
)
}
if (settings.events.updating) {
events.push(
this.triggerThen('updating', this, attrs, options).bind(this)
)
}
// Resolve all promises in parallel like bookshelf does
return Promise.all(events)
})
.then(() => {
// Check if we need to use a transaction
if (options.transacting) {
query = query.transacting(options.transacting)
}
return query
.update(attrs, this.idAttribute)
.where(this.format(this.attributes))
.where(`${result(this, 'tableName')}.${settings.field}`, settings.nullValue)
})
.then((resp) => {
// Check if the caller required a row to be deleted and if
// events weren't totally disabled
if (resp === 0 && options.require) {
throw new this.constructor.NoRowsDeletedError('No Rows Deleted')
} else if (!settings.events) {
return
}
// Add previous attr for reference and reset the model to pristine state
this.set(attrs)
options.previousAttributes = this._previousAttributes
this._reset()
let events = []
// Emulate all post update events
if (settings.events.destroyed) {
events.push(
this.triggerThen('destroyed', this, options).bind(this)
)
}
if (settings.events.saved) {
events.push(
this.triggerThen('saved', this, resp, options).bind(this)
)
}
if (settings.events.updated) {
events.push(
this.triggerThen('updated', this, resp, options).bind(this)
)
}
return Promise.all(events)
})
.then(() => this)
} else {
return modelPrototype.destroy.call(this, options)
}
}
|
[
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"if",
"(",
"this",
".",
"softDelete",
"&&",
"!",
"options",
".",
"hardDelete",
")",
"{",
"let",
"query",
"=",
"this",
".",
"query",
"(",
")",
"// Add default values to options",
"options",
"=",
"merge",
"(",
"{",
"method",
":",
"'update'",
",",
"patch",
":",
"true",
",",
"softDelete",
":",
"true",
",",
"query",
":",
"query",
"}",
",",
"options",
")",
"const",
"date",
"=",
"options",
".",
"date",
"?",
"new",
"Date",
"(",
"options",
".",
"date",
")",
":",
"new",
"Date",
"(",
")",
"// Attributes to be passed to events",
"let",
"attrs",
"=",
"{",
"[",
"settings",
".",
"field",
"]",
":",
"date",
"}",
"// Null out sentinel column, since NULL is not considered by SQL unique indexes",
"if",
"(",
"settings",
".",
"sentinel",
")",
"{",
"attrs",
"[",
"settings",
".",
"sentinel",
"]",
"=",
"null",
"}",
"// Make sure the field is formatted the same as other date columns",
"attrs",
"=",
"this",
".",
"format",
"(",
"attrs",
")",
"return",
"Promise",
".",
"resolve",
"(",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"// Don't need to trigger hooks if there's no events registered",
"if",
"(",
"!",
"settings",
".",
"events",
")",
"return",
"let",
"events",
"=",
"[",
"]",
"// Emulate all pre update events",
"if",
"(",
"settings",
".",
"events",
".",
"destroying",
")",
"{",
"events",
".",
"push",
"(",
"this",
".",
"triggerThen",
"(",
"'destroying'",
",",
"this",
",",
"options",
")",
".",
"bind",
"(",
"this",
")",
")",
"}",
"if",
"(",
"settings",
".",
"events",
".",
"saving",
")",
"{",
"events",
".",
"push",
"(",
"this",
".",
"triggerThen",
"(",
"'saving'",
",",
"this",
",",
"attrs",
",",
"options",
")",
".",
"bind",
"(",
"this",
")",
")",
"}",
"if",
"(",
"settings",
".",
"events",
".",
"updating",
")",
"{",
"events",
".",
"push",
"(",
"this",
".",
"triggerThen",
"(",
"'updating'",
",",
"this",
",",
"attrs",
",",
"options",
")",
".",
"bind",
"(",
"this",
")",
")",
"}",
"// Resolve all promises in parallel like bookshelf does",
"return",
"Promise",
".",
"all",
"(",
"events",
")",
"}",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"// Check if we need to use a transaction",
"if",
"(",
"options",
".",
"transacting",
")",
"{",
"query",
"=",
"query",
".",
"transacting",
"(",
"options",
".",
"transacting",
")",
"}",
"return",
"query",
".",
"update",
"(",
"attrs",
",",
"this",
".",
"idAttribute",
")",
".",
"where",
"(",
"this",
".",
"format",
"(",
"this",
".",
"attributes",
")",
")",
".",
"where",
"(",
"`",
"${",
"result",
"(",
"this",
",",
"'tableName'",
")",
"}",
"${",
"settings",
".",
"field",
"}",
"`",
",",
"settings",
".",
"nullValue",
")",
"}",
")",
".",
"then",
"(",
"(",
"resp",
")",
"=>",
"{",
"// Check if the caller required a row to be deleted and if",
"// events weren't totally disabled",
"if",
"(",
"resp",
"===",
"0",
"&&",
"options",
".",
"require",
")",
"{",
"throw",
"new",
"this",
".",
"constructor",
".",
"NoRowsDeletedError",
"(",
"'No Rows Deleted'",
")",
"}",
"else",
"if",
"(",
"!",
"settings",
".",
"events",
")",
"{",
"return",
"}",
"// Add previous attr for reference and reset the model to pristine state",
"this",
".",
"set",
"(",
"attrs",
")",
"options",
".",
"previousAttributes",
"=",
"this",
".",
"_previousAttributes",
"this",
".",
"_reset",
"(",
")",
"let",
"events",
"=",
"[",
"]",
"// Emulate all post update events",
"if",
"(",
"settings",
".",
"events",
".",
"destroyed",
")",
"{",
"events",
".",
"push",
"(",
"this",
".",
"triggerThen",
"(",
"'destroyed'",
",",
"this",
",",
"options",
")",
".",
"bind",
"(",
"this",
")",
")",
"}",
"if",
"(",
"settings",
".",
"events",
".",
"saved",
")",
"{",
"events",
".",
"push",
"(",
"this",
".",
"triggerThen",
"(",
"'saved'",
",",
"this",
",",
"resp",
",",
"options",
")",
".",
"bind",
"(",
"this",
")",
")",
"}",
"if",
"(",
"settings",
".",
"events",
".",
"updated",
")",
"{",
"events",
".",
"push",
"(",
"this",
".",
"triggerThen",
"(",
"'updated'",
",",
"this",
",",
"resp",
",",
"options",
")",
".",
"bind",
"(",
"this",
")",
")",
"}",
"return",
"Promise",
".",
"all",
"(",
"events",
")",
"}",
")",
".",
"then",
"(",
"(",
")",
"=>",
"this",
")",
"}",
"else",
"{",
"return",
"modelPrototype",
".",
"destroy",
".",
"call",
"(",
"this",
",",
"options",
")",
"}",
"}"
] |
Override the default destroy method to provide soft deletion logic
@param {Object} [options] The default options parameters from Model.destroy
@param {Boolean} [options.hardDelete=false] Override the default soft
delete behavior and allow a model to be hard deleted
@param {Number|Date} [options.date=new Date()] Use a client supplied time
@return {Promise} A promise that's fulfilled when the model has been
hard or soft deleted
|
[
"Override",
"the",
"default",
"destroy",
"method",
"to",
"provide",
"soft",
"deletion",
"logic"
] |
1e5185f4bc5b20de27cacb1117890bec72b364d2
|
https://github.com/bsiddiqui/bookshelf-paranoia/blob/1e5185f4bc5b20de27cacb1117890bec72b364d2/index.js#L103-L211
|
|
19,931
|
timbuckley/redux-saga-test-engine
|
src/core.js
|
getNextVal
|
function getNextVal(searchVal, mapping) {
let value
if (isMap(mapping)) {
for (let [key, val] of mapping.entries()) {
if (deepEqual(key, searchVal)) {
value = val
break
}
}
} else {
value = (mapping.find(keyVal => deepEqual(keyVal[0], searchVal)) || [])[1]
}
if (typeof value === 'function') {
return value()
}
return value
}
|
javascript
|
function getNextVal(searchVal, mapping) {
let value
if (isMap(mapping)) {
for (let [key, val] of mapping.entries()) {
if (deepEqual(key, searchVal)) {
value = val
break
}
}
} else {
value = (mapping.find(keyVal => deepEqual(keyVal[0], searchVal)) || [])[1]
}
if (typeof value === 'function') {
return value()
}
return value
}
|
[
"function",
"getNextVal",
"(",
"searchVal",
",",
"mapping",
")",
"{",
"let",
"value",
"if",
"(",
"isMap",
"(",
"mapping",
")",
")",
"{",
"for",
"(",
"let",
"[",
"key",
",",
"val",
"]",
"of",
"mapping",
".",
"entries",
"(",
")",
")",
"{",
"if",
"(",
"deepEqual",
"(",
"key",
",",
"searchVal",
")",
")",
"{",
"value",
"=",
"val",
"break",
"}",
"}",
"}",
"else",
"{",
"value",
"=",
"(",
"mapping",
".",
"find",
"(",
"keyVal",
"=>",
"deepEqual",
"(",
"keyVal",
"[",
"0",
"]",
",",
"searchVal",
")",
")",
"||",
"[",
"]",
")",
"[",
"1",
"]",
"}",
"if",
"(",
"typeof",
"value",
"===",
"'function'",
")",
"{",
"return",
"value",
"(",
")",
"}",
"return",
"value",
"}"
] |
Returns value in mapping corresponding to matching searchVal key.
|
[
"Returns",
"value",
"in",
"mapping",
"corresponding",
"to",
"matching",
"searchVal",
"key",
"."
] |
f75fe195c6b3c839cdd16ba01f75caf74ca49734
|
https://github.com/timbuckley/redux-saga-test-engine/blob/f75fe195c6b3c839cdd16ba01f75caf74ca49734/src/core.js#L49-L66
|
19,932
|
timbuckley/redux-saga-test-engine
|
src/core.js
|
stringifyVal
|
function stringifyVal(val) {
return JSON.stringify(
val,
(key, val) => {
if (typeof val === 'function') {
if (val.name) {
return `[Function: ${val.name}]: ${val.toString()}`
} else {
return `[Function]: ${val.toString()}`
}
}
return val
},
2
)
}
|
javascript
|
function stringifyVal(val) {
return JSON.stringify(
val,
(key, val) => {
if (typeof val === 'function') {
if (val.name) {
return `[Function: ${val.name}]: ${val.toString()}`
} else {
return `[Function]: ${val.toString()}`
}
}
return val
},
2
)
}
|
[
"function",
"stringifyVal",
"(",
"val",
")",
"{",
"return",
"JSON",
".",
"stringify",
"(",
"val",
",",
"(",
"key",
",",
"val",
")",
"=>",
"{",
"if",
"(",
"typeof",
"val",
"===",
"'function'",
")",
"{",
"if",
"(",
"val",
".",
"name",
")",
"{",
"return",
"`",
"${",
"val",
".",
"name",
"}",
"${",
"val",
".",
"toString",
"(",
")",
"}",
"`",
"}",
"else",
"{",
"return",
"`",
"${",
"val",
".",
"toString",
"(",
")",
"}",
"`",
"}",
"}",
"return",
"val",
"}",
",",
"2",
")",
"}"
] |
Used to stringify yielded values. Output includes functions
|
[
"Used",
"to",
"stringify",
"yielded",
"values",
".",
"Output",
"includes",
"functions"
] |
f75fe195c6b3c839cdd16ba01f75caf74ca49734
|
https://github.com/timbuckley/redux-saga-test-engine/blob/f75fe195c6b3c839cdd16ba01f75caf74ca49734/src/core.js#L69-L84
|
19,933
|
groupon/cson-parser
|
lib/stringify.js
|
stringify
|
function stringify(data, visitor, indent) {
if (typeof data === 'function' || typeof data === 'undefined') {
// eslint-disable-next-line consistent-return
return undefined;
}
indent = parseIndent(indent);
const normalized = JSON.parse(JSON.stringify(data, visitor));
function visitNode(node, options) {
if (options == null) {
options = {};
}
switch (typeof node) {
case 'boolean':
return `${node}`;
case 'number':
if (isFinite(node)) {
return `${node}`;
}
return 'null';
case 'string':
return visitString(visitNode, indent, node, options);
case 'object':
if (node === null) {
return 'null';
} else if (Array.isArray(node)) {
return visitArray(visitNode, indent, node, options);
}
return visitObject(visitNode, indent, node, options);
default:
// eslint-disable-next-line consistent-return
return undefined;
}
}
// eslint-disable-next-line consistent-return
return visitNode(normalized);
}
|
javascript
|
function stringify(data, visitor, indent) {
if (typeof data === 'function' || typeof data === 'undefined') {
// eslint-disable-next-line consistent-return
return undefined;
}
indent = parseIndent(indent);
const normalized = JSON.parse(JSON.stringify(data, visitor));
function visitNode(node, options) {
if (options == null) {
options = {};
}
switch (typeof node) {
case 'boolean':
return `${node}`;
case 'number':
if (isFinite(node)) {
return `${node}`;
}
return 'null';
case 'string':
return visitString(visitNode, indent, node, options);
case 'object':
if (node === null) {
return 'null';
} else if (Array.isArray(node)) {
return visitArray(visitNode, indent, node, options);
}
return visitObject(visitNode, indent, node, options);
default:
// eslint-disable-next-line consistent-return
return undefined;
}
}
// eslint-disable-next-line consistent-return
return visitNode(normalized);
}
|
[
"function",
"stringify",
"(",
"data",
",",
"visitor",
",",
"indent",
")",
"{",
"if",
"(",
"typeof",
"data",
"===",
"'function'",
"||",
"typeof",
"data",
"===",
"'undefined'",
")",
"{",
"// eslint-disable-next-line consistent-return",
"return",
"undefined",
";",
"}",
"indent",
"=",
"parseIndent",
"(",
"indent",
")",
";",
"const",
"normalized",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"data",
",",
"visitor",
")",
")",
";",
"function",
"visitNode",
"(",
"node",
",",
"options",
")",
"{",
"if",
"(",
"options",
"==",
"null",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"switch",
"(",
"typeof",
"node",
")",
"{",
"case",
"'boolean'",
":",
"return",
"`",
"${",
"node",
"}",
"`",
";",
"case",
"'number'",
":",
"if",
"(",
"isFinite",
"(",
"node",
")",
")",
"{",
"return",
"`",
"${",
"node",
"}",
"`",
";",
"}",
"return",
"'null'",
";",
"case",
"'string'",
":",
"return",
"visitString",
"(",
"visitNode",
",",
"indent",
",",
"node",
",",
"options",
")",
";",
"case",
"'object'",
":",
"if",
"(",
"node",
"===",
"null",
")",
"{",
"return",
"'null'",
";",
"}",
"else",
"if",
"(",
"Array",
".",
"isArray",
"(",
"node",
")",
")",
"{",
"return",
"visitArray",
"(",
"visitNode",
",",
"indent",
",",
"node",
",",
"options",
")",
";",
"}",
"return",
"visitObject",
"(",
"visitNode",
",",
"indent",
",",
"node",
",",
"options",
")",
";",
"default",
":",
"// eslint-disable-next-line consistent-return",
"return",
"undefined",
";",
"}",
"}",
"// eslint-disable-next-line consistent-return",
"return",
"visitNode",
"(",
"normalized",
")",
";",
"}"
] |
disabling consistent return so cson parser handles undefined like JSON.stringify does
|
[
"disabling",
"consistent",
"return",
"so",
"cson",
"parser",
"handles",
"undefined",
"like",
"JSON",
".",
"stringify",
"does"
] |
4470da600b566bedec007d7d38881a4109ad4f03
|
https://github.com/groupon/cson-parser/blob/4470da600b566bedec007d7d38881a4109ad4f03/lib/stringify.js#L155-L199
|
19,934
|
matrix-org/matrix-appservice-node
|
lib/app-service-registration.js
|
AppServiceRegistration
|
function AppServiceRegistration(appServiceUrl) {
this.url = appServiceUrl;
this.id = null;
this.hs_token = null;
this.as_token = null;
this.sender_localpart = null;
this.rate_limited = true;
this.namespaces = {
users: [],
aliases: [],
rooms: []
};
this.protocols = null;
this._cachedRegex = {};
}
|
javascript
|
function AppServiceRegistration(appServiceUrl) {
this.url = appServiceUrl;
this.id = null;
this.hs_token = null;
this.as_token = null;
this.sender_localpart = null;
this.rate_limited = true;
this.namespaces = {
users: [],
aliases: [],
rooms: []
};
this.protocols = null;
this._cachedRegex = {};
}
|
[
"function",
"AppServiceRegistration",
"(",
"appServiceUrl",
")",
"{",
"this",
".",
"url",
"=",
"appServiceUrl",
";",
"this",
".",
"id",
"=",
"null",
";",
"this",
".",
"hs_token",
"=",
"null",
";",
"this",
".",
"as_token",
"=",
"null",
";",
"this",
".",
"sender_localpart",
"=",
"null",
";",
"this",
".",
"rate_limited",
"=",
"true",
";",
"this",
".",
"namespaces",
"=",
"{",
"users",
":",
"[",
"]",
",",
"aliases",
":",
"[",
"]",
",",
"rooms",
":",
"[",
"]",
"}",
";",
"this",
".",
"protocols",
"=",
"null",
";",
"this",
".",
"_cachedRegex",
"=",
"{",
"}",
";",
"}"
] |
Construct a new application service registration.
@constructor
@param {string} appServiceUrl The base URL the AS can be reached via.
|
[
"Construct",
"a",
"new",
"application",
"service",
"registration",
"."
] |
5ced14feaf06228e3f3bde04857dc83b076cc81d
|
https://github.com/matrix-org/matrix-appservice-node/blob/5ced14feaf06228e3f3bde04857dc83b076cc81d/lib/app-service-registration.js#L11-L25
|
19,935
|
EasyGraphQL/easygraphql-mock
|
util/customMock.js
|
fieldTypes
|
function fieldTypes (type) {
switch (type) {
case constants.ID:
case constants.string:
return 'string'
case constants.int:
case constants.float:
return 'number'
default:
}
}
|
javascript
|
function fieldTypes (type) {
switch (type) {
case constants.ID:
case constants.string:
return 'string'
case constants.int:
case constants.float:
return 'number'
default:
}
}
|
[
"function",
"fieldTypes",
"(",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"constants",
".",
"ID",
":",
"case",
"constants",
".",
"string",
":",
"return",
"'string'",
"case",
"constants",
".",
"int",
":",
"case",
"constants",
".",
"float",
":",
"return",
"'number'",
"default",
":",
"}",
"}"
] |
Convert the type of the field to return the type and check the typeof
|
[
"Convert",
"the",
"type",
"of",
"the",
"field",
"to",
"return",
"the",
"type",
"and",
"check",
"the",
"typeof"
] |
394620e0f53582c89db329cc8d61a2eae8800440
|
https://github.com/EasyGraphQL/easygraphql-mock/blob/394620e0f53582c89db329cc8d61a2eae8800440/util/customMock.js#L5-L17
|
19,936
|
fitraditya/node-pdf2img
|
lib/pdf2img.js
|
function (callback) {
gm(input).identify("%p ", function (err, value) {
var pageCount = String(value).split(' ');
if (!pageCount.length) {
callback({
result: 'error',
message: 'Invalid page number.'
}, null);
} else {
// Convert selected page
if (options.page !== null) {
if (options.page <= pageCount.length) {
callback(null, [options.page]);
} else {
callback({
result: 'error',
message: 'Invalid page number.'
}, null);
}
} else {
callback(null, pageCount);
}
}
})
}
|
javascript
|
function (callback) {
gm(input).identify("%p ", function (err, value) {
var pageCount = String(value).split(' ');
if (!pageCount.length) {
callback({
result: 'error',
message: 'Invalid page number.'
}, null);
} else {
// Convert selected page
if (options.page !== null) {
if (options.page <= pageCount.length) {
callback(null, [options.page]);
} else {
callback({
result: 'error',
message: 'Invalid page number.'
}, null);
}
} else {
callback(null, pageCount);
}
}
})
}
|
[
"function",
"(",
"callback",
")",
"{",
"gm",
"(",
"input",
")",
".",
"identify",
"(",
"\"%p \"",
",",
"function",
"(",
"err",
",",
"value",
")",
"{",
"var",
"pageCount",
"=",
"String",
"(",
"value",
")",
".",
"split",
"(",
"' '",
")",
";",
"if",
"(",
"!",
"pageCount",
".",
"length",
")",
"{",
"callback",
"(",
"{",
"result",
":",
"'error'",
",",
"message",
":",
"'Invalid page number.'",
"}",
",",
"null",
")",
";",
"}",
"else",
"{",
"// Convert selected page",
"if",
"(",
"options",
".",
"page",
"!==",
"null",
")",
"{",
"if",
"(",
"options",
".",
"page",
"<=",
"pageCount",
".",
"length",
")",
"{",
"callback",
"(",
"null",
",",
"[",
"options",
".",
"page",
"]",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"{",
"result",
":",
"'error'",
",",
"message",
":",
"'Invalid page number.'",
"}",
",",
"null",
")",
";",
"}",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"pageCount",
")",
";",
"}",
"}",
"}",
")",
"}"
] |
Get pages count
|
[
"Get",
"pages",
"count"
] |
1160ddfc5222701de5e1e0fc0b9c473b34ff131d
|
https://github.com/fitraditya/node-pdf2img/blob/1160ddfc5222701de5e1e0fc0b9c473b34ff131d/lib/pdf2img.js#L71-L98
|
|
19,937
|
fitraditya/node-pdf2img
|
lib/pdf2img.js
|
function(pages, callback) {
// Use eachSeries to make sure that conversion has done page by page
async.eachSeries(pages, function(page, callbackmap) {
var inputStream = fs.createReadStream(input);
var outputFile = options.outputdir + options.outputname + '_' + page + '.' + options.type;
convertPdf2Img(inputStream, outputFile, parseInt(page), function(error, result) {
if (error) {
return callbackmap(error);
}
stdout.push(result);
return callbackmap(error, result);
});
}, function(e) {
if (e) callback(e);
return callback(null, {
result: 'success',
message: stdout
});
});
}
|
javascript
|
function(pages, callback) {
// Use eachSeries to make sure that conversion has done page by page
async.eachSeries(pages, function(page, callbackmap) {
var inputStream = fs.createReadStream(input);
var outputFile = options.outputdir + options.outputname + '_' + page + '.' + options.type;
convertPdf2Img(inputStream, outputFile, parseInt(page), function(error, result) {
if (error) {
return callbackmap(error);
}
stdout.push(result);
return callbackmap(error, result);
});
}, function(e) {
if (e) callback(e);
return callback(null, {
result: 'success',
message: stdout
});
});
}
|
[
"function",
"(",
"pages",
",",
"callback",
")",
"{",
"// Use eachSeries to make sure that conversion has done page by page",
"async",
".",
"eachSeries",
"(",
"pages",
",",
"function",
"(",
"page",
",",
"callbackmap",
")",
"{",
"var",
"inputStream",
"=",
"fs",
".",
"createReadStream",
"(",
"input",
")",
";",
"var",
"outputFile",
"=",
"options",
".",
"outputdir",
"+",
"options",
".",
"outputname",
"+",
"'_'",
"+",
"page",
"+",
"'.'",
"+",
"options",
".",
"type",
";",
"convertPdf2Img",
"(",
"inputStream",
",",
"outputFile",
",",
"parseInt",
"(",
"page",
")",
",",
"function",
"(",
"error",
",",
"result",
")",
"{",
"if",
"(",
"error",
")",
"{",
"return",
"callbackmap",
"(",
"error",
")",
";",
"}",
"stdout",
".",
"push",
"(",
"result",
")",
";",
"return",
"callbackmap",
"(",
"error",
",",
"result",
")",
";",
"}",
")",
";",
"}",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
")",
"callback",
"(",
"e",
")",
";",
"return",
"callback",
"(",
"null",
",",
"{",
"result",
":",
"'success'",
",",
"message",
":",
"stdout",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Convert pdf file
|
[
"Convert",
"pdf",
"file"
] |
1160ddfc5222701de5e1e0fc0b9c473b34ff131d
|
https://github.com/fitraditya/node-pdf2img/blob/1160ddfc5222701de5e1e0fc0b9c473b34ff131d/lib/pdf2img.js#L102-L124
|
|
19,938
|
turt2live/node-email-reply-parser
|
index.js
|
parse
|
function parse(text, visibleTextOnly) {
var parser = new Parser();
var email = parser.parse(text);
if (visibleTextOnly) {
if (!email) return '';
else return email.getVisibleText();
} else return email;
}
|
javascript
|
function parse(text, visibleTextOnly) {
var parser = new Parser();
var email = parser.parse(text);
if (visibleTextOnly) {
if (!email) return '';
else return email.getVisibleText();
} else return email;
}
|
[
"function",
"parse",
"(",
"text",
",",
"visibleTextOnly",
")",
"{",
"var",
"parser",
"=",
"new",
"Parser",
"(",
")",
";",
"var",
"email",
"=",
"parser",
".",
"parse",
"(",
"text",
")",
";",
"if",
"(",
"visibleTextOnly",
")",
"{",
"if",
"(",
"!",
"email",
")",
"return",
"''",
";",
"else",
"return",
"email",
".",
"getVisibleText",
"(",
")",
";",
"}",
"else",
"return",
"email",
";",
"}"
] |
Parses the given text into an email
@param {string} text the email text to parse
@param {boolean} [visibleTextOnly] if true, the visible text will be returned instead of an Email
@returns {Email|string} the parsed Email or visible text, depending on the second argument
|
[
"Parses",
"the",
"given",
"text",
"into",
"an",
"email"
] |
3afbe2ccf929e3b5f6bf2d5711e8be7d42245c65
|
https://github.com/turt2live/node-email-reply-parser/blob/3afbe2ccf929e3b5f6bf2d5711e8be7d42245c65/index.js#L14-L22
|
19,939
|
ember-engines/ember-asset-loader
|
lib/node-asset-manifest-generator.js
|
NodeAssetManifestGenerator
|
function NodeAssetManifestGenerator(inputTrees, options) {
options = options || {};
this.appName = options.appName;
Plugin.call(this, [ inputTrees ], {
annotation: options.annotation
});
}
|
javascript
|
function NodeAssetManifestGenerator(inputTrees, options) {
options = options || {};
this.appName = options.appName;
Plugin.call(this, [ inputTrees ], {
annotation: options.annotation
});
}
|
[
"function",
"NodeAssetManifestGenerator",
"(",
"inputTrees",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"appName",
"=",
"options",
".",
"appName",
";",
"Plugin",
".",
"call",
"(",
"this",
",",
"[",
"inputTrees",
"]",
",",
"{",
"annotation",
":",
"options",
".",
"annotation",
"}",
")",
";",
"}"
] |
A Broccoli plugin to generate a module to be used in Node for resolving the
asset manifest. Primary use case is for FastBoot like environments.
@class NodeAssetManifestGenerator
@extends BroccoliCachingWriter
|
[
"A",
"Broccoli",
"plugin",
"to",
"generate",
"a",
"module",
"to",
"be",
"used",
"in",
"Node",
"for",
"resolving",
"the",
"asset",
"manifest",
".",
"Primary",
"use",
"case",
"is",
"for",
"FastBoot",
"like",
"environments",
"."
] |
4d36e16cf3199b7bae5c16cf3b09f87da608ed3f
|
https://github.com/ember-engines/ember-asset-loader/blob/4d36e16cf3199b7bae5c16cf3b09f87da608ed3f/lib/node-asset-manifest-generator.js#L12-L20
|
19,940
|
ember-engines/ember-asset-loader
|
lib/asset-manifest-generator.js
|
AssetManifestGenerator
|
function AssetManifestGenerator(inputTrees, options) {
options = options || {};
this.prepend = options.prepend || '';
this.filesToIgnore = options.filesToIgnore || [];
this.supportedTypes = options.supportedTypes || DEFAULT_SUPPORTED_TYPES;
this.generateURI = options.generateURI || function generateURI(filePath) {
return filePath;
};
Plugin.call(this, inputTrees, {
annotation: options.annotation
});
}
|
javascript
|
function AssetManifestGenerator(inputTrees, options) {
options = options || {};
this.prepend = options.prepend || '';
this.filesToIgnore = options.filesToIgnore || [];
this.supportedTypes = options.supportedTypes || DEFAULT_SUPPORTED_TYPES;
this.generateURI = options.generateURI || function generateURI(filePath) {
return filePath;
};
Plugin.call(this, inputTrees, {
annotation: options.annotation
});
}
|
[
"function",
"AssetManifestGenerator",
"(",
"inputTrees",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"prepend",
"=",
"options",
".",
"prepend",
"||",
"''",
";",
"this",
".",
"filesToIgnore",
"=",
"options",
".",
"filesToIgnore",
"||",
"[",
"]",
";",
"this",
".",
"supportedTypes",
"=",
"options",
".",
"supportedTypes",
"||",
"DEFAULT_SUPPORTED_TYPES",
";",
"this",
".",
"generateURI",
"=",
"options",
".",
"generateURI",
"||",
"function",
"generateURI",
"(",
"filePath",
")",
"{",
"return",
"filePath",
";",
"}",
";",
"Plugin",
".",
"call",
"(",
"this",
",",
"inputTrees",
",",
"{",
"annotation",
":",
"options",
".",
"annotation",
"}",
")",
";",
"}"
] |
A Broccoli plugin to generate an asset manifest from a given input tree.
You can also provide a second tree that is a tree containing an existing
`asset-manifest.json` file to merge with.
@class AssetManifestGenerator
@extends BroccoliCachingWriter
|
[
"A",
"Broccoli",
"plugin",
"to",
"generate",
"an",
"asset",
"manifest",
"from",
"a",
"given",
"input",
"tree",
".",
"You",
"can",
"also",
"provide",
"a",
"second",
"tree",
"that",
"is",
"a",
"tree",
"containing",
"an",
"existing",
"asset",
"-",
"manifest",
".",
"json",
"file",
"to",
"merge",
"with",
"."
] |
4d36e16cf3199b7bae5c16cf3b09f87da608ed3f
|
https://github.com/ember-engines/ember-asset-loader/blob/4d36e16cf3199b7bae5c16cf3b09f87da608ed3f/lib/asset-manifest-generator.js#L18-L31
|
19,941
|
ember-engines/ember-asset-loader
|
addon/services/asset-loader.js
|
reduceManifestBundles
|
function reduceManifestBundles(input, manifest) {
// If manifest doesn't have any bundles, then no reducing to do
if (!manifest.bundles) {
return input;
}
// Merge the bundles together, checking for collisions
return Object.keys(manifest.bundles).reduce((output, bundle) => {
Ember.assert(`The bundle "${bundle}" already exists.`, !output.bundles[bundle]);
output.bundles[bundle] = manifest.bundles[bundle];
return output;
}, input);
}
|
javascript
|
function reduceManifestBundles(input, manifest) {
// If manifest doesn't have any bundles, then no reducing to do
if (!manifest.bundles) {
return input;
}
// Merge the bundles together, checking for collisions
return Object.keys(manifest.bundles).reduce((output, bundle) => {
Ember.assert(`The bundle "${bundle}" already exists.`, !output.bundles[bundle]);
output.bundles[bundle] = manifest.bundles[bundle];
return output;
}, input);
}
|
[
"function",
"reduceManifestBundles",
"(",
"input",
",",
"manifest",
")",
"{",
"// If manifest doesn't have any bundles, then no reducing to do",
"if",
"(",
"!",
"manifest",
".",
"bundles",
")",
"{",
"return",
"input",
";",
"}",
"// Merge the bundles together, checking for collisions",
"return",
"Object",
".",
"keys",
"(",
"manifest",
".",
"bundles",
")",
".",
"reduce",
"(",
"(",
"output",
",",
"bundle",
")",
"=>",
"{",
"Ember",
".",
"assert",
"(",
"`",
"${",
"bundle",
"}",
"`",
",",
"!",
"output",
".",
"bundles",
"[",
"bundle",
"]",
")",
";",
"output",
".",
"bundles",
"[",
"bundle",
"]",
"=",
"manifest",
".",
"bundles",
"[",
"bundle",
"]",
";",
"return",
"output",
";",
"}",
",",
"input",
")",
";",
"}"
] |
Merges two manifests' bundles together and returns a new manifest.
@param {AssetManifest} input
@param {AssetManifest} manifest
@return {AssetManifest} output
|
[
"Merges",
"two",
"manifests",
"bundles",
"together",
"and",
"returns",
"a",
"new",
"manifest",
"."
] |
4d36e16cf3199b7bae5c16cf3b09f87da608ed3f
|
https://github.com/ember-engines/ember-asset-loader/blob/4d36e16cf3199b7bae5c16cf3b09f87da608ed3f/addon/services/asset-loader.js#L17-L29
|
19,942
|
ember-engines/ember-asset-loader
|
index.js
|
function() {
var tree = this._super.treeForApp.apply(this, arguments);
var app = findHost(this);
if (app && app.options && app.options.assetLoader && app.options.assetLoader.noManifest) {
tree = new Funnel(tree, {
exclude: [
'config/asset-manifest.js',
'instance-initializers/load-asset-manifest.js'
]
});
}
return tree;
}
|
javascript
|
function() {
var tree = this._super.treeForApp.apply(this, arguments);
var app = findHost(this);
if (app && app.options && app.options.assetLoader && app.options.assetLoader.noManifest) {
tree = new Funnel(tree, {
exclude: [
'config/asset-manifest.js',
'instance-initializers/load-asset-manifest.js'
]
});
}
return tree;
}
|
[
"function",
"(",
")",
"{",
"var",
"tree",
"=",
"this",
".",
"_super",
".",
"treeForApp",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"app",
"=",
"findHost",
"(",
"this",
")",
";",
"if",
"(",
"app",
"&&",
"app",
".",
"options",
"&&",
"app",
".",
"options",
".",
"assetLoader",
"&&",
"app",
".",
"options",
".",
"assetLoader",
".",
"noManifest",
")",
"{",
"tree",
"=",
"new",
"Funnel",
"(",
"tree",
",",
"{",
"exclude",
":",
"[",
"'config/asset-manifest.js'",
",",
"'instance-initializers/load-asset-manifest.js'",
"]",
"}",
")",
";",
"}",
"return",
"tree",
";",
"}"
] |
If the app has specified `noManifest` to be generated, then we don't
include the shim for the manifest and the service initializer.
@override
|
[
"If",
"the",
"app",
"has",
"specified",
"noManifest",
"to",
"be",
"generated",
"then",
"we",
"don",
"t",
"include",
"the",
"shim",
"for",
"the",
"manifest",
"and",
"the",
"service",
"initializer",
"."
] |
4d36e16cf3199b7bae5c16cf3b09f87da608ed3f
|
https://github.com/ember-engines/ember-asset-loader/blob/4d36e16cf3199b7bae5c16cf3b09f87da608ed3f/index.js#L16-L30
|
|
19,943
|
uber-web/ocular
|
modules/dev-tools/node/aliases.js
|
getSubmodules
|
function getSubmodules(packageRoot) {
const submodules = {};
const parentPath = resolve(packageRoot, './modules');
if (fs.existsSync(parentPath)) {
//monorepo
fs.readdirSync(parentPath)
.forEach(item => {
const itemPath = resolve(parentPath, item);
const moduleInfo = getModuleInfo(itemPath);
if (moduleInfo) {
submodules[moduleInfo.name] = moduleInfo;
}
});
} else {
const moduleInfo = getModuleInfo(packageRoot);
submodules[moduleInfo.name] = moduleInfo;
}
return submodules;
}
|
javascript
|
function getSubmodules(packageRoot) {
const submodules = {};
const parentPath = resolve(packageRoot, './modules');
if (fs.existsSync(parentPath)) {
//monorepo
fs.readdirSync(parentPath)
.forEach(item => {
const itemPath = resolve(parentPath, item);
const moduleInfo = getModuleInfo(itemPath);
if (moduleInfo) {
submodules[moduleInfo.name] = moduleInfo;
}
});
} else {
const moduleInfo = getModuleInfo(packageRoot);
submodules[moduleInfo.name] = moduleInfo;
}
return submodules;
}
|
[
"function",
"getSubmodules",
"(",
"packageRoot",
")",
"{",
"const",
"submodules",
"=",
"{",
"}",
";",
"const",
"parentPath",
"=",
"resolve",
"(",
"packageRoot",
",",
"'./modules'",
")",
";",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"parentPath",
")",
")",
"{",
"//monorepo",
"fs",
".",
"readdirSync",
"(",
"parentPath",
")",
".",
"forEach",
"(",
"item",
"=>",
"{",
"const",
"itemPath",
"=",
"resolve",
"(",
"parentPath",
",",
"item",
")",
";",
"const",
"moduleInfo",
"=",
"getModuleInfo",
"(",
"itemPath",
")",
";",
"if",
"(",
"moduleInfo",
")",
"{",
"submodules",
"[",
"moduleInfo",
".",
"name",
"]",
"=",
"moduleInfo",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"const",
"moduleInfo",
"=",
"getModuleInfo",
"(",
"packageRoot",
")",
";",
"submodules",
"[",
"moduleInfo",
".",
"name",
"]",
"=",
"moduleInfo",
";",
"}",
"return",
"submodules",
";",
"}"
] |
Get information of all submodules
|
[
"Get",
"information",
"of",
"all",
"submodules"
] |
cceb9720b4cf5460c77ed05b7ea0985355031f9d
|
https://github.com/uber-web/ocular/blob/cceb9720b4cf5460c77ed05b7ea0985355031f9d/modules/dev-tools/node/aliases.js#L22-L42
|
19,944
|
uber-web/ocular
|
modules/gatsby/src/utils/example-registry.js
|
getHeroExample
|
function getHeroExample() {
const EXAMPLES = getExamples();
const exampleNames = Object.keys(EXAMPLES);
let DefaultHeroExample = exampleNames.length && EXAMPLES[0];
// HACK/ib - Check if this is a dummy example injected to keep graphgl happy
// Set to null if undefined
if (!DefaultHeroExample || DefaultHeroExample.title === "none") {
DefaultHeroExample = null;
}
const HeroExample = DefaultHeroExample;
if (!HeroExample) {
console.warn("ocular: No hero example found", EXAMPLES); // eslint-disable-line
}
return HeroExample;
}
|
javascript
|
function getHeroExample() {
const EXAMPLES = getExamples();
const exampleNames = Object.keys(EXAMPLES);
let DefaultHeroExample = exampleNames.length && EXAMPLES[0];
// HACK/ib - Check if this is a dummy example injected to keep graphgl happy
// Set to null if undefined
if (!DefaultHeroExample || DefaultHeroExample.title === "none") {
DefaultHeroExample = null;
}
const HeroExample = DefaultHeroExample;
if (!HeroExample) {
console.warn("ocular: No hero example found", EXAMPLES); // eslint-disable-line
}
return HeroExample;
}
|
[
"function",
"getHeroExample",
"(",
")",
"{",
"const",
"EXAMPLES",
"=",
"getExamples",
"(",
")",
";",
"const",
"exampleNames",
"=",
"Object",
".",
"keys",
"(",
"EXAMPLES",
")",
";",
"let",
"DefaultHeroExample",
"=",
"exampleNames",
".",
"length",
"&&",
"EXAMPLES",
"[",
"0",
"]",
";",
"// HACK/ib - Check if this is a dummy example injected to keep graphgl happy",
"// Set to null if undefined",
"if",
"(",
"!",
"DefaultHeroExample",
"||",
"DefaultHeroExample",
".",
"title",
"===",
"\"none\"",
")",
"{",
"DefaultHeroExample",
"=",
"null",
";",
"}",
"const",
"HeroExample",
"=",
"DefaultHeroExample",
";",
"if",
"(",
"!",
"HeroExample",
")",
"{",
"console",
".",
"warn",
"(",
"\"ocular: No hero example found\"",
",",
"EXAMPLES",
")",
";",
"// eslint-disable-line",
"}",
"return",
"HeroExample",
";",
"}"
] |
Get a hero example if provided, or the first of the listed examples
|
[
"Get",
"a",
"hero",
"example",
"if",
"provided",
"or",
"the",
"first",
"of",
"the",
"listed",
"examples"
] |
cceb9720b4cf5460c77ed05b7ea0985355031f9d
|
https://github.com/uber-web/ocular/blob/cceb9720b4cf5460c77ed05b7ea0985355031f9d/modules/gatsby/src/utils/example-registry.js#L10-L25
|
19,945
|
uber-web/ocular
|
modules/gatsby/src/gatsby-node/create-webpack-config.js
|
stringify
|
function stringify(key, value) {
if (value instanceof RegExp) {
return value.toString();
}
if (value instanceof Function) {
return '[function]';
}
return value;
}
|
javascript
|
function stringify(key, value) {
if (value instanceof RegExp) {
return value.toString();
}
if (value instanceof Function) {
return '[function]';
}
return value;
}
|
[
"function",
"stringify",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"RegExp",
")",
"{",
"return",
"value",
".",
"toString",
"(",
")",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Function",
")",
"{",
"return",
"'[function]'",
";",
"}",
"return",
"value",
";",
"}"
] |
Makes JSON.stringify print regexps
|
[
"Makes",
"JSON",
".",
"stringify",
"print",
"regexps"
] |
cceb9720b4cf5460c77ed05b7ea0985355031f9d
|
https://github.com/uber-web/ocular/blob/cceb9720b4cf5460c77ed05b7ea0985355031f9d/modules/gatsby/src/gatsby-node/create-webpack-config.js#L10-L18
|
19,946
|
OSSIndex/auditjs
|
audit-package.js
|
function(pkgManagerName, pkgName, versionRange, callback) {
if (!myCache) {
myCache = cache({
base: require('os').homedir() + "/.auditjs",
name: 'auditjs3x',
duration: 1000 * 3600 * CACHE_DURATION_HOURS //one day
});
}
cleanCache();
auditPackagesImpl([{pm: pkgManagerName, name: pkgName, version: versionRange}], callback);
}
|
javascript
|
function(pkgManagerName, pkgName, versionRange, callback) {
if (!myCache) {
myCache = cache({
base: require('os').homedir() + "/.auditjs",
name: 'auditjs3x',
duration: 1000 * 3600 * CACHE_DURATION_HOURS //one day
});
}
cleanCache();
auditPackagesImpl([{pm: pkgManagerName, name: pkgName, version: versionRange}], callback);
}
|
[
"function",
"(",
"pkgManagerName",
",",
"pkgName",
",",
"versionRange",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"myCache",
")",
"{",
"myCache",
"=",
"cache",
"(",
"{",
"base",
":",
"require",
"(",
"'os'",
")",
".",
"homedir",
"(",
")",
"+",
"\"/.auditjs\"",
",",
"name",
":",
"'auditjs3x'",
",",
"duration",
":",
"1000",
"*",
"3600",
"*",
"CACHE_DURATION_HOURS",
"//one day",
"}",
")",
";",
"}",
"cleanCache",
"(",
")",
";",
"auditPackagesImpl",
"(",
"[",
"{",
"pm",
":",
"pkgManagerName",
",",
"name",
":",
"pkgName",
",",
"version",
":",
"versionRange",
"}",
"]",
",",
"callback",
")",
";",
"}"
] |
Audit a specific package
@param pkgManagerName Name of the package manager the package belongs to
@param pkgName Name of the package to audit
@param versionRange Semantic version range for the package
@param callback Function to call on completion of each dependency
analysis. This call back has 2 arguments:
(err, single_package_data).
|
[
"Audit",
"a",
"specific",
"package"
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/audit-package.js#L101-L111
|
|
19,947
|
OSSIndex/auditjs
|
audit.js
|
getLockfileDependencies
|
function getLockfileDependencies(root) {
var deps = {};
if (root.name && root.version) {
deps[root.name + "@" + root.version] = {
"pm": "npm",
"name": root.name,
"version": root.version
};
}
if (root.dependencies) {
for (var name in root.dependencies) {
var dep = root.dependencies[name];
if (dep.version) {
deps[name + "@" + dep.version] = {
"pm": "npm",
"name": name,
"version": dep.version
};
}
var childDeps = getLockfileDependencies(root.dependencies[name]);
for (var attr in childDeps) {
deps[attr] = childDeps[attr];
}
}
}
return Object.keys(deps).map(function (k) { return deps[k];});
}
|
javascript
|
function getLockfileDependencies(root) {
var deps = {};
if (root.name && root.version) {
deps[root.name + "@" + root.version] = {
"pm": "npm",
"name": root.name,
"version": root.version
};
}
if (root.dependencies) {
for (var name in root.dependencies) {
var dep = root.dependencies[name];
if (dep.version) {
deps[name + "@" + dep.version] = {
"pm": "npm",
"name": name,
"version": dep.version
};
}
var childDeps = getLockfileDependencies(root.dependencies[name]);
for (var attr in childDeps) {
deps[attr] = childDeps[attr];
}
}
}
return Object.keys(deps).map(function (k) { return deps[k];});
}
|
[
"function",
"getLockfileDependencies",
"(",
"root",
")",
"{",
"var",
"deps",
"=",
"{",
"}",
";",
"if",
"(",
"root",
".",
"name",
"&&",
"root",
".",
"version",
")",
"{",
"deps",
"[",
"root",
".",
"name",
"+",
"\"@\"",
"+",
"root",
".",
"version",
"]",
"=",
"{",
"\"pm\"",
":",
"\"npm\"",
",",
"\"name\"",
":",
"root",
".",
"name",
",",
"\"version\"",
":",
"root",
".",
"version",
"}",
";",
"}",
"if",
"(",
"root",
".",
"dependencies",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"root",
".",
"dependencies",
")",
"{",
"var",
"dep",
"=",
"root",
".",
"dependencies",
"[",
"name",
"]",
";",
"if",
"(",
"dep",
".",
"version",
")",
"{",
"deps",
"[",
"name",
"+",
"\"@\"",
"+",
"dep",
".",
"version",
"]",
"=",
"{",
"\"pm\"",
":",
"\"npm\"",
",",
"\"name\"",
":",
"name",
",",
"\"version\"",
":",
"dep",
".",
"version",
"}",
";",
"}",
"var",
"childDeps",
"=",
"getLockfileDependencies",
"(",
"root",
".",
"dependencies",
"[",
"name",
"]",
")",
";",
"for",
"(",
"var",
"attr",
"in",
"childDeps",
")",
"{",
"deps",
"[",
"attr",
"]",
"=",
"childDeps",
"[",
"attr",
"]",
";",
"}",
"}",
"}",
"return",
"Object",
".",
"keys",
"(",
"deps",
")",
".",
"map",
"(",
"function",
"(",
"k",
")",
"{",
"return",
"deps",
"[",
"k",
"]",
";",
"}",
")",
";",
"}"
] |
Given packag-lock.json data, produce a list of dependencies
|
[
"Given",
"packag",
"-",
"lock",
".",
"json",
"data",
"produce",
"a",
"list",
"of",
"dependencies"
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/audit.js#L239-L268
|
19,948
|
OSSIndex/auditjs
|
audit.js
|
exitHandler
|
function exitHandler(options, err) {
if (err) {
if (err.stack) {
console.error(err.stack);
} else {
console.error(err.toString());
}
}
if (whitelistedVulnerabilities.length > 0) {
logger.info(colors.bold.yellow("Filtering the following vulnerabilities"));
logger.info(colors.bold.yellow('=================================================='));
for (var i = 0; i < whitelistedVulnerabilities.length; i++) {
var detail = whitelistedVulnerabilities[i];
logger.info(`${colors.bold.blue(detail['title'])} affected versions: ${colors.red(detail['package'])} ${colors.red(detail['versions'])}`);
logger.info(`${detail['description']}`);
logger.info(colors.bold("ID") + ": " + detail.id);
if (detail.whitelistedPaths) {
detail.whitelistedPaths.forEach(function(path) {
logger.info(colors.bold("Ignored Path") + ": " + path);
})
}
logger.info(colors.bold.yellow('=================================================='));
};
}
logger.info('');
logger.info('Audited dependencies: ' + actualAudits +
', Vulnerable: ' + colors.bold.red(vulnerabilityCount) +
', Ignored: ' + whitelistedVulnerabilities.length);
if(config.get('report')) {
var filtered = whitelistedVulnerabilities.length;
mkdirp('reports');
if (JUnit[0] != '<') { // This is a hack in case this gets called twice
// Convert to XML
JUnit = jsontoxml(JUnit);
}
var dom = new DOMParser().parseFromString(JUnit);
dom.documentElement.setAttribute('name', `auditjs.security.${programPackage.split('.')[0]}`);
dom.documentElement.setAttribute('errors', 0);
dom.documentElement.setAttribute('tests', expectedAudits);
dom.documentElement.setAttribute('package', 'test');
dom.documentElement.setAttribute('id', '');
dom.documentElement.setAttribute('skipped', filtered);
dom.documentElement.setAttribute('failures', vulnerabilityCount);
JUnit = new XMLSerializer().serializeToString(dom);
logger.info( `Wrote JUnit report to reports/${output}`);
fs.writeFileSync('reports/' + output, `<?xml version="1.0" encoding="UTF-8"?>\n${JUnit}`);
}
if (config.get('suppressExitError')) {
process.exit(0);
} else {
process.exit(vulnerabilityCount);
}
}
|
javascript
|
function exitHandler(options, err) {
if (err) {
if (err.stack) {
console.error(err.stack);
} else {
console.error(err.toString());
}
}
if (whitelistedVulnerabilities.length > 0) {
logger.info(colors.bold.yellow("Filtering the following vulnerabilities"));
logger.info(colors.bold.yellow('=================================================='));
for (var i = 0; i < whitelistedVulnerabilities.length; i++) {
var detail = whitelistedVulnerabilities[i];
logger.info(`${colors.bold.blue(detail['title'])} affected versions: ${colors.red(detail['package'])} ${colors.red(detail['versions'])}`);
logger.info(`${detail['description']}`);
logger.info(colors.bold("ID") + ": " + detail.id);
if (detail.whitelistedPaths) {
detail.whitelistedPaths.forEach(function(path) {
logger.info(colors.bold("Ignored Path") + ": " + path);
})
}
logger.info(colors.bold.yellow('=================================================='));
};
}
logger.info('');
logger.info('Audited dependencies: ' + actualAudits +
', Vulnerable: ' + colors.bold.red(vulnerabilityCount) +
', Ignored: ' + whitelistedVulnerabilities.length);
if(config.get('report')) {
var filtered = whitelistedVulnerabilities.length;
mkdirp('reports');
if (JUnit[0] != '<') { // This is a hack in case this gets called twice
// Convert to XML
JUnit = jsontoxml(JUnit);
}
var dom = new DOMParser().parseFromString(JUnit);
dom.documentElement.setAttribute('name', `auditjs.security.${programPackage.split('.')[0]}`);
dom.documentElement.setAttribute('errors', 0);
dom.documentElement.setAttribute('tests', expectedAudits);
dom.documentElement.setAttribute('package', 'test');
dom.documentElement.setAttribute('id', '');
dom.documentElement.setAttribute('skipped', filtered);
dom.documentElement.setAttribute('failures', vulnerabilityCount);
JUnit = new XMLSerializer().serializeToString(dom);
logger.info( `Wrote JUnit report to reports/${output}`);
fs.writeFileSync('reports/' + output, `<?xml version="1.0" encoding="UTF-8"?>\n${JUnit}`);
}
if (config.get('suppressExitError')) {
process.exit(0);
} else {
process.exit(vulnerabilityCount);
}
}
|
[
"function",
"exitHandler",
"(",
"options",
",",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"stack",
")",
"{",
"console",
".",
"error",
"(",
"err",
".",
"stack",
")",
";",
"}",
"else",
"{",
"console",
".",
"error",
"(",
"err",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"whitelistedVulnerabilities",
".",
"length",
">",
"0",
")",
"{",
"logger",
".",
"info",
"(",
"colors",
".",
"bold",
".",
"yellow",
"(",
"\"Filtering the following vulnerabilities\"",
")",
")",
";",
"logger",
".",
"info",
"(",
"colors",
".",
"bold",
".",
"yellow",
"(",
"'=================================================='",
")",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"whitelistedVulnerabilities",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"detail",
"=",
"whitelistedVulnerabilities",
"[",
"i",
"]",
";",
"logger",
".",
"info",
"(",
"`",
"${",
"colors",
".",
"bold",
".",
"blue",
"(",
"detail",
"[",
"'title'",
"]",
")",
"}",
"${",
"colors",
".",
"red",
"(",
"detail",
"[",
"'package'",
"]",
")",
"}",
"${",
"colors",
".",
"red",
"(",
"detail",
"[",
"'versions'",
"]",
")",
"}",
"`",
")",
";",
"logger",
".",
"info",
"(",
"`",
"${",
"detail",
"[",
"'description'",
"]",
"}",
"`",
")",
";",
"logger",
".",
"info",
"(",
"colors",
".",
"bold",
"(",
"\"ID\"",
")",
"+",
"\": \"",
"+",
"detail",
".",
"id",
")",
";",
"if",
"(",
"detail",
".",
"whitelistedPaths",
")",
"{",
"detail",
".",
"whitelistedPaths",
".",
"forEach",
"(",
"function",
"(",
"path",
")",
"{",
"logger",
".",
"info",
"(",
"colors",
".",
"bold",
"(",
"\"Ignored Path\"",
")",
"+",
"\": \"",
"+",
"path",
")",
";",
"}",
")",
"}",
"logger",
".",
"info",
"(",
"colors",
".",
"bold",
".",
"yellow",
"(",
"'=================================================='",
")",
")",
";",
"}",
";",
"}",
"logger",
".",
"info",
"(",
"''",
")",
";",
"logger",
".",
"info",
"(",
"'Audited dependencies: '",
"+",
"actualAudits",
"+",
"', Vulnerable: '",
"+",
"colors",
".",
"bold",
".",
"red",
"(",
"vulnerabilityCount",
")",
"+",
"', Ignored: '",
"+",
"whitelistedVulnerabilities",
".",
"length",
")",
";",
"if",
"(",
"config",
".",
"get",
"(",
"'report'",
")",
")",
"{",
"var",
"filtered",
"=",
"whitelistedVulnerabilities",
".",
"length",
";",
"mkdirp",
"(",
"'reports'",
")",
";",
"if",
"(",
"JUnit",
"[",
"0",
"]",
"!=",
"'<'",
")",
"{",
"// This is a hack in case this gets called twice",
"// Convert to XML",
"JUnit",
"=",
"jsontoxml",
"(",
"JUnit",
")",
";",
"}",
"var",
"dom",
"=",
"new",
"DOMParser",
"(",
")",
".",
"parseFromString",
"(",
"JUnit",
")",
";",
"dom",
".",
"documentElement",
".",
"setAttribute",
"(",
"'name'",
",",
"`",
"${",
"programPackage",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"}",
"`",
")",
";",
"dom",
".",
"documentElement",
".",
"setAttribute",
"(",
"'errors'",
",",
"0",
")",
";",
"dom",
".",
"documentElement",
".",
"setAttribute",
"(",
"'tests'",
",",
"expectedAudits",
")",
";",
"dom",
".",
"documentElement",
".",
"setAttribute",
"(",
"'package'",
",",
"'test'",
")",
";",
"dom",
".",
"documentElement",
".",
"setAttribute",
"(",
"'id'",
",",
"''",
")",
";",
"dom",
".",
"documentElement",
".",
"setAttribute",
"(",
"'skipped'",
",",
"filtered",
")",
";",
"dom",
".",
"documentElement",
".",
"setAttribute",
"(",
"'failures'",
",",
"vulnerabilityCount",
")",
";",
"JUnit",
"=",
"new",
"XMLSerializer",
"(",
")",
".",
"serializeToString",
"(",
"dom",
")",
";",
"logger",
".",
"info",
"(",
"`",
"${",
"output",
"}",
"`",
")",
";",
"fs",
".",
"writeFileSync",
"(",
"'reports/'",
"+",
"output",
",",
"`",
"\\n",
"${",
"JUnit",
"}",
"`",
")",
";",
"}",
"if",
"(",
"config",
".",
"get",
"(",
"'suppressExitError'",
")",
")",
"{",
"process",
".",
"exit",
"(",
"0",
")",
";",
"}",
"else",
"{",
"process",
".",
"exit",
"(",
"vulnerabilityCount",
")",
";",
"}",
"}"
] |
Set the return value
@param options
@param err
@returns
|
[
"Set",
"the",
"return",
"value"
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/audit.js#L276-L331
|
19,949
|
OSSIndex/auditjs
|
audit.js
|
checkProperties
|
function checkProperties(obj) {
for (var key in obj) {
if (obj[key] !== null && obj[key] != "")
return false;
}
return true;
}
|
javascript
|
function checkProperties(obj) {
for (var key in obj) {
if (obj[key] !== null && obj[key] != "")
return false;
}
return true;
}
|
[
"function",
"checkProperties",
"(",
"obj",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"obj",
"[",
"key",
"]",
"!==",
"null",
"&&",
"obj",
"[",
"key",
"]",
"!=",
"\"\"",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check if all properties of an object are null and return true if they are
|
[
"Check",
"if",
"all",
"properties",
"of",
"an",
"object",
"are",
"null",
"and",
"return",
"true",
"if",
"they",
"are"
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/audit.js#L350-L356
|
19,950
|
OSSIndex/auditjs
|
audit.js
|
buildDependencyObjectLookup
|
function buildDependencyObjectLookup(data, lookup, parentPath) {
if (lookup == undefined) {
lookup = {};
}
parentPath = parentPath || '';
for(var k in data.dependencies) {
var dep = data.dependencies[k];
depPath = parentPath + '/' + dep.name;
var lookupKey = 'UNKNOWN'; //If we can't find a key below, something's wrong.
var depToStore = dep;
if (dep.name) {
lookupKey = dep.name + '@' + dep.version
} else if (dep._from) {
lookupKey = dep._from;
} else if (dep.requiredBy) {
// If we can't find the node_modules folder, we'll get 'requiredBy' instead.
lookupKey = k + "@" + dep.requiredBy;
depToStore = extractDep(data.dependencies[k]);
}
var existing = lookup[lookupKey];
if (existing) {
existing.depPaths.push(depPath);
} else {
lookup[lookupKey] = depToStore;
lookup[lookupKey].depPaths = [depPath];
}
buildDependencyObjectLookup(dep, lookup, depPath);
}
return lookup;
}
|
javascript
|
function buildDependencyObjectLookup(data, lookup, parentPath) {
if (lookup == undefined) {
lookup = {};
}
parentPath = parentPath || '';
for(var k in data.dependencies) {
var dep = data.dependencies[k];
depPath = parentPath + '/' + dep.name;
var lookupKey = 'UNKNOWN'; //If we can't find a key below, something's wrong.
var depToStore = dep;
if (dep.name) {
lookupKey = dep.name + '@' + dep.version
} else if (dep._from) {
lookupKey = dep._from;
} else if (dep.requiredBy) {
// If we can't find the node_modules folder, we'll get 'requiredBy' instead.
lookupKey = k + "@" + dep.requiredBy;
depToStore = extractDep(data.dependencies[k]);
}
var existing = lookup[lookupKey];
if (existing) {
existing.depPaths.push(depPath);
} else {
lookup[lookupKey] = depToStore;
lookup[lookupKey].depPaths = [depPath];
}
buildDependencyObjectLookup(dep, lookup, depPath);
}
return lookup;
}
|
[
"function",
"buildDependencyObjectLookup",
"(",
"data",
",",
"lookup",
",",
"parentPath",
")",
"{",
"if",
"(",
"lookup",
"==",
"undefined",
")",
"{",
"lookup",
"=",
"{",
"}",
";",
"}",
"parentPath",
"=",
"parentPath",
"||",
"''",
";",
"for",
"(",
"var",
"k",
"in",
"data",
".",
"dependencies",
")",
"{",
"var",
"dep",
"=",
"data",
".",
"dependencies",
"[",
"k",
"]",
";",
"depPath",
"=",
"parentPath",
"+",
"'/'",
"+",
"dep",
".",
"name",
";",
"var",
"lookupKey",
"=",
"'UNKNOWN'",
";",
"//If we can't find a key below, something's wrong.",
"var",
"depToStore",
"=",
"dep",
";",
"if",
"(",
"dep",
".",
"name",
")",
"{",
"lookupKey",
"=",
"dep",
".",
"name",
"+",
"'@'",
"+",
"dep",
".",
"version",
"}",
"else",
"if",
"(",
"dep",
".",
"_from",
")",
"{",
"lookupKey",
"=",
"dep",
".",
"_from",
";",
"}",
"else",
"if",
"(",
"dep",
".",
"requiredBy",
")",
"{",
"// If we can't find the node_modules folder, we'll get 'requiredBy' instead.",
"lookupKey",
"=",
"k",
"+",
"\"@\"",
"+",
"dep",
".",
"requiredBy",
";",
"depToStore",
"=",
"extractDep",
"(",
"data",
".",
"dependencies",
"[",
"k",
"]",
")",
";",
"}",
"var",
"existing",
"=",
"lookup",
"[",
"lookupKey",
"]",
";",
"if",
"(",
"existing",
")",
"{",
"existing",
".",
"depPaths",
".",
"push",
"(",
"depPath",
")",
";",
"}",
"else",
"{",
"lookup",
"[",
"lookupKey",
"]",
"=",
"depToStore",
";",
"lookup",
"[",
"lookupKey",
"]",
".",
"depPaths",
"=",
"[",
"depPath",
"]",
";",
"}",
"buildDependencyObjectLookup",
"(",
"dep",
",",
"lookup",
",",
"depPath",
")",
";",
"}",
"return",
"lookup",
";",
"}"
] |
Each specific package@version is only represented with the complete
dependency definitions once in the tree, but might not be where we need it.
Therefore we make a special lookup table
of package@version = [Object] which will be referenced later.
|
[
"Each",
"specific",
"package"
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/audit.js#L363-L397
|
19,951
|
OSSIndex/auditjs
|
audit.js
|
getDependencyList
|
function getDependencyList(depMap, depLookup) {
var results = [];
var lookup = {};
var keys = Object.keys(depMap);
for(var i = 0; i < keys.length; i++) {
var name = keys[i];
// The value of o depends on the type of structure we are passed
var o = depMap[name];
var spec = o.version ? name + "@" + o.version : name + "@" + o;
var version = o.version ? o.version : o;
var depPaths = o.depPaths ? o.depPaths : [spec];
// Only add a dependency once
// We need both the local and global "auditLookup" tables.
// The global lookup is used to ensure we only audit a
// dependency once, but cannot be done at the same level
// as the local lookup since the sub-dependencies are not
// available at all locations of the dependency tree (depMap).
if(lookup[spec] == undefined && auditLookup[spec] == undefined) {
lookup[spec] = true;
auditLookup[spec] = true;
results.push({"pm": config.get("pm"), "name": name, "version": version, "depPaths": depPaths});
// If there is a possibility of recursive dependencies...
if (o.version) {
var dataDeps = getDepsFromDataObject(o, depLookup);
if(dataDeps) {
var deps = getDependencyList(dataDeps, depLookup);
if(deps != undefined) {
results = results.concat(deps);
}
}
}
}
}
return results;
}
|
javascript
|
function getDependencyList(depMap, depLookup) {
var results = [];
var lookup = {};
var keys = Object.keys(depMap);
for(var i = 0; i < keys.length; i++) {
var name = keys[i];
// The value of o depends on the type of structure we are passed
var o = depMap[name];
var spec = o.version ? name + "@" + o.version : name + "@" + o;
var version = o.version ? o.version : o;
var depPaths = o.depPaths ? o.depPaths : [spec];
// Only add a dependency once
// We need both the local and global "auditLookup" tables.
// The global lookup is used to ensure we only audit a
// dependency once, but cannot be done at the same level
// as the local lookup since the sub-dependencies are not
// available at all locations of the dependency tree (depMap).
if(lookup[spec] == undefined && auditLookup[spec] == undefined) {
lookup[spec] = true;
auditLookup[spec] = true;
results.push({"pm": config.get("pm"), "name": name, "version": version, "depPaths": depPaths});
// If there is a possibility of recursive dependencies...
if (o.version) {
var dataDeps = getDepsFromDataObject(o, depLookup);
if(dataDeps) {
var deps = getDependencyList(dataDeps, depLookup);
if(deps != undefined) {
results = results.concat(deps);
}
}
}
}
}
return results;
}
|
[
"function",
"getDependencyList",
"(",
"depMap",
",",
"depLookup",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"var",
"lookup",
"=",
"{",
"}",
";",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"depMap",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"name",
"=",
"keys",
"[",
"i",
"]",
";",
"// The value of o depends on the type of structure we are passed",
"var",
"o",
"=",
"depMap",
"[",
"name",
"]",
";",
"var",
"spec",
"=",
"o",
".",
"version",
"?",
"name",
"+",
"\"@\"",
"+",
"o",
".",
"version",
":",
"name",
"+",
"\"@\"",
"+",
"o",
";",
"var",
"version",
"=",
"o",
".",
"version",
"?",
"o",
".",
"version",
":",
"o",
";",
"var",
"depPaths",
"=",
"o",
".",
"depPaths",
"?",
"o",
".",
"depPaths",
":",
"[",
"spec",
"]",
";",
"// Only add a dependency once",
"// We need both the local and global \"auditLookup\" tables.",
"// The global lookup is used to ensure we only audit a",
"// dependency once, but cannot be done at the same level",
"// as the local lookup since the sub-dependencies are not",
"// available at all locations of the dependency tree (depMap).",
"if",
"(",
"lookup",
"[",
"spec",
"]",
"==",
"undefined",
"&&",
"auditLookup",
"[",
"spec",
"]",
"==",
"undefined",
")",
"{",
"lookup",
"[",
"spec",
"]",
"=",
"true",
";",
"auditLookup",
"[",
"spec",
"]",
"=",
"true",
";",
"results",
".",
"push",
"(",
"{",
"\"pm\"",
":",
"config",
".",
"get",
"(",
"\"pm\"",
")",
",",
"\"name\"",
":",
"name",
",",
"\"version\"",
":",
"version",
",",
"\"depPaths\"",
":",
"depPaths",
"}",
")",
";",
"// If there is a possibility of recursive dependencies...",
"if",
"(",
"o",
".",
"version",
")",
"{",
"var",
"dataDeps",
"=",
"getDepsFromDataObject",
"(",
"o",
",",
"depLookup",
")",
";",
"if",
"(",
"dataDeps",
")",
"{",
"var",
"deps",
"=",
"getDependencyList",
"(",
"dataDeps",
",",
"depLookup",
")",
";",
"if",
"(",
"deps",
"!=",
"undefined",
")",
"{",
"results",
"=",
"results",
".",
"concat",
"(",
"deps",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"results",
";",
"}"
] |
Recursively get a flat list of dependency objects. This is simpler for
subsequent code to handle then a tree of dependencies.
Depending on the command line arguments, the dependencies may includes
a mix of production, development, optional, etc. dependencies.
|
[
"Recursively",
"get",
"a",
"flat",
"list",
"of",
"dependency",
"objects",
".",
"This",
"is",
"simpler",
"for",
"subsequent",
"code",
"to",
"handle",
"then",
"a",
"tree",
"of",
"dependencies",
"."
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/audit.js#L405-L445
|
19,952
|
OSSIndex/auditjs
|
audit.js
|
lookupSpecMatch
|
function lookupSpecMatch(lookup, spec) {
// Direct match
if (lookup[spec]) {
return lookup[spec];
}
// Close match
var shortSpec = spec.replace(/@\D/g,'@');
if (lookup[shortSpec]) {
return lookup[shortSpec];
}
// Check for Semver valid match
var lastIndex = spec.lastIndexOf('@');
var myName = spec.substring(0, lastIndex);
var myVersion = spec.substring(lastIndex + 1);
for(var k in lookup) {
lastIndex = k.lastIndexOf('@');
var yourName = k.substring(0, lastIndex);
var yourVersion = k.substring(lastIndex + 1);
if (myName == yourName && semver.valid(yourVersion) && semver.satisfies(yourVersion, myVersion)) {
return lookup[k];
}
}
return undefined;
}
|
javascript
|
function lookupSpecMatch(lookup, spec) {
// Direct match
if (lookup[spec]) {
return lookup[spec];
}
// Close match
var shortSpec = spec.replace(/@\D/g,'@');
if (lookup[shortSpec]) {
return lookup[shortSpec];
}
// Check for Semver valid match
var lastIndex = spec.lastIndexOf('@');
var myName = spec.substring(0, lastIndex);
var myVersion = spec.substring(lastIndex + 1);
for(var k in lookup) {
lastIndex = k.lastIndexOf('@');
var yourName = k.substring(0, lastIndex);
var yourVersion = k.substring(lastIndex + 1);
if (myName == yourName && semver.valid(yourVersion) && semver.satisfies(yourVersion, myVersion)) {
return lookup[k];
}
}
return undefined;
}
|
[
"function",
"lookupSpecMatch",
"(",
"lookup",
",",
"spec",
")",
"{",
"// Direct match",
"if",
"(",
"lookup",
"[",
"spec",
"]",
")",
"{",
"return",
"lookup",
"[",
"spec",
"]",
";",
"}",
"// Close match",
"var",
"shortSpec",
"=",
"spec",
".",
"replace",
"(",
"/",
"@\\D",
"/",
"g",
",",
"'@'",
")",
";",
"if",
"(",
"lookup",
"[",
"shortSpec",
"]",
")",
"{",
"return",
"lookup",
"[",
"shortSpec",
"]",
";",
"}",
"// Check for Semver valid match",
"var",
"lastIndex",
"=",
"spec",
".",
"lastIndexOf",
"(",
"'@'",
")",
";",
"var",
"myName",
"=",
"spec",
".",
"substring",
"(",
"0",
",",
"lastIndex",
")",
";",
"var",
"myVersion",
"=",
"spec",
".",
"substring",
"(",
"lastIndex",
"+",
"1",
")",
";",
"for",
"(",
"var",
"k",
"in",
"lookup",
")",
"{",
"lastIndex",
"=",
"k",
".",
"lastIndexOf",
"(",
"'@'",
")",
";",
"var",
"yourName",
"=",
"k",
".",
"substring",
"(",
"0",
",",
"lastIndex",
")",
";",
"var",
"yourVersion",
"=",
"k",
".",
"substring",
"(",
"lastIndex",
"+",
"1",
")",
";",
"if",
"(",
"myName",
"==",
"yourName",
"&&",
"semver",
".",
"valid",
"(",
"yourVersion",
")",
"&&",
"semver",
".",
"satisfies",
"(",
"yourVersion",
",",
"myVersion",
")",
")",
"{",
"return",
"lookup",
"[",
"k",
"]",
";",
"}",
"}",
"return",
"undefined",
";",
"}"
] |
Given a lookup table, try and find the best specification match for the
provided name@version
|
[
"Given",
"a",
"lookup",
"table",
"try",
"and",
"find",
"the",
"best",
"specification",
"match",
"for",
"the",
"provided",
"name"
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/audit.js#L463-L488
|
19,953
|
OSSIndex/auditjs
|
audit.js
|
getDepsFromDataObject
|
function getDepsFromDataObject(data, lookup) {
var results = {};
if (categories.length == 0) {
for(var k in data.dependencies) {
var dep = extractDep(data.dependencies[k]);
results[k]=dep;
}
}
if (lookup) {
for (var i = 0; i < categories.length; i++) {
var category = categories[i];
for(var k in data[category]) {
var spec = k + "@" + data[category][k];
var specMatch = lookupSpecMatch(lookup, spec);
// If there is no match in the lookup then this dependency was "deduped"
if (specMatch) {
results[k]=specMatch;
}
}
}
}
return results;
}
|
javascript
|
function getDepsFromDataObject(data, lookup) {
var results = {};
if (categories.length == 0) {
for(var k in data.dependencies) {
var dep = extractDep(data.dependencies[k]);
results[k]=dep;
}
}
if (lookup) {
for (var i = 0; i < categories.length; i++) {
var category = categories[i];
for(var k in data[category]) {
var spec = k + "@" + data[category][k];
var specMatch = lookupSpecMatch(lookup, spec);
// If there is no match in the lookup then this dependency was "deduped"
if (specMatch) {
results[k]=specMatch;
}
}
}
}
return results;
}
|
[
"function",
"getDepsFromDataObject",
"(",
"data",
",",
"lookup",
")",
"{",
"var",
"results",
"=",
"{",
"}",
";",
"if",
"(",
"categories",
".",
"length",
"==",
"0",
")",
"{",
"for",
"(",
"var",
"k",
"in",
"data",
".",
"dependencies",
")",
"{",
"var",
"dep",
"=",
"extractDep",
"(",
"data",
".",
"dependencies",
"[",
"k",
"]",
")",
";",
"results",
"[",
"k",
"]",
"=",
"dep",
";",
"}",
"}",
"if",
"(",
"lookup",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"categories",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"category",
"=",
"categories",
"[",
"i",
"]",
";",
"for",
"(",
"var",
"k",
"in",
"data",
"[",
"category",
"]",
")",
"{",
"var",
"spec",
"=",
"k",
"+",
"\"@\"",
"+",
"data",
"[",
"category",
"]",
"[",
"k",
"]",
";",
"var",
"specMatch",
"=",
"lookupSpecMatch",
"(",
"lookup",
",",
"spec",
")",
";",
"// If there is no match in the lookup then this dependency was \"deduped\"",
"if",
"(",
"specMatch",
")",
"{",
"results",
"[",
"k",
"]",
"=",
"specMatch",
";",
"}",
"}",
"}",
"}",
"return",
"results",
";",
"}"
] |
Get the dependencies from an npm object. The exact dependencies retrieved
depend on categories requested by the user.
|
[
"Get",
"the",
"dependencies",
"from",
"an",
"npm",
"object",
".",
"The",
"exact",
"dependencies",
"retrieved",
"depend",
"on",
"categories",
"requested",
"by",
"the",
"user",
"."
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/audit.js#L493-L518
|
19,954
|
OSSIndex/auditjs
|
audit.js
|
getValidVulnerabilities
|
function getValidVulnerabilities(productRange, details, pkg, depPaths) {
var results = [];
if(details != undefined) {
for(var i = 0; i < details.length; i++) {
var detail = details[i];
detail.depPaths = depPaths;
// Do we white-list this match?
var id = detail.id;
if (whitelist && whitelist[id]) {
var whitelistEntry = whitelist[id];
if (whitelistEntry.dependencyPaths) {
for (var whitelistIdx = 0; whitelistIdx < whitelistEntry.dependencyPaths.length; whitelistIdx++) {
var wDep = whitelistEntry.dependencyPaths[whitelistIdx];
var regex = new RegExp(wDep);
detail.depPaths = detail.depPaths.filter(function(dDep) {
if (regex.test(dDep)){
detail.whitelistedPaths = detail.whitelistedPaths || [];
detail.whitelistedPaths.push(dDep);
return false;
}
return true;
});
}
detail["package"] = pkg;
whitelistedVulnerabilities.push(detail);
if (detail.depPaths.length == 0) {
console.log('SKIPPING BECAUSE ALL PATHS MATCHED')
}
} else {
detail["package"] = pkg;
whitelistedVulnerabilities.push(detail);
}
}
else {
results.push(detail);
}
}
}
return results;
}
|
javascript
|
function getValidVulnerabilities(productRange, details, pkg, depPaths) {
var results = [];
if(details != undefined) {
for(var i = 0; i < details.length; i++) {
var detail = details[i];
detail.depPaths = depPaths;
// Do we white-list this match?
var id = detail.id;
if (whitelist && whitelist[id]) {
var whitelistEntry = whitelist[id];
if (whitelistEntry.dependencyPaths) {
for (var whitelistIdx = 0; whitelistIdx < whitelistEntry.dependencyPaths.length; whitelistIdx++) {
var wDep = whitelistEntry.dependencyPaths[whitelistIdx];
var regex = new RegExp(wDep);
detail.depPaths = detail.depPaths.filter(function(dDep) {
if (regex.test(dDep)){
detail.whitelistedPaths = detail.whitelistedPaths || [];
detail.whitelistedPaths.push(dDep);
return false;
}
return true;
});
}
detail["package"] = pkg;
whitelistedVulnerabilities.push(detail);
if (detail.depPaths.length == 0) {
console.log('SKIPPING BECAUSE ALL PATHS MATCHED')
}
} else {
detail["package"] = pkg;
whitelistedVulnerabilities.push(detail);
}
}
else {
results.push(detail);
}
}
}
return results;
}
|
[
"function",
"getValidVulnerabilities",
"(",
"productRange",
",",
"details",
",",
"pkg",
",",
"depPaths",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"details",
"!=",
"undefined",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"details",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"detail",
"=",
"details",
"[",
"i",
"]",
";",
"detail",
".",
"depPaths",
"=",
"depPaths",
";",
"// Do we white-list this match?",
"var",
"id",
"=",
"detail",
".",
"id",
";",
"if",
"(",
"whitelist",
"&&",
"whitelist",
"[",
"id",
"]",
")",
"{",
"var",
"whitelistEntry",
"=",
"whitelist",
"[",
"id",
"]",
";",
"if",
"(",
"whitelistEntry",
".",
"dependencyPaths",
")",
"{",
"for",
"(",
"var",
"whitelistIdx",
"=",
"0",
";",
"whitelistIdx",
"<",
"whitelistEntry",
".",
"dependencyPaths",
".",
"length",
";",
"whitelistIdx",
"++",
")",
"{",
"var",
"wDep",
"=",
"whitelistEntry",
".",
"dependencyPaths",
"[",
"whitelistIdx",
"]",
";",
"var",
"regex",
"=",
"new",
"RegExp",
"(",
"wDep",
")",
";",
"detail",
".",
"depPaths",
"=",
"detail",
".",
"depPaths",
".",
"filter",
"(",
"function",
"(",
"dDep",
")",
"{",
"if",
"(",
"regex",
".",
"test",
"(",
"dDep",
")",
")",
"{",
"detail",
".",
"whitelistedPaths",
"=",
"detail",
".",
"whitelistedPaths",
"||",
"[",
"]",
";",
"detail",
".",
"whitelistedPaths",
".",
"push",
"(",
"dDep",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"}",
"detail",
"[",
"\"package\"",
"]",
"=",
"pkg",
";",
"whitelistedVulnerabilities",
".",
"push",
"(",
"detail",
")",
";",
"if",
"(",
"detail",
".",
"depPaths",
".",
"length",
"==",
"0",
")",
"{",
"console",
".",
"log",
"(",
"'SKIPPING BECAUSE ALL PATHS MATCHED'",
")",
"}",
"}",
"else",
"{",
"detail",
"[",
"\"package\"",
"]",
"=",
"pkg",
";",
"whitelistedVulnerabilities",
".",
"push",
"(",
"detail",
")",
";",
"}",
"}",
"else",
"{",
"results",
".",
"push",
"(",
"detail",
")",
";",
"}",
"}",
"}",
"return",
"results",
";",
"}"
] |
Return list of vulnerabilities found to affect this version.
@param productRange A version range as defined by semantic versioning
@param details Vulnerability details
@returns
|
[
"Return",
"list",
"of",
"vulnerabilities",
"found",
"to",
"affect",
"this",
"version",
"."
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/audit.js#L704-L746
|
19,955
|
OSSIndex/auditjs
|
config.js
|
simplifyWhitelist
|
function simplifyWhitelist(whitelist) {
var results = [];
if (Array.isArray(whitelist)) {
// whitelist is in Simplified format
for (var i = 0; i < whitelist.length; i++) {
results.push({
"id": whitelist[i]
});
}
} else {
// whitelist is in Verbose format
for (var project in whitelist) {
var vlist = whitelist[project];
for (var i = 0; i < vlist.length; i++) {
var id = vlist[i].id;
results.push({
"id": id,
"dependencyPaths": vlist[i].dependencyPaths
});
}
}
}
return results;
}
|
javascript
|
function simplifyWhitelist(whitelist) {
var results = [];
if (Array.isArray(whitelist)) {
// whitelist is in Simplified format
for (var i = 0; i < whitelist.length; i++) {
results.push({
"id": whitelist[i]
});
}
} else {
// whitelist is in Verbose format
for (var project in whitelist) {
var vlist = whitelist[project];
for (var i = 0; i < vlist.length; i++) {
var id = vlist[i].id;
results.push({
"id": id,
"dependencyPaths": vlist[i].dependencyPaths
});
}
}
}
return results;
}
|
[
"function",
"simplifyWhitelist",
"(",
"whitelist",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"whitelist",
")",
")",
"{",
"// whitelist is in Simplified format",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"whitelist",
".",
"length",
";",
"i",
"++",
")",
"{",
"results",
".",
"push",
"(",
"{",
"\"id\"",
":",
"whitelist",
"[",
"i",
"]",
"}",
")",
";",
"}",
"}",
"else",
"{",
"// whitelist is in Verbose format",
"for",
"(",
"var",
"project",
"in",
"whitelist",
")",
"{",
"var",
"vlist",
"=",
"whitelist",
"[",
"project",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"vlist",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"id",
"=",
"vlist",
"[",
"i",
"]",
".",
"id",
";",
"results",
".",
"push",
"(",
"{",
"\"id\"",
":",
"id",
",",
"\"dependencyPaths\"",
":",
"vlist",
"[",
"i",
"]",
".",
"dependencyPaths",
"}",
")",
";",
"}",
"}",
"}",
"return",
"results",
";",
"}"
] |
Simplify the white-list into a list of issue IDs.
|
[
"Simplify",
"the",
"white",
"-",
"list",
"into",
"a",
"list",
"of",
"issue",
"IDs",
"."
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/config.js#L135-L160
|
19,956
|
OSSIndex/auditjs
|
config.js
|
loadConfig
|
function loadConfig() {
underload('whitelist', 'whitelist.file');
if (!program['bower'] && config.has('packages.type') && config.get('packages.type') == 'bower') {
program['bower'] = true;
}
if (!program['noNode'] && config.has('packages.withNode') && config.get('packages.withNode') == false) {
program['noNode'] = true;
}
underload('package', 'packages.file');
underload('level', 'logging.level');
underload('quiet', 'logging.quiet');
underload('verbose', 'logging.verbose');
underload('scheme', 'server.scheme');
underload('host', 'server.host');
underload('port', 'server.port');
underload('cacheDir', 'cache.path');
underload('cacheTimeout', 'cache.timeout')
underload('username', 'auth.user');
underload('token', 'auth.token');
}
|
javascript
|
function loadConfig() {
underload('whitelist', 'whitelist.file');
if (!program['bower'] && config.has('packages.type') && config.get('packages.type') == 'bower') {
program['bower'] = true;
}
if (!program['noNode'] && config.has('packages.withNode') && config.get('packages.withNode') == false) {
program['noNode'] = true;
}
underload('package', 'packages.file');
underload('level', 'logging.level');
underload('quiet', 'logging.quiet');
underload('verbose', 'logging.verbose');
underload('scheme', 'server.scheme');
underload('host', 'server.host');
underload('port', 'server.port');
underload('cacheDir', 'cache.path');
underload('cacheTimeout', 'cache.timeout')
underload('username', 'auth.user');
underload('token', 'auth.token');
}
|
[
"function",
"loadConfig",
"(",
")",
"{",
"underload",
"(",
"'whitelist'",
",",
"'whitelist.file'",
")",
";",
"if",
"(",
"!",
"program",
"[",
"'bower'",
"]",
"&&",
"config",
".",
"has",
"(",
"'packages.type'",
")",
"&&",
"config",
".",
"get",
"(",
"'packages.type'",
")",
"==",
"'bower'",
")",
"{",
"program",
"[",
"'bower'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"program",
"[",
"'noNode'",
"]",
"&&",
"config",
".",
"has",
"(",
"'packages.withNode'",
")",
"&&",
"config",
".",
"get",
"(",
"'packages.withNode'",
")",
"==",
"false",
")",
"{",
"program",
"[",
"'noNode'",
"]",
"=",
"true",
";",
"}",
"underload",
"(",
"'package'",
",",
"'packages.file'",
")",
";",
"underload",
"(",
"'level'",
",",
"'logging.level'",
")",
";",
"underload",
"(",
"'quiet'",
",",
"'logging.quiet'",
")",
";",
"underload",
"(",
"'verbose'",
",",
"'logging.verbose'",
")",
";",
"underload",
"(",
"'scheme'",
",",
"'server.scheme'",
")",
";",
"underload",
"(",
"'host'",
",",
"'server.host'",
")",
";",
"underload",
"(",
"'port'",
",",
"'server.port'",
")",
";",
"underload",
"(",
"'cacheDir'",
",",
"'cache.path'",
")",
";",
"underload",
"(",
"'cacheTimeout'",
",",
"'cache.timeout'",
")",
"underload",
"(",
"'username'",
",",
"'auth.user'",
")",
";",
"underload",
"(",
"'token'",
",",
"'auth.token'",
")",
";",
"}"
] |
Load configuration information from the specified file. Command line
overrides all file configuration.
|
[
"Load",
"configuration",
"information",
"from",
"the",
"specified",
"file",
".",
"Command",
"line",
"overrides",
"all",
"file",
"configuration",
"."
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/config.js#L165-L192
|
19,957
|
OSSIndex/auditjs
|
config.js
|
underload
|
function underload(cmdlineName, configName) {
if (!program[cmdlineName] && config.has(configName)) {
program[cmdlineName] = config.get(configName);
}
}
|
javascript
|
function underload(cmdlineName, configName) {
if (!program[cmdlineName] && config.has(configName)) {
program[cmdlineName] = config.get(configName);
}
}
|
[
"function",
"underload",
"(",
"cmdlineName",
",",
"configName",
")",
"{",
"if",
"(",
"!",
"program",
"[",
"cmdlineName",
"]",
"&&",
"config",
".",
"has",
"(",
"configName",
")",
")",
"{",
"program",
"[",
"cmdlineName",
"]",
"=",
"config",
".",
"get",
"(",
"configName",
")",
";",
"}",
"}"
] |
Load the config file option if not overloaded by the command line.
@param cmdlineName: The command line option name
@param configName: The config file option name
|
[
"Load",
"the",
"config",
"file",
"option",
"if",
"not",
"overloaded",
"by",
"the",
"command",
"line",
"."
] |
17ac261168645e2dfe58e439eea4ca2606b8f2af
|
https://github.com/OSSIndex/auditjs/blob/17ac261168645e2dfe58e439eea4ca2606b8f2af/config.js#L199-L203
|
19,958
|
nearform/node-clinic-flame
|
visualizer/no-data-node.js
|
getNoDataNode
|
function getNoDataNode () {
return {
category: 'none', // Used to distinguish fake nodes like this from real ones
children: [],
functionName: 'No data.',
fileName: 'Nothing to show currently.',
id: null, // Don't show any id in the url hash
name: '',
onStackTop: {
asViewed: 0,
base: 0,
rootFromMean: 0
},
type: 'no-data', // Used for this node specifically, indicating no visible data
areaText: 'No frames are visible', // Trailing '.' is added in info-box.js
getNodeRect: function () {
return {
x: 0,
y: 0,
width: 0,
height: 0
}
}
}
}
|
javascript
|
function getNoDataNode () {
return {
category: 'none', // Used to distinguish fake nodes like this from real ones
children: [],
functionName: 'No data.',
fileName: 'Nothing to show currently.',
id: null, // Don't show any id in the url hash
name: '',
onStackTop: {
asViewed: 0,
base: 0,
rootFromMean: 0
},
type: 'no-data', // Used for this node specifically, indicating no visible data
areaText: 'No frames are visible', // Trailing '.' is added in info-box.js
getNodeRect: function () {
return {
x: 0,
y: 0,
width: 0,
height: 0
}
}
}
}
|
[
"function",
"getNoDataNode",
"(",
")",
"{",
"return",
"{",
"category",
":",
"'none'",
",",
"// Used to distinguish fake nodes like this from real ones",
"children",
":",
"[",
"]",
",",
"functionName",
":",
"'No data.'",
",",
"fileName",
":",
"'Nothing to show currently.'",
",",
"id",
":",
"null",
",",
"// Don't show any id in the url hash",
"name",
":",
"''",
",",
"onStackTop",
":",
"{",
"asViewed",
":",
"0",
",",
"base",
":",
"0",
",",
"rootFromMean",
":",
"0",
"}",
",",
"type",
":",
"'no-data'",
",",
"// Used for this node specifically, indicating no visible data",
"areaText",
":",
"'No frames are visible'",
",",
"// Trailing '.' is added in info-box.js",
"getNodeRect",
":",
"function",
"(",
")",
"{",
"return",
"{",
"x",
":",
"0",
",",
"y",
":",
"0",
",",
"width",
":",
"0",
",",
"height",
":",
"0",
"}",
"}",
"}",
"}"
] |
Recreate the object every time it is needed so the caller can change properties without mutating the original.
|
[
"Recreate",
"the",
"object",
"every",
"time",
"it",
"is",
"needed",
"so",
"the",
"caller",
"can",
"change",
"properties",
"without",
"mutating",
"the",
"original",
"."
] |
0d70eb42980c5bc536c9f7aff3058a6448b4627a
|
https://github.com/nearform/node-clinic-flame/blob/0d70eb42980c5bc536c9f7aff3058a6448b4627a/visualizer/no-data-node.js#L5-L30
|
19,959
|
nearform/node-clinic-flame
|
analysis/code-areas.js
|
toCodeAreaChildren
|
function toCodeAreaChildren (set) {
return Array.from(set, (id) => {
return { id }
}).sort(sorter)
function sorter (a, b) {
return a.id.localeCompare(b.id)
}
}
|
javascript
|
function toCodeAreaChildren (set) {
return Array.from(set, (id) => {
return { id }
}).sort(sorter)
function sorter (a, b) {
return a.id.localeCompare(b.id)
}
}
|
[
"function",
"toCodeAreaChildren",
"(",
"set",
")",
"{",
"return",
"Array",
".",
"from",
"(",
"set",
",",
"(",
"id",
")",
"=>",
"{",
"return",
"{",
"id",
"}",
"}",
")",
".",
"sort",
"(",
"sorter",
")",
"function",
"sorter",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"id",
".",
"localeCompare",
"(",
"b",
".",
"id",
")",
"}",
"}"
] |
Turn a Set of code area names into a sorted list of code area objects. This sorts by name right now, just to have a consistent output, but could use eg. the heat of the area in the future.
|
[
"Turn",
"a",
"Set",
"of",
"code",
"area",
"names",
"into",
"a",
"sorted",
"list",
"of",
"code",
"area",
"objects",
".",
"This",
"sorts",
"by",
"name",
"right",
"now",
"just",
"to",
"have",
"a",
"consistent",
"output",
"but",
"could",
"use",
"eg",
".",
"the",
"heat",
"of",
"the",
"area",
"in",
"the",
"future",
"."
] |
0d70eb42980c5bc536c9f7aff3058a6448b4627a
|
https://github.com/nearform/node-clinic-flame/blob/0d70eb42980c5bc536c9f7aff3058a6448b4627a/analysis/code-areas.js#L6-L14
|
19,960
|
xkeshi/vue-barcode
|
dist/vue-barcode.common.js
|
autoSelectFromAB
|
function autoSelectFromAB(string, isA) {
var ranges = isA ? A_CHARS : B_CHARS;
var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)'));
if (untilC) {
return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));
}
var chars = string.match(new RegExp('^' + ranges + '+'))[0];
if (chars.length === string.length) {
return string;
}
return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA);
}
|
javascript
|
function autoSelectFromAB(string, isA) {
var ranges = isA ? A_CHARS : B_CHARS;
var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)'));
if (untilC) {
return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));
}
var chars = string.match(new RegExp('^' + ranges + '+'))[0];
if (chars.length === string.length) {
return string;
}
return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA);
}
|
[
"function",
"autoSelectFromAB",
"(",
"string",
",",
"isA",
")",
"{",
"var",
"ranges",
"=",
"isA",
"?",
"A_CHARS",
":",
"B_CHARS",
";",
"var",
"untilC",
"=",
"string",
".",
"match",
"(",
"new",
"RegExp",
"(",
"'^('",
"+",
"ranges",
"+",
"'+?)(([0-9]{2}){2,})([^0-9]|$)'",
")",
")",
";",
"if",
"(",
"untilC",
")",
"{",
"return",
"untilC",
"[",
"1",
"]",
"+",
"String",
".",
"fromCharCode",
"(",
"204",
")",
"+",
"autoSelectFromC",
"(",
"string",
".",
"substring",
"(",
"untilC",
"[",
"1",
"]",
".",
"length",
")",
")",
";",
"}",
"var",
"chars",
"=",
"string",
".",
"match",
"(",
"new",
"RegExp",
"(",
"'^'",
"+",
"ranges",
"+",
"'+'",
")",
")",
"[",
"0",
"]",
";",
"if",
"(",
"chars",
".",
"length",
"===",
"string",
".",
"length",
")",
"{",
"return",
"string",
";",
"}",
"return",
"chars",
"+",
"String",
".",
"fromCharCode",
"(",
"isA",
"?",
"205",
":",
"206",
")",
"+",
"autoSelectFromAB",
"(",
"string",
".",
"substring",
"(",
"chars",
".",
"length",
")",
",",
"!",
"isA",
")",
";",
"}"
] |
CODE128A or CODE128B
|
[
"CODE128A",
"or",
"CODE128B"
] |
c2b03914a9604df607edcfd72c4d77eaf41ff7f4
|
https://github.com/xkeshi/vue-barcode/blob/c2b03914a9604df607edcfd72c4d77eaf41ff7f4/dist/vue-barcode.common.js#L415-L430
|
19,961
|
xkeshi/vue-barcode
|
dist/vue-barcode.common.js
|
encode
|
function encode(data, structure, separator) {
var encoded = data.split('').map(function (val, idx) {
return BINARIES[structure[idx]];
}).map(function (val, idx) {
return val ? val[data[idx]] : '';
});
if (separator) {
var last = data.length - 1;
encoded = encoded.map(function (val, idx) {
return idx < last ? val + separator : val;
});
}
return encoded.join('');
}
|
javascript
|
function encode(data, structure, separator) {
var encoded = data.split('').map(function (val, idx) {
return BINARIES[structure[idx]];
}).map(function (val, idx) {
return val ? val[data[idx]] : '';
});
if (separator) {
var last = data.length - 1;
encoded = encoded.map(function (val, idx) {
return idx < last ? val + separator : val;
});
}
return encoded.join('');
}
|
[
"function",
"encode",
"(",
"data",
",",
"structure",
",",
"separator",
")",
"{",
"var",
"encoded",
"=",
"data",
".",
"split",
"(",
"''",
")",
".",
"map",
"(",
"function",
"(",
"val",
",",
"idx",
")",
"{",
"return",
"BINARIES",
"[",
"structure",
"[",
"idx",
"]",
"]",
";",
"}",
")",
".",
"map",
"(",
"function",
"(",
"val",
",",
"idx",
")",
"{",
"return",
"val",
"?",
"val",
"[",
"data",
"[",
"idx",
"]",
"]",
":",
"''",
";",
"}",
")",
";",
"if",
"(",
"separator",
")",
"{",
"var",
"last",
"=",
"data",
".",
"length",
"-",
"1",
";",
"encoded",
"=",
"encoded",
".",
"map",
"(",
"function",
"(",
"val",
",",
"idx",
")",
"{",
"return",
"idx",
"<",
"last",
"?",
"val",
"+",
"separator",
":",
"val",
";",
"}",
")",
";",
"}",
"return",
"encoded",
".",
"join",
"(",
"''",
")",
";",
"}"
] |
Encode data string
|
[
"Encode",
"data",
"string"
] |
c2b03914a9604df607edcfd72c4d77eaf41ff7f4
|
https://github.com/xkeshi/vue-barcode/blob/c2b03914a9604df607edcfd72c4d77eaf41ff7f4/dist/vue-barcode.common.js#L564-L579
|
19,962
|
xkeshi/vue-barcode
|
dist/vue-barcode.common.js
|
checksum$4
|
function checksum$4(data) {
var result = 0;
for (var i = 0; i < 13; i++) {
result += parseInt(data[i]) * (3 - i % 2 * 2);
}
return Math.ceil(result / 10) * 10 - result;
}
|
javascript
|
function checksum$4(data) {
var result = 0;
for (var i = 0; i < 13; i++) {
result += parseInt(data[i]) * (3 - i % 2 * 2);
}
return Math.ceil(result / 10) * 10 - result;
}
|
[
"function",
"checksum$4",
"(",
"data",
")",
"{",
"var",
"result",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"13",
";",
"i",
"++",
")",
"{",
"result",
"+=",
"parseInt",
"(",
"data",
"[",
"i",
"]",
")",
"*",
"(",
"3",
"-",
"i",
"%",
"2",
"*",
"2",
")",
";",
"}",
"return",
"Math",
".",
"ceil",
"(",
"result",
"/",
"10",
")",
"*",
"10",
"-",
"result",
";",
"}"
] |
Calulate the checksum digit
|
[
"Calulate",
"the",
"checksum",
"digit"
] |
c2b03914a9604df607edcfd72c4d77eaf41ff7f4
|
https://github.com/xkeshi/vue-barcode/blob/c2b03914a9604df607edcfd72c4d77eaf41ff7f4/dist/vue-barcode.common.js#L1235-L1243
|
19,963
|
xkeshi/vue-barcode
|
dist/vue-barcode.common.js
|
JsBarcode
|
function JsBarcode(element, text, options) {
var api = new API();
if (typeof element === "undefined") {
throw Error("No element to render on was provided.");
}
// Variables that will be pased through the API calls
api._renderProperties = getRenderProperties(element);
api._encodings = [];
api._options = defaults$1;
api._errorHandler = new ErrorHandler(api);
// If text is set, use the simple syntax (render the barcode directly)
if (typeof text !== "undefined") {
options = options || {};
if (!options.format) {
options.format = autoSelectBarcode();
}
api.options(options)[options.format](text, options).render();
}
return api;
}
|
javascript
|
function JsBarcode(element, text, options) {
var api = new API();
if (typeof element === "undefined") {
throw Error("No element to render on was provided.");
}
// Variables that will be pased through the API calls
api._renderProperties = getRenderProperties(element);
api._encodings = [];
api._options = defaults$1;
api._errorHandler = new ErrorHandler(api);
// If text is set, use the simple syntax (render the barcode directly)
if (typeof text !== "undefined") {
options = options || {};
if (!options.format) {
options.format = autoSelectBarcode();
}
api.options(options)[options.format](text, options).render();
}
return api;
}
|
[
"function",
"JsBarcode",
"(",
"element",
",",
"text",
",",
"options",
")",
"{",
"var",
"api",
"=",
"new",
"API",
"(",
")",
";",
"if",
"(",
"typeof",
"element",
"===",
"\"undefined\"",
")",
"{",
"throw",
"Error",
"(",
"\"No element to render on was provided.\"",
")",
";",
"}",
"// Variables that will be pased through the API calls",
"api",
".",
"_renderProperties",
"=",
"getRenderProperties",
"(",
"element",
")",
";",
"api",
".",
"_encodings",
"=",
"[",
"]",
";",
"api",
".",
"_options",
"=",
"defaults$1",
";",
"api",
".",
"_errorHandler",
"=",
"new",
"ErrorHandler",
"(",
"api",
")",
";",
"// If text is set, use the simple syntax (render the barcode directly)",
"if",
"(",
"typeof",
"text",
"!==",
"\"undefined\"",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"options",
".",
"format",
")",
"{",
"options",
".",
"format",
"=",
"autoSelectBarcode",
"(",
")",
";",
"}",
"api",
".",
"options",
"(",
"options",
")",
"[",
"options",
".",
"format",
"]",
"(",
"text",
",",
"options",
")",
".",
"render",
"(",
")",
";",
"}",
"return",
"api",
";",
"}"
] |
The first call of the library API Will return an object with all barcodes calls and the data that is used by the renderers
|
[
"The",
"first",
"call",
"of",
"the",
"library",
"API",
"Will",
"return",
"an",
"object",
"with",
"all",
"barcodes",
"calls",
"and",
"the",
"data",
"that",
"is",
"used",
"by",
"the",
"renderers"
] |
c2b03914a9604df607edcfd72c4d77eaf41ff7f4
|
https://github.com/xkeshi/vue-barcode/blob/c2b03914a9604df607edcfd72c4d77eaf41ff7f4/dist/vue-barcode.common.js#L2297-L2322
|
19,964
|
xkeshi/vue-barcode
|
dist/vue-barcode.common.js
|
render
|
function render(renderProperties, encodings, options) {
encodings = linearizeEncodings(encodings);
for (var i = 0; i < encodings.length; i++) {
encodings[i].options = merge(options, encodings[i].options);
fixOptions(encodings[i].options);
}
fixOptions(options);
var Renderer = renderProperties.renderer;
var renderer = new Renderer(renderProperties.element, encodings, options);
renderer.render();
if (renderProperties.afterRender) {
renderProperties.afterRender();
}
}
|
javascript
|
function render(renderProperties, encodings, options) {
encodings = linearizeEncodings(encodings);
for (var i = 0; i < encodings.length; i++) {
encodings[i].options = merge(options, encodings[i].options);
fixOptions(encodings[i].options);
}
fixOptions(options);
var Renderer = renderProperties.renderer;
var renderer = new Renderer(renderProperties.element, encodings, options);
renderer.render();
if (renderProperties.afterRender) {
renderProperties.afterRender();
}
}
|
[
"function",
"render",
"(",
"renderProperties",
",",
"encodings",
",",
"options",
")",
"{",
"encodings",
"=",
"linearizeEncodings",
"(",
"encodings",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"encodings",
".",
"length",
";",
"i",
"++",
")",
"{",
"encodings",
"[",
"i",
"]",
".",
"options",
"=",
"merge",
"(",
"options",
",",
"encodings",
"[",
"i",
"]",
".",
"options",
")",
";",
"fixOptions",
"(",
"encodings",
"[",
"i",
"]",
".",
"options",
")",
";",
"}",
"fixOptions",
"(",
"options",
")",
";",
"var",
"Renderer",
"=",
"renderProperties",
".",
"renderer",
";",
"var",
"renderer",
"=",
"new",
"Renderer",
"(",
"renderProperties",
".",
"element",
",",
"encodings",
",",
"options",
")",
";",
"renderer",
".",
"render",
"(",
")",
";",
"if",
"(",
"renderProperties",
".",
"afterRender",
")",
"{",
"renderProperties",
".",
"afterRender",
"(",
")",
";",
"}",
"}"
] |
Prepares the encodings and calls the renderer
|
[
"Prepares",
"the",
"encodings",
"and",
"calls",
"the",
"renderer"
] |
c2b03914a9604df607edcfd72c4d77eaf41ff7f4
|
https://github.com/xkeshi/vue-barcode/blob/c2b03914a9604df607edcfd72c4d77eaf41ff7f4/dist/vue-barcode.common.js#L2457-L2474
|
19,965
|
thlorenz/cardinal
|
settings.js
|
resolveTheme
|
function resolveTheme(home_) {
var themePath
var settings = getSettings(home_)
if (!settings || !settings.theme) return undefined
try {
// allow specifying just the name of a built-in theme or a full path to a custom theme
themePath = utl.isPath(settings.theme) ? settings.theme : path.join(__dirname, 'themes', settings.theme)
return require(themePath)
} catch (e) {
// Specified theme path is invalid
console.error(e)
return undefined
}
}
|
javascript
|
function resolveTheme(home_) {
var themePath
var settings = getSettings(home_)
if (!settings || !settings.theme) return undefined
try {
// allow specifying just the name of a built-in theme or a full path to a custom theme
themePath = utl.isPath(settings.theme) ? settings.theme : path.join(__dirname, 'themes', settings.theme)
return require(themePath)
} catch (e) {
// Specified theme path is invalid
console.error(e)
return undefined
}
}
|
[
"function",
"resolveTheme",
"(",
"home_",
")",
"{",
"var",
"themePath",
"var",
"settings",
"=",
"getSettings",
"(",
"home_",
")",
"if",
"(",
"!",
"settings",
"||",
"!",
"settings",
".",
"theme",
")",
"return",
"undefined",
"try",
"{",
"// allow specifying just the name of a built-in theme or a full path to a custom theme",
"themePath",
"=",
"utl",
".",
"isPath",
"(",
"settings",
".",
"theme",
")",
"?",
"settings",
".",
"theme",
":",
"path",
".",
"join",
"(",
"__dirname",
",",
"'themes'",
",",
"settings",
".",
"theme",
")",
"return",
"require",
"(",
"themePath",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"// Specified theme path is invalid",
"console",
".",
"error",
"(",
"e",
")",
"return",
"undefined",
"}",
"}"
] |
home_ mainly to be used during tests Resolves the preferred theme from the .cardinalrc found in the HOME directory If it couldn't be resolved, undefined is returned
|
[
"home_",
"mainly",
"to",
"be",
"used",
"during",
"tests",
"Resolves",
"the",
"preferred",
"theme",
"from",
"the",
".",
"cardinalrc",
"found",
"in",
"the",
"HOME",
"directory",
"If",
"it",
"couldn",
"t",
"be",
"resolved",
"undefined",
"is",
"returned"
] |
c407ebe9c16122025488313fb1b020e62c0046ef
|
https://github.com/thlorenz/cardinal/blob/c407ebe9c16122025488313fb1b020e62c0046ef/settings.js#L31-L47
|
19,966
|
trayio/threadneedle
|
lib/addMethod/addMethodREST.js
|
afterHeadersResolve
|
function afterHeadersResolve (body, result) {
logger.info(methodName+': running `afterHeaders` hook');
globalize.afterHeaders.call(threadneedle, config, null, body, params, result.response)
.done(
function (headers) {
resolve(formatResponse(headers, body));
},
function (error) {
reject(formatResponse({}, error));
}
);
}
|
javascript
|
function afterHeadersResolve (body, result) {
logger.info(methodName+': running `afterHeaders` hook');
globalize.afterHeaders.call(threadneedle, config, null, body, params, result.response)
.done(
function (headers) {
resolve(formatResponse(headers, body));
},
function (error) {
reject(formatResponse({}, error));
}
);
}
|
[
"function",
"afterHeadersResolve",
"(",
"body",
",",
"result",
")",
"{",
"logger",
".",
"info",
"(",
"methodName",
"+",
"': running `afterHeaders` hook'",
")",
";",
"globalize",
".",
"afterHeaders",
".",
"call",
"(",
"threadneedle",
",",
"config",
",",
"null",
",",
"body",
",",
"params",
",",
"result",
".",
"response",
")",
".",
"done",
"(",
"function",
"(",
"headers",
")",
"{",
"resolve",
"(",
"formatResponse",
"(",
"headers",
",",
"body",
")",
")",
";",
"}",
",",
"function",
"(",
"error",
")",
"{",
"reject",
"(",
"formatResponse",
"(",
"{",
"}",
",",
"error",
")",
")",
";",
"}",
")",
";",
"}"
] |
Handle afterHeader for resolving
|
[
"Handle",
"afterHeader",
"for",
"resolving"
] |
5deabeb5ee2f5df3d124d8f159207520bedb170c
|
https://github.com/trayio/threadneedle/blob/5deabeb5ee2f5df3d124d8f159207520bedb170c/lib/addMethod/addMethodREST.js#L59-L73
|
19,967
|
trayio/threadneedle
|
lib/addMethod/addMethodREST.js
|
afterHeadersReject
|
function afterHeadersReject (error, payload, response) {
logger.info(methodName+': running `afterHeaders` hook');
globalize.afterHeaders.call(threadneedle, config, error, payload, params, response)
.done(
function (headers) {
reject(formatResponse(headers, error));
},
function (err) {
reject(formatResponse({}, err || error));
}
);
}
|
javascript
|
function afterHeadersReject (error, payload, response) {
logger.info(methodName+': running `afterHeaders` hook');
globalize.afterHeaders.call(threadneedle, config, error, payload, params, response)
.done(
function (headers) {
reject(formatResponse(headers, error));
},
function (err) {
reject(formatResponse({}, err || error));
}
);
}
|
[
"function",
"afterHeadersReject",
"(",
"error",
",",
"payload",
",",
"response",
")",
"{",
"logger",
".",
"info",
"(",
"methodName",
"+",
"': running `afterHeaders` hook'",
")",
";",
"globalize",
".",
"afterHeaders",
".",
"call",
"(",
"threadneedle",
",",
"config",
",",
"error",
",",
"payload",
",",
"params",
",",
"response",
")",
".",
"done",
"(",
"function",
"(",
"headers",
")",
"{",
"reject",
"(",
"formatResponse",
"(",
"headers",
",",
"error",
")",
")",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"reject",
"(",
"formatResponse",
"(",
"{",
"}",
",",
"err",
"||",
"error",
")",
")",
";",
"}",
")",
";",
"}"
] |
Handle afterHeader for rejecting
|
[
"Handle",
"afterHeader",
"for",
"rejecting"
] |
5deabeb5ee2f5df3d124d8f159207520bedb170c
|
https://github.com/trayio/threadneedle/blob/5deabeb5ee2f5df3d124d8f159207520bedb170c/lib/addMethod/addMethodREST.js#L76-L90
|
19,968
|
emberfeather/less.js-middleware
|
lib/middleware.js
|
function(path, next) {
var nodes = lessFiles[path].imports;
if (!nodes || !nodes.length) {
return next();
}
var pending = nodes.length;
var changed = [];
nodes.forEach(function(imported){
fs.stat(imported.path, function(err, stat) {
// error or newer mtime
if (err || !imported.mtime || stat.mtime > imported.mtime) {
changed.push(imported.path);
}
--pending || next(changed);
});
});
}
|
javascript
|
function(path, next) {
var nodes = lessFiles[path].imports;
if (!nodes || !nodes.length) {
return next();
}
var pending = nodes.length;
var changed = [];
nodes.forEach(function(imported){
fs.stat(imported.path, function(err, stat) {
// error or newer mtime
if (err || !imported.mtime || stat.mtime > imported.mtime) {
changed.push(imported.path);
}
--pending || next(changed);
});
});
}
|
[
"function",
"(",
"path",
",",
"next",
")",
"{",
"var",
"nodes",
"=",
"lessFiles",
"[",
"path",
"]",
".",
"imports",
";",
"if",
"(",
"!",
"nodes",
"||",
"!",
"nodes",
".",
"length",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
"var",
"pending",
"=",
"nodes",
".",
"length",
";",
"var",
"changed",
"=",
"[",
"]",
";",
"nodes",
".",
"forEach",
"(",
"function",
"(",
"imported",
")",
"{",
"fs",
".",
"stat",
"(",
"imported",
".",
"path",
",",
"function",
"(",
"err",
",",
"stat",
")",
"{",
"// error or newer mtime",
"if",
"(",
"err",
"||",
"!",
"imported",
".",
"mtime",
"||",
"stat",
".",
"mtime",
">",
"imported",
".",
"mtime",
")",
"{",
"changed",
".",
"push",
"(",
"imported",
".",
"path",
")",
";",
"}",
"--",
"pending",
"||",
"next",
"(",
"changed",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Check imports for changes.
|
[
"Check",
"imports",
"for",
"changes",
"."
] |
a9e09472681c83df468effd6378b2d87e3e2c09b
|
https://github.com/emberfeather/less.js-middleware/blob/a9e09472681c83df468effd6378b2d87e3e2c09b/lib/middleware.js#L25-L45
|
|
19,969
|
css-modules/css-modulesify
|
index.js
|
getPlugins
|
function getPlugins (options) {
var plugins = options.use || options.u;
if (!plugins) {
plugins = getDefaultPlugins(options);
}
else {
if (typeof plugins === 'string') {
plugins = [plugins];
}
}
var postcssBefore = options.postcssBefore || options.before || [];
var postcssAfter = options.postcssAfter || options.after || [];
plugins = (Array.isArray(postcssBefore) ? postcssBefore : [postcssBefore]).concat(plugins).concat(postcssAfter);
// load plugins by name (if a string is used)
return plugins.map(function requirePlugin (name) {
// assume not strings are already required plugins
if (typeof name !== 'string') {
return name;
}
var plugin = module.parent.require(name);
// custom scoped name generation
if (name === 'postcss-modules-scope') {
options[name] = options[name] || {};
if (!options[name].generateScopedName) {
options[name].generateScopedName = generateLongName;
}
}
if (name in options) {
plugin = plugin(options[name]);
}
else {
plugin = plugin.postcss || plugin();
}
return plugin;
});
}
|
javascript
|
function getPlugins (options) {
var plugins = options.use || options.u;
if (!plugins) {
plugins = getDefaultPlugins(options);
}
else {
if (typeof plugins === 'string') {
plugins = [plugins];
}
}
var postcssBefore = options.postcssBefore || options.before || [];
var postcssAfter = options.postcssAfter || options.after || [];
plugins = (Array.isArray(postcssBefore) ? postcssBefore : [postcssBefore]).concat(plugins).concat(postcssAfter);
// load plugins by name (if a string is used)
return plugins.map(function requirePlugin (name) {
// assume not strings are already required plugins
if (typeof name !== 'string') {
return name;
}
var plugin = module.parent.require(name);
// custom scoped name generation
if (name === 'postcss-modules-scope') {
options[name] = options[name] || {};
if (!options[name].generateScopedName) {
options[name].generateScopedName = generateLongName;
}
}
if (name in options) {
plugin = plugin(options[name]);
}
else {
plugin = plugin.postcss || plugin();
}
return plugin;
});
}
|
[
"function",
"getPlugins",
"(",
"options",
")",
"{",
"var",
"plugins",
"=",
"options",
".",
"use",
"||",
"options",
".",
"u",
";",
"if",
"(",
"!",
"plugins",
")",
"{",
"plugins",
"=",
"getDefaultPlugins",
"(",
"options",
")",
";",
"}",
"else",
"{",
"if",
"(",
"typeof",
"plugins",
"===",
"'string'",
")",
"{",
"plugins",
"=",
"[",
"plugins",
"]",
";",
"}",
"}",
"var",
"postcssBefore",
"=",
"options",
".",
"postcssBefore",
"||",
"options",
".",
"before",
"||",
"[",
"]",
";",
"var",
"postcssAfter",
"=",
"options",
".",
"postcssAfter",
"||",
"options",
".",
"after",
"||",
"[",
"]",
";",
"plugins",
"=",
"(",
"Array",
".",
"isArray",
"(",
"postcssBefore",
")",
"?",
"postcssBefore",
":",
"[",
"postcssBefore",
"]",
")",
".",
"concat",
"(",
"plugins",
")",
".",
"concat",
"(",
"postcssAfter",
")",
";",
"// load plugins by name (if a string is used)",
"return",
"plugins",
".",
"map",
"(",
"function",
"requirePlugin",
"(",
"name",
")",
"{",
"// assume not strings are already required plugins",
"if",
"(",
"typeof",
"name",
"!==",
"'string'",
")",
"{",
"return",
"name",
";",
"}",
"var",
"plugin",
"=",
"module",
".",
"parent",
".",
"require",
"(",
"name",
")",
";",
"// custom scoped name generation",
"if",
"(",
"name",
"===",
"'postcss-modules-scope'",
")",
"{",
"options",
"[",
"name",
"]",
"=",
"options",
"[",
"name",
"]",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"options",
"[",
"name",
"]",
".",
"generateScopedName",
")",
"{",
"options",
"[",
"name",
"]",
".",
"generateScopedName",
"=",
"generateLongName",
";",
"}",
"}",
"if",
"(",
"name",
"in",
"options",
")",
"{",
"plugin",
"=",
"plugin",
"(",
"options",
"[",
"name",
"]",
")",
";",
"}",
"else",
"{",
"plugin",
"=",
"plugin",
".",
"postcss",
"||",
"plugin",
"(",
")",
";",
"}",
"return",
"plugin",
";",
"}",
")",
";",
"}"
] |
PostCSS plugins passed to FileSystemLoader
|
[
"PostCSS",
"plugins",
"passed",
"to",
"FileSystemLoader"
] |
bf1fb9a60ba5c5cc38ba31dbcd18144ca0413bee
|
https://github.com/css-modules/css-modulesify/blob/bf1fb9a60ba5c5cc38ba31dbcd18144ca0413bee/index.js#L78-L119
|
19,970
|
jacobrask/styledocco
|
share/docs.previews.js
|
function(el) {
var mirrorEl = document.createElement('div');
mirrorEl.className = 'preview-code';
mirrorEl.style.position = 'absolute';
mirrorEl.style.left = '-9999px';
bodyEl.appendChild(mirrorEl);
var maxHeight = parseInt(
window.getComputedStyle(el).getPropertyValue('max-height'),
10);
var codeDidChange = function(ev) {
mirrorEl.textContent = this.value + '\n';
var height = mirrorEl.offsetHeight + 2; // Account for borders.
if (height >= maxHeight) {
this.style.overflow = 'auto';
} else {
this.style.overflow = 'hidden';
}
this.style.height = (mirrorEl.offsetHeight + 2) + 'px';
};
el.addEventListener('keypress', codeDidChange);
el.addEventListener('keyup', codeDidChange);
codeDidChange.call(el);
}
|
javascript
|
function(el) {
var mirrorEl = document.createElement('div');
mirrorEl.className = 'preview-code';
mirrorEl.style.position = 'absolute';
mirrorEl.style.left = '-9999px';
bodyEl.appendChild(mirrorEl);
var maxHeight = parseInt(
window.getComputedStyle(el).getPropertyValue('max-height'),
10);
var codeDidChange = function(ev) {
mirrorEl.textContent = this.value + '\n';
var height = mirrorEl.offsetHeight + 2; // Account for borders.
if (height >= maxHeight) {
this.style.overflow = 'auto';
} else {
this.style.overflow = 'hidden';
}
this.style.height = (mirrorEl.offsetHeight + 2) + 'px';
};
el.addEventListener('keypress', codeDidChange);
el.addEventListener('keyup', codeDidChange);
codeDidChange.call(el);
}
|
[
"function",
"(",
"el",
")",
"{",
"var",
"mirrorEl",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"mirrorEl",
".",
"className",
"=",
"'preview-code'",
";",
"mirrorEl",
".",
"style",
".",
"position",
"=",
"'absolute'",
";",
"mirrorEl",
".",
"style",
".",
"left",
"=",
"'-9999px'",
";",
"bodyEl",
".",
"appendChild",
"(",
"mirrorEl",
")",
";",
"var",
"maxHeight",
"=",
"parseInt",
"(",
"window",
".",
"getComputedStyle",
"(",
"el",
")",
".",
"getPropertyValue",
"(",
"'max-height'",
")",
",",
"10",
")",
";",
"var",
"codeDidChange",
"=",
"function",
"(",
"ev",
")",
"{",
"mirrorEl",
".",
"textContent",
"=",
"this",
".",
"value",
"+",
"'\\n'",
";",
"var",
"height",
"=",
"mirrorEl",
".",
"offsetHeight",
"+",
"2",
";",
"// Account for borders.",
"if",
"(",
"height",
">=",
"maxHeight",
")",
"{",
"this",
".",
"style",
".",
"overflow",
"=",
"'auto'",
";",
"}",
"else",
"{",
"this",
".",
"style",
".",
"overflow",
"=",
"'hidden'",
";",
"}",
"this",
".",
"style",
".",
"height",
"=",
"(",
"mirrorEl",
".",
"offsetHeight",
"+",
"2",
")",
"+",
"'px'",
";",
"}",
";",
"el",
".",
"addEventListener",
"(",
"'keypress'",
",",
"codeDidChange",
")",
";",
"el",
".",
"addEventListener",
"(",
"'keyup'",
",",
"codeDidChange",
")",
";",
"codeDidChange",
".",
"call",
"(",
"el",
")",
";",
"}"
] |
Add an element with the same styles and content as the textarea to calculate the height of the textarea content.
|
[
"Add",
"an",
"element",
"with",
"the",
"same",
"styles",
"and",
"content",
"as",
"the",
"textarea",
"to",
"calculate",
"the",
"height",
"of",
"the",
"textarea",
"content",
"."
] |
9f12e71a02c5193ed0427aecba7929b230cf0975
|
https://github.com/jacobrask/styledocco/blob/9f12e71a02c5193ed0427aecba7929b230cf0975/share/docs.previews.js#L141-L163
|
|
19,971
|
jacobrask/styledocco
|
share/docs.previews.js
|
function(width) {
document.cookie = 'preview-width=' + width;
forEach(resizeableEls, function(el) {
if (width === 'auto') width = el.parentNode.offsetWidth;
el.style.width = width + 'px';
// TODO: Add CSS transitions and update height after `transitionend` event
postMessage(el.getElementsByTagName('iframe')[0], 'getHeight');
});
}
|
javascript
|
function(width) {
document.cookie = 'preview-width=' + width;
forEach(resizeableEls, function(el) {
if (width === 'auto') width = el.parentNode.offsetWidth;
el.style.width = width + 'px';
// TODO: Add CSS transitions and update height after `transitionend` event
postMessage(el.getElementsByTagName('iframe')[0], 'getHeight');
});
}
|
[
"function",
"(",
"width",
")",
"{",
"document",
".",
"cookie",
"=",
"'preview-width='",
"+",
"width",
";",
"forEach",
"(",
"resizeableEls",
",",
"function",
"(",
"el",
")",
"{",
"if",
"(",
"width",
"===",
"'auto'",
")",
"width",
"=",
"el",
".",
"parentNode",
".",
"offsetWidth",
";",
"el",
".",
"style",
".",
"width",
"=",
"width",
"+",
"'px'",
";",
"// TODO: Add CSS transitions and update height after `transitionend` event",
"postMessage",
"(",
"el",
".",
"getElementsByTagName",
"(",
"'iframe'",
")",
"[",
"0",
"]",
",",
"'getHeight'",
")",
";",
"}",
")",
";",
"}"
] |
`.resizeable` padding
|
[
".",
"resizeable",
"padding"
] |
9f12e71a02c5193ed0427aecba7929b230cf0975
|
https://github.com/jacobrask/styledocco/blob/9f12e71a02c5193ed0427aecba7929b230cf0975/share/docs.previews.js#L169-L177
|
|
19,972
|
sffc/easy-no-password
|
lib/base62.js
|
encode
|
function encode(buf) {
if (buf.length != 8) {
throw new TypeError("Buffer must be length 8");
}
var num = new UInt64(buf.readUInt32BE(4), buf.readUInt32BE(0));
var str = "";
do {
num.div(SIXTY_TWO);
str = CHARS[num.remainder] + str;
} while (num.greaterThan(ZERO));
return str;
}
|
javascript
|
function encode(buf) {
if (buf.length != 8) {
throw new TypeError("Buffer must be length 8");
}
var num = new UInt64(buf.readUInt32BE(4), buf.readUInt32BE(0));
var str = "";
do {
num.div(SIXTY_TWO);
str = CHARS[num.remainder] + str;
} while (num.greaterThan(ZERO));
return str;
}
|
[
"function",
"encode",
"(",
"buf",
")",
"{",
"if",
"(",
"buf",
".",
"length",
"!=",
"8",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"\"Buffer must be length 8\"",
")",
";",
"}",
"var",
"num",
"=",
"new",
"UInt64",
"(",
"buf",
".",
"readUInt32BE",
"(",
"4",
")",
",",
"buf",
".",
"readUInt32BE",
"(",
"0",
")",
")",
";",
"var",
"str",
"=",
"\"\"",
";",
"do",
"{",
"num",
".",
"div",
"(",
"SIXTY_TWO",
")",
";",
"str",
"=",
"CHARS",
"[",
"num",
".",
"remainder",
"]",
"+",
"str",
";",
"}",
"while",
"(",
"num",
".",
"greaterThan",
"(",
"ZERO",
")",
")",
";",
"return",
"str",
";",
"}"
] |
Encodes an 8-byte buffer as base 62.
|
[
"Encodes",
"an",
"8",
"-",
"byte",
"buffer",
"as",
"base",
"62",
"."
] |
29ad932d0d8bd180736b232b87ad6b986a0311ec
|
https://github.com/sffc/easy-no-password/blob/29ad932d0d8bd180736b232b87ad6b986a0311ec/lib/base62.js#L13-L26
|
19,973
|
l20n/l20n.js
|
src/gecko/l20n.js
|
requestBundles
|
function requestBundles(requestedLangs = navigator.languages) {
return L10nRegistry.getResources(requestedLangs, resIds).then(
({bundles}) => bundles.map(
bundle => new ChromeResourceBundle(bundle.locale, bundle.resources)
)
);
}
|
javascript
|
function requestBundles(requestedLangs = navigator.languages) {
return L10nRegistry.getResources(requestedLangs, resIds).then(
({bundles}) => bundles.map(
bundle => new ChromeResourceBundle(bundle.locale, bundle.resources)
)
);
}
|
[
"function",
"requestBundles",
"(",
"requestedLangs",
"=",
"navigator",
".",
"languages",
")",
"{",
"return",
"L10nRegistry",
".",
"getResources",
"(",
"requestedLangs",
",",
"resIds",
")",
".",
"then",
"(",
"(",
"{",
"bundles",
"}",
")",
"=>",
"bundles",
".",
"map",
"(",
"bundle",
"=>",
"new",
"ChromeResourceBundle",
"(",
"bundle",
".",
"locale",
",",
"bundle",
".",
"resources",
")",
")",
")",
";",
"}"
] |
This function is called by `Localization` class to retrieve an array of `ResourceBundle`s. In chrome-privileged setup we use the `L10nRegistry` to get this array.
|
[
"This",
"function",
"is",
"called",
"by",
"Localization",
"class",
"to",
"retrieve",
"an",
"array",
"of",
"ResourceBundle",
"s",
".",
"In",
"chrome",
"-",
"privileged",
"setup",
"we",
"use",
"the",
"L10nRegistry",
"to",
"get",
"this",
"array",
"."
] |
a56dc2ed980db87b45b11021e645009a439a90ec
|
https://github.com/l20n/l20n.js/blob/a56dc2ed980db87b45b11021e645009a439a90ec/src/gecko/l20n.js#L49-L55
|
19,974
|
l20n/l20n.js
|
src/localization.js
|
createHeadContextWith
|
function createHeadContextWith(createContext, bundles) {
const [bundle] = bundles;
if (!bundle) {
return Promise.resolve(null);
}
return bundle.fetch().then(resources => {
const ctx = createContext(bundle.lang);
resources
// Filter out resources which failed to load correctly (e.g. 404).
.filter(res => res !== null)
.forEach(res => ctx.addMessages(res));
// Save the reference to the context.
contexts.set(bundle, ctx);
return ctx;
});
}
|
javascript
|
function createHeadContextWith(createContext, bundles) {
const [bundle] = bundles;
if (!bundle) {
return Promise.resolve(null);
}
return bundle.fetch().then(resources => {
const ctx = createContext(bundle.lang);
resources
// Filter out resources which failed to load correctly (e.g. 404).
.filter(res => res !== null)
.forEach(res => ctx.addMessages(res));
// Save the reference to the context.
contexts.set(bundle, ctx);
return ctx;
});
}
|
[
"function",
"createHeadContextWith",
"(",
"createContext",
",",
"bundles",
")",
"{",
"const",
"[",
"bundle",
"]",
"=",
"bundles",
";",
"if",
"(",
"!",
"bundle",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"null",
")",
";",
"}",
"return",
"bundle",
".",
"fetch",
"(",
")",
".",
"then",
"(",
"resources",
"=>",
"{",
"const",
"ctx",
"=",
"createContext",
"(",
"bundle",
".",
"lang",
")",
";",
"resources",
"// Filter out resources which failed to load correctly (e.g. 404).",
".",
"filter",
"(",
"res",
"=>",
"res",
"!==",
"null",
")",
".",
"forEach",
"(",
"res",
"=>",
"ctx",
".",
"addMessages",
"(",
"res",
")",
")",
";",
"// Save the reference to the context.",
"contexts",
".",
"set",
"(",
"bundle",
",",
"ctx",
")",
";",
"return",
"ctx",
";",
"}",
")",
";",
"}"
] |
Create a `MessageContext` for the first bundle in the fallback chain.
Fetches the bundle's resources and creates a context from them.
@param {Array<ResourceBundle>} bundle
@param {Function} createContext
@returns {Promise<MessageContext>}
@private
|
[
"Create",
"a",
"MessageContext",
"for",
"the",
"first",
"bundle",
"in",
"the",
"fallback",
"chain",
"."
] |
a56dc2ed980db87b45b11021e645009a439a90ec
|
https://github.com/l20n/l20n.js/blob/a56dc2ed980db87b45b11021e645009a439a90ec/src/localization.js#L363-L380
|
19,975
|
l20n/l20n.js
|
src/web/index.js
|
requestBundles
|
function requestBundles(requestedLangs = navigator.languages) {
const newLangs = negotiateLanguages(
requestedLangs, availableLangs, { defaultLocale }
);
const bundles = newLangs.map(
lang => new ResourceBundle(lang, resIds)
);
return Promise.resolve(bundles);
}
|
javascript
|
function requestBundles(requestedLangs = navigator.languages) {
const newLangs = negotiateLanguages(
requestedLangs, availableLangs, { defaultLocale }
);
const bundles = newLangs.map(
lang => new ResourceBundle(lang, resIds)
);
return Promise.resolve(bundles);
}
|
[
"function",
"requestBundles",
"(",
"requestedLangs",
"=",
"navigator",
".",
"languages",
")",
"{",
"const",
"newLangs",
"=",
"negotiateLanguages",
"(",
"requestedLangs",
",",
"availableLangs",
",",
"{",
"defaultLocale",
"}",
")",
";",
"const",
"bundles",
"=",
"newLangs",
".",
"map",
"(",
"lang",
"=>",
"new",
"ResourceBundle",
"(",
"lang",
",",
"resIds",
")",
")",
";",
"return",
"Promise",
".",
"resolve",
"(",
"bundles",
")",
";",
"}"
] |
This function is called by `Localization` class to retrieve an array of `ResourceBundle`s.
|
[
"This",
"function",
"is",
"called",
"by",
"Localization",
"class",
"to",
"retrieve",
"an",
"array",
"of",
"ResourceBundle",
"s",
"."
] |
a56dc2ed980db87b45b11021e645009a439a90ec
|
https://github.com/l20n/l20n.js/blob/a56dc2ed980db87b45b11021e645009a439a90ec/src/web/index.js#L24-L34
|
19,976
|
l20n/l20n.js
|
src/overlay.js
|
isElementAllowed
|
function isElementAllowed(element) {
const allowed = ALLOWED_ELEMENTS[element.namespaceURI];
if (!allowed) {
return false;
}
return allowed.indexOf(element.tagName.toLowerCase()) !== -1;
}
|
javascript
|
function isElementAllowed(element) {
const allowed = ALLOWED_ELEMENTS[element.namespaceURI];
if (!allowed) {
return false;
}
return allowed.indexOf(element.tagName.toLowerCase()) !== -1;
}
|
[
"function",
"isElementAllowed",
"(",
"element",
")",
"{",
"const",
"allowed",
"=",
"ALLOWED_ELEMENTS",
"[",
"element",
".",
"namespaceURI",
"]",
";",
"if",
"(",
"!",
"allowed",
")",
"{",
"return",
"false",
";",
"}",
"return",
"allowed",
".",
"indexOf",
"(",
"element",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
")",
"!==",
"-",
"1",
";",
"}"
] |
Check if element is allowed in the translation.
This method is used by the sanitizer when the translation markup contains
an element which is not present in the source code.
@param {Element} element
@returns {boolean}
@private
|
[
"Check",
"if",
"element",
"is",
"allowed",
"in",
"the",
"translation",
"."
] |
a56dc2ed980db87b45b11021e645009a439a90ec
|
https://github.com/l20n/l20n.js/blob/a56dc2ed980db87b45b11021e645009a439a90ec/src/overlay.js#L154-L161
|
19,977
|
l20n/l20n.js
|
src/overlay.js
|
isAttrAllowed
|
function isAttrAllowed(attr, element) {
const allowed = ALLOWED_ATTRIBUTES[element.namespaceURI];
if (!allowed) {
return false;
}
const attrName = attr.name.toLowerCase();
const elemName = element.tagName.toLowerCase();
// Is it a globally safe attribute?
if (allowed.global.indexOf(attrName) !== -1) {
return true;
}
// Are there no allowed attributes for this element?
if (!allowed[elemName]) {
return false;
}
// Is it allowed on this element?
if (allowed[elemName].indexOf(attrName) !== -1) {
return true;
}
// Special case for value on HTML inputs with type button, reset, submit
if (element.namespaceURI === 'http://www.w3.org/1999/xhtml' &&
elemName === 'input' && attrName === 'value') {
const type = element.type.toLowerCase();
if (type === 'submit' || type === 'button' || type === 'reset') {
return true;
}
}
return false;
}
|
javascript
|
function isAttrAllowed(attr, element) {
const allowed = ALLOWED_ATTRIBUTES[element.namespaceURI];
if (!allowed) {
return false;
}
const attrName = attr.name.toLowerCase();
const elemName = element.tagName.toLowerCase();
// Is it a globally safe attribute?
if (allowed.global.indexOf(attrName) !== -1) {
return true;
}
// Are there no allowed attributes for this element?
if (!allowed[elemName]) {
return false;
}
// Is it allowed on this element?
if (allowed[elemName].indexOf(attrName) !== -1) {
return true;
}
// Special case for value on HTML inputs with type button, reset, submit
if (element.namespaceURI === 'http://www.w3.org/1999/xhtml' &&
elemName === 'input' && attrName === 'value') {
const type = element.type.toLowerCase();
if (type === 'submit' || type === 'button' || type === 'reset') {
return true;
}
}
return false;
}
|
[
"function",
"isAttrAllowed",
"(",
"attr",
",",
"element",
")",
"{",
"const",
"allowed",
"=",
"ALLOWED_ATTRIBUTES",
"[",
"element",
".",
"namespaceURI",
"]",
";",
"if",
"(",
"!",
"allowed",
")",
"{",
"return",
"false",
";",
"}",
"const",
"attrName",
"=",
"attr",
".",
"name",
".",
"toLowerCase",
"(",
")",
";",
"const",
"elemName",
"=",
"element",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
";",
"// Is it a globally safe attribute?",
"if",
"(",
"allowed",
".",
"global",
".",
"indexOf",
"(",
"attrName",
")",
"!==",
"-",
"1",
")",
"{",
"return",
"true",
";",
"}",
"// Are there no allowed attributes for this element?",
"if",
"(",
"!",
"allowed",
"[",
"elemName",
"]",
")",
"{",
"return",
"false",
";",
"}",
"// Is it allowed on this element?",
"if",
"(",
"allowed",
"[",
"elemName",
"]",
".",
"indexOf",
"(",
"attrName",
")",
"!==",
"-",
"1",
")",
"{",
"return",
"true",
";",
"}",
"// Special case for value on HTML inputs with type button, reset, submit",
"if",
"(",
"element",
".",
"namespaceURI",
"===",
"'http://www.w3.org/1999/xhtml'",
"&&",
"elemName",
"===",
"'input'",
"&&",
"attrName",
"===",
"'value'",
")",
"{",
"const",
"type",
"=",
"element",
".",
"type",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"type",
"===",
"'submit'",
"||",
"type",
"===",
"'button'",
"||",
"type",
"===",
"'reset'",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if attribute is allowed for the given element.
This method is used by the sanitizer when the translation markup contains
DOM attributes, or when the translation has traits which map to DOM
attributes.
@param {{name: string}} attr
@param {Element} element
@returns {boolean}
@private
|
[
"Check",
"if",
"attribute",
"is",
"allowed",
"for",
"the",
"given",
"element",
"."
] |
a56dc2ed980db87b45b11021e645009a439a90ec
|
https://github.com/l20n/l20n.js/blob/a56dc2ed980db87b45b11021e645009a439a90ec/src/overlay.js#L175-L209
|
19,978
|
l20n/l20n.js
|
src/overlay.js
|
getIndexOfType
|
function getIndexOfType(element) {
let index = 0;
let child;
while ((child = element.previousElementSibling)) {
if (child.tagName === element.tagName) {
index++;
}
}
return index;
}
|
javascript
|
function getIndexOfType(element) {
let index = 0;
let child;
while ((child = element.previousElementSibling)) {
if (child.tagName === element.tagName) {
index++;
}
}
return index;
}
|
[
"function",
"getIndexOfType",
"(",
"element",
")",
"{",
"let",
"index",
"=",
"0",
";",
"let",
"child",
";",
"while",
"(",
"(",
"child",
"=",
"element",
".",
"previousElementSibling",
")",
")",
"{",
"if",
"(",
"child",
".",
"tagName",
"===",
"element",
".",
"tagName",
")",
"{",
"index",
"++",
";",
"}",
"}",
"return",
"index",
";",
"}"
] |
Get the index of the element among siblings of the same type.
|
[
"Get",
"the",
"index",
"of",
"the",
"element",
"among",
"siblings",
"of",
"the",
"same",
"type",
"."
] |
a56dc2ed980db87b45b11021e645009a439a90ec
|
https://github.com/l20n/l20n.js/blob/a56dc2ed980db87b45b11021e645009a439a90ec/src/overlay.js#L230-L239
|
19,979
|
syntax-tree/mdast-util-to-hast
|
lib/handlers/html.js
|
html
|
function html(h, node) {
return h.dangerous ? h.augment(node, u('raw', node.value)) : null
}
|
javascript
|
function html(h, node) {
return h.dangerous ? h.augment(node, u('raw', node.value)) : null
}
|
[
"function",
"html",
"(",
"h",
",",
"node",
")",
"{",
"return",
"h",
".",
"dangerous",
"?",
"h",
".",
"augment",
"(",
"node",
",",
"u",
"(",
"'raw'",
",",
"node",
".",
"value",
")",
")",
":",
"null",
"}"
] |
Return either a `raw` node, in dangerous mode, or nothing.
|
[
"Return",
"either",
"a",
"raw",
"node",
"in",
"dangerous",
"mode",
"or",
"nothing",
"."
] |
751b54d3d5a0ebe03cc56290abfcbaeeeca3a326
|
https://github.com/syntax-tree/mdast-util-to-hast/blob/751b54d3d5a0ebe03cc56290abfcbaeeeca3a326/lib/handlers/html.js#L8-L10
|
19,980
|
syntax-tree/mdast-util-to-hast
|
lib/wrap.js
|
wrap
|
function wrap(nodes, loose) {
var result = []
var index = -1
var length = nodes.length
if (loose) {
result.push(u('text', '\n'))
}
while (++index < length) {
if (index) {
result.push(u('text', '\n'))
}
result.push(nodes[index])
}
if (loose && nodes.length !== 0) {
result.push(u('text', '\n'))
}
return result
}
|
javascript
|
function wrap(nodes, loose) {
var result = []
var index = -1
var length = nodes.length
if (loose) {
result.push(u('text', '\n'))
}
while (++index < length) {
if (index) {
result.push(u('text', '\n'))
}
result.push(nodes[index])
}
if (loose && nodes.length !== 0) {
result.push(u('text', '\n'))
}
return result
}
|
[
"function",
"wrap",
"(",
"nodes",
",",
"loose",
")",
"{",
"var",
"result",
"=",
"[",
"]",
"var",
"index",
"=",
"-",
"1",
"var",
"length",
"=",
"nodes",
".",
"length",
"if",
"(",
"loose",
")",
"{",
"result",
".",
"push",
"(",
"u",
"(",
"'text'",
",",
"'\\n'",
")",
")",
"}",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"if",
"(",
"index",
")",
"{",
"result",
".",
"push",
"(",
"u",
"(",
"'text'",
",",
"'\\n'",
")",
")",
"}",
"result",
".",
"push",
"(",
"nodes",
"[",
"index",
"]",
")",
"}",
"if",
"(",
"loose",
"&&",
"nodes",
".",
"length",
"!==",
"0",
")",
"{",
"result",
".",
"push",
"(",
"u",
"(",
"'text'",
",",
"'\\n'",
")",
")",
"}",
"return",
"result",
"}"
] |
Wrap `nodes` with newlines between each entry. Optionally adds newlines at the start and end.
|
[
"Wrap",
"nodes",
"with",
"newlines",
"between",
"each",
"entry",
".",
"Optionally",
"adds",
"newlines",
"at",
"the",
"start",
"and",
"end",
"."
] |
751b54d3d5a0ebe03cc56290abfcbaeeeca3a326
|
https://github.com/syntax-tree/mdast-util-to-hast/blob/751b54d3d5a0ebe03cc56290abfcbaeeeca3a326/lib/wrap.js#L9-L31
|
19,981
|
syntax-tree/mdast-util-to-hast
|
lib/one.js
|
unknown
|
function unknown(h, node) {
if (text(node)) {
return h.augment(node, u('text', node.value))
}
return h(node, 'div', all(h, node))
}
|
javascript
|
function unknown(h, node) {
if (text(node)) {
return h.augment(node, u('text', node.value))
}
return h(node, 'div', all(h, node))
}
|
[
"function",
"unknown",
"(",
"h",
",",
"node",
")",
"{",
"if",
"(",
"text",
"(",
"node",
")",
")",
"{",
"return",
"h",
".",
"augment",
"(",
"node",
",",
"u",
"(",
"'text'",
",",
"node",
".",
"value",
")",
")",
"}",
"return",
"h",
"(",
"node",
",",
"'div'",
",",
"all",
"(",
"h",
",",
"node",
")",
")",
"}"
] |
Transform an unknown node.
|
[
"Transform",
"an",
"unknown",
"node",
"."
] |
751b54d3d5a0ebe03cc56290abfcbaeeeca3a326
|
https://github.com/syntax-tree/mdast-util-to-hast/blob/751b54d3d5a0ebe03cc56290abfcbaeeeca3a326/lib/one.js#L11-L17
|
19,982
|
syntax-tree/mdast-util-to-hast
|
lib/one.js
|
one
|
function one(h, node, parent) {
var type = node && node.type
var fn = own.call(h.handlers, type) ? h.handlers[type] : null
// Fail on non-nodes.
if (!type) {
throw new Error('Expected node, got `' + node + '`')
}
return (typeof fn === 'function' ? fn : unknown)(h, node, parent)
}
|
javascript
|
function one(h, node, parent) {
var type = node && node.type
var fn = own.call(h.handlers, type) ? h.handlers[type] : null
// Fail on non-nodes.
if (!type) {
throw new Error('Expected node, got `' + node + '`')
}
return (typeof fn === 'function' ? fn : unknown)(h, node, parent)
}
|
[
"function",
"one",
"(",
"h",
",",
"node",
",",
"parent",
")",
"{",
"var",
"type",
"=",
"node",
"&&",
"node",
".",
"type",
"var",
"fn",
"=",
"own",
".",
"call",
"(",
"h",
".",
"handlers",
",",
"type",
")",
"?",
"h",
".",
"handlers",
"[",
"type",
"]",
":",
"null",
"// Fail on non-nodes.",
"if",
"(",
"!",
"type",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Expected node, got `'",
"+",
"node",
"+",
"'`'",
")",
"}",
"return",
"(",
"typeof",
"fn",
"===",
"'function'",
"?",
"fn",
":",
"unknown",
")",
"(",
"h",
",",
"node",
",",
"parent",
")",
"}"
] |
Visit a node.
|
[
"Visit",
"a",
"node",
"."
] |
751b54d3d5a0ebe03cc56290abfcbaeeeca3a326
|
https://github.com/syntax-tree/mdast-util-to-hast/blob/751b54d3d5a0ebe03cc56290abfcbaeeeca3a326/lib/one.js#L20-L30
|
19,983
|
syntax-tree/mdast-util-to-hast
|
lib/one.js
|
text
|
function text(node) {
var data = node.data || {}
if (
own.call(data, 'hName') ||
own.call(data, 'hProperties') ||
own.call(data, 'hChildren')
) {
return false
}
return 'value' in node
}
|
javascript
|
function text(node) {
var data = node.data || {}
if (
own.call(data, 'hName') ||
own.call(data, 'hProperties') ||
own.call(data, 'hChildren')
) {
return false
}
return 'value' in node
}
|
[
"function",
"text",
"(",
"node",
")",
"{",
"var",
"data",
"=",
"node",
".",
"data",
"||",
"{",
"}",
"if",
"(",
"own",
".",
"call",
"(",
"data",
",",
"'hName'",
")",
"||",
"own",
".",
"call",
"(",
"data",
",",
"'hProperties'",
")",
"||",
"own",
".",
"call",
"(",
"data",
",",
"'hChildren'",
")",
")",
"{",
"return",
"false",
"}",
"return",
"'value'",
"in",
"node",
"}"
] |
Check if the node should be renderered a text node.
|
[
"Check",
"if",
"the",
"node",
"should",
"be",
"renderered",
"a",
"text",
"node",
"."
] |
751b54d3d5a0ebe03cc56290abfcbaeeeca3a326
|
https://github.com/syntax-tree/mdast-util-to-hast/blob/751b54d3d5a0ebe03cc56290abfcbaeeeca3a326/lib/one.js#L33-L45
|
19,984
|
syntax-tree/mdast-util-to-hast
|
lib/index.js
|
factory
|
function factory(tree, options) {
var settings = options || {}
var dangerous = settings.allowDangerousHTML
h.dangerous = dangerous
h.definition = definitions(tree, settings)
h.footnotes = []
h.augment = augment
h.handlers = xtend(handlers, settings.handlers || {})
visit(tree, 'footnoteDefinition', visitor)
return h
// Finalise the created `right`, a hast node, from `left`, an mdast node.
function augment(left, right) {
var data
var ctx
// Handle `data.hName`, `data.hProperties, `hChildren`.
if (left && 'data' in left) {
data = left.data
if (right.type === 'element' && data.hName) {
right.tagName = data.hName
}
if (right.type === 'element' && data.hProperties) {
right.properties = xtend(right.properties, data.hProperties)
}
if (right.children && data.hChildren) {
right.children = data.hChildren
}
}
ctx = left && left.position ? left : {position: left}
if (!generated(ctx)) {
right.position = {
start: position.start(ctx),
end: position.end(ctx)
}
}
return right
}
// Create an element for a `node`.
function h(node, tagName, props, children) {
if (
(children === undefined || children === null) &&
typeof props === 'object' &&
'length' in props
) {
children = props
props = {}
}
return augment(node, {
type: 'element',
tagName: tagName,
properties: props || {},
children: children || []
})
}
function visitor(definition) {
h.footnotes.push(definition)
}
}
|
javascript
|
function factory(tree, options) {
var settings = options || {}
var dangerous = settings.allowDangerousHTML
h.dangerous = dangerous
h.definition = definitions(tree, settings)
h.footnotes = []
h.augment = augment
h.handlers = xtend(handlers, settings.handlers || {})
visit(tree, 'footnoteDefinition', visitor)
return h
// Finalise the created `right`, a hast node, from `left`, an mdast node.
function augment(left, right) {
var data
var ctx
// Handle `data.hName`, `data.hProperties, `hChildren`.
if (left && 'data' in left) {
data = left.data
if (right.type === 'element' && data.hName) {
right.tagName = data.hName
}
if (right.type === 'element' && data.hProperties) {
right.properties = xtend(right.properties, data.hProperties)
}
if (right.children && data.hChildren) {
right.children = data.hChildren
}
}
ctx = left && left.position ? left : {position: left}
if (!generated(ctx)) {
right.position = {
start: position.start(ctx),
end: position.end(ctx)
}
}
return right
}
// Create an element for a `node`.
function h(node, tagName, props, children) {
if (
(children === undefined || children === null) &&
typeof props === 'object' &&
'length' in props
) {
children = props
props = {}
}
return augment(node, {
type: 'element',
tagName: tagName,
properties: props || {},
children: children || []
})
}
function visitor(definition) {
h.footnotes.push(definition)
}
}
|
[
"function",
"factory",
"(",
"tree",
",",
"options",
")",
"{",
"var",
"settings",
"=",
"options",
"||",
"{",
"}",
"var",
"dangerous",
"=",
"settings",
".",
"allowDangerousHTML",
"h",
".",
"dangerous",
"=",
"dangerous",
"h",
".",
"definition",
"=",
"definitions",
"(",
"tree",
",",
"settings",
")",
"h",
".",
"footnotes",
"=",
"[",
"]",
"h",
".",
"augment",
"=",
"augment",
"h",
".",
"handlers",
"=",
"xtend",
"(",
"handlers",
",",
"settings",
".",
"handlers",
"||",
"{",
"}",
")",
"visit",
"(",
"tree",
",",
"'footnoteDefinition'",
",",
"visitor",
")",
"return",
"h",
"// Finalise the created `right`, a hast node, from `left`, an mdast node.",
"function",
"augment",
"(",
"left",
",",
"right",
")",
"{",
"var",
"data",
"var",
"ctx",
"// Handle `data.hName`, `data.hProperties, `hChildren`.",
"if",
"(",
"left",
"&&",
"'data'",
"in",
"left",
")",
"{",
"data",
"=",
"left",
".",
"data",
"if",
"(",
"right",
".",
"type",
"===",
"'element'",
"&&",
"data",
".",
"hName",
")",
"{",
"right",
".",
"tagName",
"=",
"data",
".",
"hName",
"}",
"if",
"(",
"right",
".",
"type",
"===",
"'element'",
"&&",
"data",
".",
"hProperties",
")",
"{",
"right",
".",
"properties",
"=",
"xtend",
"(",
"right",
".",
"properties",
",",
"data",
".",
"hProperties",
")",
"}",
"if",
"(",
"right",
".",
"children",
"&&",
"data",
".",
"hChildren",
")",
"{",
"right",
".",
"children",
"=",
"data",
".",
"hChildren",
"}",
"}",
"ctx",
"=",
"left",
"&&",
"left",
".",
"position",
"?",
"left",
":",
"{",
"position",
":",
"left",
"}",
"if",
"(",
"!",
"generated",
"(",
"ctx",
")",
")",
"{",
"right",
".",
"position",
"=",
"{",
"start",
":",
"position",
".",
"start",
"(",
"ctx",
")",
",",
"end",
":",
"position",
".",
"end",
"(",
"ctx",
")",
"}",
"}",
"return",
"right",
"}",
"// Create an element for a `node`.",
"function",
"h",
"(",
"node",
",",
"tagName",
",",
"props",
",",
"children",
")",
"{",
"if",
"(",
"(",
"children",
"===",
"undefined",
"||",
"children",
"===",
"null",
")",
"&&",
"typeof",
"props",
"===",
"'object'",
"&&",
"'length'",
"in",
"props",
")",
"{",
"children",
"=",
"props",
"props",
"=",
"{",
"}",
"}",
"return",
"augment",
"(",
"node",
",",
"{",
"type",
":",
"'element'",
",",
"tagName",
":",
"tagName",
",",
"properties",
":",
"props",
"||",
"{",
"}",
",",
"children",
":",
"children",
"||",
"[",
"]",
"}",
")",
"}",
"function",
"visitor",
"(",
"definition",
")",
"{",
"h",
".",
"footnotes",
".",
"push",
"(",
"definition",
")",
"}",
"}"
] |
Factory to transform.
|
[
"Factory",
"to",
"transform",
"."
] |
751b54d3d5a0ebe03cc56290abfcbaeeeca3a326
|
https://github.com/syntax-tree/mdast-util-to-hast/blob/751b54d3d5a0ebe03cc56290abfcbaeeeca3a326/lib/index.js#L16-L86
|
19,985
|
syntax-tree/mdast-util-to-hast
|
lib/index.js
|
augment
|
function augment(left, right) {
var data
var ctx
// Handle `data.hName`, `data.hProperties, `hChildren`.
if (left && 'data' in left) {
data = left.data
if (right.type === 'element' && data.hName) {
right.tagName = data.hName
}
if (right.type === 'element' && data.hProperties) {
right.properties = xtend(right.properties, data.hProperties)
}
if (right.children && data.hChildren) {
right.children = data.hChildren
}
}
ctx = left && left.position ? left : {position: left}
if (!generated(ctx)) {
right.position = {
start: position.start(ctx),
end: position.end(ctx)
}
}
return right
}
|
javascript
|
function augment(left, right) {
var data
var ctx
// Handle `data.hName`, `data.hProperties, `hChildren`.
if (left && 'data' in left) {
data = left.data
if (right.type === 'element' && data.hName) {
right.tagName = data.hName
}
if (right.type === 'element' && data.hProperties) {
right.properties = xtend(right.properties, data.hProperties)
}
if (right.children && data.hChildren) {
right.children = data.hChildren
}
}
ctx = left && left.position ? left : {position: left}
if (!generated(ctx)) {
right.position = {
start: position.start(ctx),
end: position.end(ctx)
}
}
return right
}
|
[
"function",
"augment",
"(",
"left",
",",
"right",
")",
"{",
"var",
"data",
"var",
"ctx",
"// Handle `data.hName`, `data.hProperties, `hChildren`.",
"if",
"(",
"left",
"&&",
"'data'",
"in",
"left",
")",
"{",
"data",
"=",
"left",
".",
"data",
"if",
"(",
"right",
".",
"type",
"===",
"'element'",
"&&",
"data",
".",
"hName",
")",
"{",
"right",
".",
"tagName",
"=",
"data",
".",
"hName",
"}",
"if",
"(",
"right",
".",
"type",
"===",
"'element'",
"&&",
"data",
".",
"hProperties",
")",
"{",
"right",
".",
"properties",
"=",
"xtend",
"(",
"right",
".",
"properties",
",",
"data",
".",
"hProperties",
")",
"}",
"if",
"(",
"right",
".",
"children",
"&&",
"data",
".",
"hChildren",
")",
"{",
"right",
".",
"children",
"=",
"data",
".",
"hChildren",
"}",
"}",
"ctx",
"=",
"left",
"&&",
"left",
".",
"position",
"?",
"left",
":",
"{",
"position",
":",
"left",
"}",
"if",
"(",
"!",
"generated",
"(",
"ctx",
")",
")",
"{",
"right",
".",
"position",
"=",
"{",
"start",
":",
"position",
".",
"start",
"(",
"ctx",
")",
",",
"end",
":",
"position",
".",
"end",
"(",
"ctx",
")",
"}",
"}",
"return",
"right",
"}"
] |
Finalise the created `right`, a hast node, from `left`, an mdast node.
|
[
"Finalise",
"the",
"created",
"right",
"a",
"hast",
"node",
"from",
"left",
"an",
"mdast",
"node",
"."
] |
751b54d3d5a0ebe03cc56290abfcbaeeeca3a326
|
https://github.com/syntax-tree/mdast-util-to-hast/blob/751b54d3d5a0ebe03cc56290abfcbaeeeca3a326/lib/index.js#L31-L62
|
19,986
|
syntax-tree/mdast-util-to-hast
|
lib/index.js
|
h
|
function h(node, tagName, props, children) {
if (
(children === undefined || children === null) &&
typeof props === 'object' &&
'length' in props
) {
children = props
props = {}
}
return augment(node, {
type: 'element',
tagName: tagName,
properties: props || {},
children: children || []
})
}
|
javascript
|
function h(node, tagName, props, children) {
if (
(children === undefined || children === null) &&
typeof props === 'object' &&
'length' in props
) {
children = props
props = {}
}
return augment(node, {
type: 'element',
tagName: tagName,
properties: props || {},
children: children || []
})
}
|
[
"function",
"h",
"(",
"node",
",",
"tagName",
",",
"props",
",",
"children",
")",
"{",
"if",
"(",
"(",
"children",
"===",
"undefined",
"||",
"children",
"===",
"null",
")",
"&&",
"typeof",
"props",
"===",
"'object'",
"&&",
"'length'",
"in",
"props",
")",
"{",
"children",
"=",
"props",
"props",
"=",
"{",
"}",
"}",
"return",
"augment",
"(",
"node",
",",
"{",
"type",
":",
"'element'",
",",
"tagName",
":",
"tagName",
",",
"properties",
":",
"props",
"||",
"{",
"}",
",",
"children",
":",
"children",
"||",
"[",
"]",
"}",
")",
"}"
] |
Create an element for a `node`.
|
[
"Create",
"an",
"element",
"for",
"a",
"node",
"."
] |
751b54d3d5a0ebe03cc56290abfcbaeeeca3a326
|
https://github.com/syntax-tree/mdast-util-to-hast/blob/751b54d3d5a0ebe03cc56290abfcbaeeeca3a326/lib/index.js#L65-L81
|
19,987
|
syntax-tree/mdast-util-to-hast
|
lib/index.js
|
toHast
|
function toHast(tree, options) {
var h = factory(tree, options)
var node = one(h, tree)
var footnotes = footer(h)
if (node && node.children && footnotes) {
node.children = node.children.concat(u('text', '\n'), footnotes)
}
return node
}
|
javascript
|
function toHast(tree, options) {
var h = factory(tree, options)
var node = one(h, tree)
var footnotes = footer(h)
if (node && node.children && footnotes) {
node.children = node.children.concat(u('text', '\n'), footnotes)
}
return node
}
|
[
"function",
"toHast",
"(",
"tree",
",",
"options",
")",
"{",
"var",
"h",
"=",
"factory",
"(",
"tree",
",",
"options",
")",
"var",
"node",
"=",
"one",
"(",
"h",
",",
"tree",
")",
"var",
"footnotes",
"=",
"footer",
"(",
"h",
")",
"if",
"(",
"node",
"&&",
"node",
".",
"children",
"&&",
"footnotes",
")",
"{",
"node",
".",
"children",
"=",
"node",
".",
"children",
".",
"concat",
"(",
"u",
"(",
"'text'",
",",
"'\\n'",
")",
",",
"footnotes",
")",
"}",
"return",
"node",
"}"
] |
Transform `tree`, which is an mdast node, to a hast node.
|
[
"Transform",
"tree",
"which",
"is",
"an",
"mdast",
"node",
"to",
"a",
"hast",
"node",
"."
] |
751b54d3d5a0ebe03cc56290abfcbaeeeca3a326
|
https://github.com/syntax-tree/mdast-util-to-hast/blob/751b54d3d5a0ebe03cc56290abfcbaeeeca3a326/lib/index.js#L89-L99
|
19,988
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(destination, source, deep, handleErrors) {
var sourceKeys = [],
key = '',
i = -1;
deep = deep || false;
handleErrors = handleErrors || false;
try {
if (Array.isArray(source)) {
for (i = 0; i < source.length; i++) {
sourceKeys.push(i);
}
} else if (source) {
sourceKeys = Object.keys(source);
}
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (!deep || typeof source[key] !== 'object' || this.isElement(source[key])) {
// All non-object properties, or all properties if shallow extend
destination[key] = source[key];
} else if (Array.isArray(source[key])) {
// Arrays
if (!destination[key]) {
destination[key] = [];
}
this.extend(destination[key], source[key], deep, handleErrors);
} else {
// Objects
if (!destination[key]) {
destination[key] = {};
}
this.extend(destination[key], source[key], deep, handleErrors);
}
}
} catch(err) {
if (handleErrors) {
this.handleExtendError(err, destination);
} else {
throw err;
}
}
return destination;
}
|
javascript
|
function(destination, source, deep, handleErrors) {
var sourceKeys = [],
key = '',
i = -1;
deep = deep || false;
handleErrors = handleErrors || false;
try {
if (Array.isArray(source)) {
for (i = 0; i < source.length; i++) {
sourceKeys.push(i);
}
} else if (source) {
sourceKeys = Object.keys(source);
}
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (!deep || typeof source[key] !== 'object' || this.isElement(source[key])) {
// All non-object properties, or all properties if shallow extend
destination[key] = source[key];
} else if (Array.isArray(source[key])) {
// Arrays
if (!destination[key]) {
destination[key] = [];
}
this.extend(destination[key], source[key], deep, handleErrors);
} else {
// Objects
if (!destination[key]) {
destination[key] = {};
}
this.extend(destination[key], source[key], deep, handleErrors);
}
}
} catch(err) {
if (handleErrors) {
this.handleExtendError(err, destination);
} else {
throw err;
}
}
return destination;
}
|
[
"function",
"(",
"destination",
",",
"source",
",",
"deep",
",",
"handleErrors",
")",
"{",
"var",
"sourceKeys",
"=",
"[",
"]",
",",
"key",
"=",
"''",
",",
"i",
"=",
"-",
"1",
";",
"deep",
"=",
"deep",
"||",
"false",
";",
"handleErrors",
"=",
"handleErrors",
"||",
"false",
";",
"try",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"source",
")",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"source",
".",
"length",
";",
"i",
"++",
")",
"{",
"sourceKeys",
".",
"push",
"(",
"i",
")",
";",
"}",
"}",
"else",
"if",
"(",
"source",
")",
"{",
"sourceKeys",
"=",
"Object",
".",
"keys",
"(",
"source",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"sourceKeys",
".",
"length",
";",
"i",
"++",
")",
"{",
"key",
"=",
"sourceKeys",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"deep",
"||",
"typeof",
"source",
"[",
"key",
"]",
"!==",
"'object'",
"||",
"this",
".",
"isElement",
"(",
"source",
"[",
"key",
"]",
")",
")",
"{",
"// All non-object properties, or all properties if shallow extend",
"destination",
"[",
"key",
"]",
"=",
"source",
"[",
"key",
"]",
";",
"}",
"else",
"if",
"(",
"Array",
".",
"isArray",
"(",
"source",
"[",
"key",
"]",
")",
")",
"{",
"// Arrays",
"if",
"(",
"!",
"destination",
"[",
"key",
"]",
")",
"{",
"destination",
"[",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"this",
".",
"extend",
"(",
"destination",
"[",
"key",
"]",
",",
"source",
"[",
"key",
"]",
",",
"deep",
",",
"handleErrors",
")",
";",
"}",
"else",
"{",
"// Objects",
"if",
"(",
"!",
"destination",
"[",
"key",
"]",
")",
"{",
"destination",
"[",
"key",
"]",
"=",
"{",
"}",
";",
"}",
"this",
".",
"extend",
"(",
"destination",
"[",
"key",
"]",
",",
"source",
"[",
"key",
"]",
",",
"deep",
",",
"handleErrors",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"if",
"(",
"handleErrors",
")",
"{",
"this",
".",
"handleExtendError",
"(",
"err",
",",
"destination",
")",
";",
"}",
"else",
"{",
"throw",
"err",
";",
"}",
"}",
"return",
"destination",
";",
"}"
] |
Merges the properties of the source object onto the
target object. Alters the target object.
@private
@param {object} destination
@param {object} source
@param {boolean} [deep=false]
@param {boolean} [handleErrors=false]
@return {void}
|
[
"Merges",
"the",
"properties",
"of",
"the",
"source",
"object",
"onto",
"the",
"target",
"object",
".",
"Alters",
"the",
"target",
"object",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L559-L610
|
|
19,989
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(box1, box2) {
var controlArea = box1.width * box1.height,
intersectionX = -1,
intersectionY = -1,
intersectionArea = -1,
ratio = -1;
intersectionX =
Math.max(0, Math.min(box1.left + box1.width, box2.left + box2.width) - Math.max(box1.left, box2.left));
intersectionY =
Math.max(0, Math.min(box1.top + box1.height, box2.top + box2.height) - Math.max(box1.top, box2.top));
intersectionArea = intersectionY * intersectionX;
ratio = intersectionArea / controlArea;
return ratio;
}
|
javascript
|
function(box1, box2) {
var controlArea = box1.width * box1.height,
intersectionX = -1,
intersectionY = -1,
intersectionArea = -1,
ratio = -1;
intersectionX =
Math.max(0, Math.min(box1.left + box1.width, box2.left + box2.width) - Math.max(box1.left, box2.left));
intersectionY =
Math.max(0, Math.min(box1.top + box1.height, box2.top + box2.height) - Math.max(box1.top, box2.top));
intersectionArea = intersectionY * intersectionX;
ratio = intersectionArea / controlArea;
return ratio;
}
|
[
"function",
"(",
"box1",
",",
"box2",
")",
"{",
"var",
"controlArea",
"=",
"box1",
".",
"width",
"*",
"box1",
".",
"height",
",",
"intersectionX",
"=",
"-",
"1",
",",
"intersectionY",
"=",
"-",
"1",
",",
"intersectionArea",
"=",
"-",
"1",
",",
"ratio",
"=",
"-",
"1",
";",
"intersectionX",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"Math",
".",
"min",
"(",
"box1",
".",
"left",
"+",
"box1",
".",
"width",
",",
"box2",
".",
"left",
"+",
"box2",
".",
"width",
")",
"-",
"Math",
".",
"max",
"(",
"box1",
".",
"left",
",",
"box2",
".",
"left",
")",
")",
";",
"intersectionY",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"Math",
".",
"min",
"(",
"box1",
".",
"top",
"+",
"box1",
".",
"height",
",",
"box2",
".",
"top",
"+",
"box2",
".",
"height",
")",
"-",
"Math",
".",
"max",
"(",
"box1",
".",
"top",
",",
"box2",
".",
"top",
")",
")",
";",
"intersectionArea",
"=",
"intersectionY",
"*",
"intersectionX",
";",
"ratio",
"=",
"intersectionArea",
"/",
"controlArea",
";",
"return",
"ratio",
";",
"}"
] |
Calcuates the area of intersection between two rectangles and expresses it as
a ratio in comparison to the area of the first rectangle.
@private
@param {Rect} box1
@param {Rect} box2
@return {number}
|
[
"Calcuates",
"the",
"area",
"of",
"intersection",
"between",
"two",
"rectangles",
"and",
"expresses",
"it",
"as",
"a",
"ratio",
"in",
"comparison",
"to",
"the",
"area",
"of",
"the",
"first",
"rectangle",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1096-L1114
|
|
19,990
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(originalArray) {
var cleanArray = [],
i = -1;
for (i = 0; i < originalArray.length; i++) {
if (originalArray[i] !== '') {
cleanArray.push(originalArray[i]);
}
}
return cleanArray;
}
|
javascript
|
function(originalArray) {
var cleanArray = [],
i = -1;
for (i = 0; i < originalArray.length; i++) {
if (originalArray[i] !== '') {
cleanArray.push(originalArray[i]);
}
}
return cleanArray;
}
|
[
"function",
"(",
"originalArray",
")",
"{",
"var",
"cleanArray",
"=",
"[",
"]",
",",
"i",
"=",
"-",
"1",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"originalArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"originalArray",
"[",
"i",
"]",
"!==",
"''",
")",
"{",
"cleanArray",
".",
"push",
"(",
"originalArray",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"cleanArray",
";",
"}"
] |
Creates a clone of a provided array, with any empty strings removed.
@private
@param {Array<*>} originalArray
@return {Array<*>}
|
[
"Creates",
"a",
"clone",
"of",
"a",
"provided",
"array",
"with",
"any",
"empty",
"strings",
"removed",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1186-L1197
|
|
19,991
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(libraries) {
var deferred = null,
promiseWrapper = null,
$ = null;
promiseWrapper = new this.Deferred();
if (mixitup.features.has.promises) {
// ES6 native promise or polyfill
promiseWrapper.promise = new Promise(function(resolve, reject) {
promiseWrapper.resolve = resolve;
promiseWrapper.reject = reject;
});
} else if (($ = (window.jQuery || libraries.$)) && typeof $.Deferred === 'function') {
// jQuery
deferred = $.Deferred();
promiseWrapper.promise = deferred.promise();
promiseWrapper.resolve = deferred.resolve;
promiseWrapper.reject = deferred.reject;
} else if (window.console) {
// No implementation
console.warn(mixitup.messages.warningNoPromiseImplementation());
}
return promiseWrapper;
}
|
javascript
|
function(libraries) {
var deferred = null,
promiseWrapper = null,
$ = null;
promiseWrapper = new this.Deferred();
if (mixitup.features.has.promises) {
// ES6 native promise or polyfill
promiseWrapper.promise = new Promise(function(resolve, reject) {
promiseWrapper.resolve = resolve;
promiseWrapper.reject = reject;
});
} else if (($ = (window.jQuery || libraries.$)) && typeof $.Deferred === 'function') {
// jQuery
deferred = $.Deferred();
promiseWrapper.promise = deferred.promise();
promiseWrapper.resolve = deferred.resolve;
promiseWrapper.reject = deferred.reject;
} else if (window.console) {
// No implementation
console.warn(mixitup.messages.warningNoPromiseImplementation());
}
return promiseWrapper;
}
|
[
"function",
"(",
"libraries",
")",
"{",
"var",
"deferred",
"=",
"null",
",",
"promiseWrapper",
"=",
"null",
",",
"$",
"=",
"null",
";",
"promiseWrapper",
"=",
"new",
"this",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"mixitup",
".",
"features",
".",
"has",
".",
"promises",
")",
"{",
"// ES6 native promise or polyfill",
"promiseWrapper",
".",
"promise",
"=",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"promiseWrapper",
".",
"resolve",
"=",
"resolve",
";",
"promiseWrapper",
".",
"reject",
"=",
"reject",
";",
"}",
")",
";",
"}",
"else",
"if",
"(",
"(",
"$",
"=",
"(",
"window",
".",
"jQuery",
"||",
"libraries",
".",
"$",
")",
")",
"&&",
"typeof",
"$",
".",
"Deferred",
"===",
"'function'",
")",
"{",
"// jQuery",
"deferred",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"promiseWrapper",
".",
"promise",
"=",
"deferred",
".",
"promise",
"(",
")",
";",
"promiseWrapper",
".",
"resolve",
"=",
"deferred",
".",
"resolve",
";",
"promiseWrapper",
".",
"reject",
"=",
"deferred",
".",
"reject",
";",
"}",
"else",
"if",
"(",
"window",
".",
"console",
")",
"{",
"// No implementation",
"console",
".",
"warn",
"(",
"mixitup",
".",
"messages",
".",
"warningNoPromiseImplementation",
"(",
")",
")",
";",
"}",
"return",
"promiseWrapper",
";",
"}"
] |
Abstracts an ES6 promise into a q-like deferred interface for storage and deferred resolution.
@private
@param {object} libraries
@return {h.Deferred}
|
[
"Abstracts",
"an",
"ES6",
"promise",
"into",
"a",
"q",
"-",
"like",
"deferred",
"interface",
"for",
"storage",
"and",
"deferred",
"resolution",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1207-L1236
|
|
19,992
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(obj, stringKey) {
var parts = stringKey.split('.'),
returnCurrent = null,
current = '',
i = 0;
if (!stringKey) {
return obj;
}
returnCurrent = function(obj) {
if (!obj) {
return null;
} else {
return obj[current];
}
};
while (i < parts.length) {
current = parts[i];
obj = returnCurrent(obj);
i++;
}
if (typeof obj !== 'undefined') {
return obj;
} else {
return null;
}
}
|
javascript
|
function(obj, stringKey) {
var parts = stringKey.split('.'),
returnCurrent = null,
current = '',
i = 0;
if (!stringKey) {
return obj;
}
returnCurrent = function(obj) {
if (!obj) {
return null;
} else {
return obj[current];
}
};
while (i < parts.length) {
current = parts[i];
obj = returnCurrent(obj);
i++;
}
if (typeof obj !== 'undefined') {
return obj;
} else {
return null;
}
}
|
[
"function",
"(",
"obj",
",",
"stringKey",
")",
"{",
"var",
"parts",
"=",
"stringKey",
".",
"split",
"(",
"'.'",
")",
",",
"returnCurrent",
"=",
"null",
",",
"current",
"=",
"''",
",",
"i",
"=",
"0",
";",
"if",
"(",
"!",
"stringKey",
")",
"{",
"return",
"obj",
";",
"}",
"returnCurrent",
"=",
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"obj",
"[",
"current",
"]",
";",
"}",
"}",
";",
"while",
"(",
"i",
"<",
"parts",
".",
"length",
")",
"{",
"current",
"=",
"parts",
"[",
"i",
"]",
";",
"obj",
"=",
"returnCurrent",
"(",
"obj",
")",
";",
"i",
"++",
";",
"}",
"if",
"(",
"typeof",
"obj",
"!==",
"'undefined'",
")",
"{",
"return",
"obj",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Returns the value of a property on a given object via its string key.
@param {object} obj
@param {string} stringKey
@return {*} value
|
[
"Returns",
"the",
"value",
"of",
"a",
"property",
"on",
"a",
"given",
"object",
"via",
"its",
"string",
"key",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1477-L1508
|
|
19,993
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(actionName, args) {
var self = this,
hooks = self.constructor.actions[actionName],
extensionName = '';
if (!hooks || h.isEmptyObject(hooks)) return;
for (extensionName in hooks) {
hooks[extensionName].apply(self, args);
}
}
|
javascript
|
function(actionName, args) {
var self = this,
hooks = self.constructor.actions[actionName],
extensionName = '';
if (!hooks || h.isEmptyObject(hooks)) return;
for (extensionName in hooks) {
hooks[extensionName].apply(self, args);
}
}
|
[
"function",
"(",
"actionName",
",",
"args",
")",
"{",
"var",
"self",
"=",
"this",
",",
"hooks",
"=",
"self",
".",
"constructor",
".",
"actions",
"[",
"actionName",
"]",
",",
"extensionName",
"=",
"''",
";",
"if",
"(",
"!",
"hooks",
"||",
"h",
".",
"isEmptyObject",
"(",
"hooks",
")",
")",
"return",
";",
"for",
"(",
"extensionName",
"in",
"hooks",
")",
"{",
"hooks",
"[",
"extensionName",
"]",
".",
"apply",
"(",
"self",
",",
"args",
")",
";",
"}",
"}"
] |
Calls any registered hooks for the provided action.
@memberof mixitup.Base
@private
@instance
@since 2.0.0
@param {string} actionName
@param {Array<*>} args
@return {void}
|
[
"Calls",
"any",
"registered",
"hooks",
"for",
"the",
"provided",
"action",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1541-L1551
|
|
19,994
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(filterName, input, args) {
var self = this,
hooks = self.constructor.filters[filterName],
output = input,
extensionName = '';
if (!hooks || h.isEmptyObject(hooks)) return output;
args = args || [];
for (extensionName in hooks) {
args = h.arrayFromList(args);
args.unshift(output);
output = hooks[extensionName].apply(self, args);
}
return output;
}
|
javascript
|
function(filterName, input, args) {
var self = this,
hooks = self.constructor.filters[filterName],
output = input,
extensionName = '';
if (!hooks || h.isEmptyObject(hooks)) return output;
args = args || [];
for (extensionName in hooks) {
args = h.arrayFromList(args);
args.unshift(output);
output = hooks[extensionName].apply(self, args);
}
return output;
}
|
[
"function",
"(",
"filterName",
",",
"input",
",",
"args",
")",
"{",
"var",
"self",
"=",
"this",
",",
"hooks",
"=",
"self",
".",
"constructor",
".",
"filters",
"[",
"filterName",
"]",
",",
"output",
"=",
"input",
",",
"extensionName",
"=",
"''",
";",
"if",
"(",
"!",
"hooks",
"||",
"h",
".",
"isEmptyObject",
"(",
"hooks",
")",
")",
"return",
"output",
";",
"args",
"=",
"args",
"||",
"[",
"]",
";",
"for",
"(",
"extensionName",
"in",
"hooks",
")",
"{",
"args",
"=",
"h",
".",
"arrayFromList",
"(",
"args",
")",
";",
"args",
".",
"unshift",
"(",
"output",
")",
";",
"output",
"=",
"hooks",
"[",
"extensionName",
"]",
".",
"apply",
"(",
"self",
",",
"args",
")",
";",
"}",
"return",
"output",
";",
"}"
] |
Calls any registered hooks for the provided filter.
@memberof mixitup.Base
@private
@instance
@since 2.0.0
@param {string} filterName
@param {*} input
@param {Array<*>} args
@return {*}
|
[
"Calls",
"any",
"registered",
"hooks",
"for",
"the",
"provided",
"filter",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1566-L1585
|
|
19,995
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(el, document) {
var self = this;
self.callActions('beforeCacheDom', arguments);
self.dom.document = document;
self.dom.body = self.dom.document.querySelector('body');
self.dom.container = el;
self.dom.parent = el;
self.callActions('afterCacheDom', arguments);
}
|
javascript
|
function(el, document) {
var self = this;
self.callActions('beforeCacheDom', arguments);
self.dom.document = document;
self.dom.body = self.dom.document.querySelector('body');
self.dom.container = el;
self.dom.parent = el;
self.callActions('afterCacheDom', arguments);
}
|
[
"function",
"(",
"el",
",",
"document",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"callActions",
"(",
"'beforeCacheDom'",
",",
"arguments",
")",
";",
"self",
".",
"dom",
".",
"document",
"=",
"document",
";",
"self",
".",
"dom",
".",
"body",
"=",
"self",
".",
"dom",
".",
"document",
".",
"querySelector",
"(",
"'body'",
")",
";",
"self",
".",
"dom",
".",
"container",
"=",
"el",
";",
"self",
".",
"dom",
".",
"parent",
"=",
"el",
";",
"self",
".",
"callActions",
"(",
"'afterCacheDom'",
",",
"arguments",
")",
";",
"}"
] |
Caches references of DOM elements neccessary for the mixer's functionality.
@private
@instance
@since 3.0.0
@param {HTMLElement} el
@param {HTMLHtmlElement} document
@return {void}
|
[
"Caches",
"references",
"of",
"DOM",
"elements",
"neccessary",
"for",
"the",
"mixer",
"s",
"functionality",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5138-L5149
|
|
19,996
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function() {
var self = this,
target = null,
el = null,
dataset = null,
i = -1;
self.callActions('beforeIndexTargets', arguments);
self.dom.targets = self.config.layout.allowNestedTargets ?
self.dom.container.querySelectorAll(self.config.selectors.target) :
h.children(self.dom.container, self.config.selectors.target, self.dom.document);
self.dom.targets = h.arrayFromList(self.dom.targets);
self.targets = [];
if ((dataset = self.config.load.dataset) && dataset.length !== self.dom.targets.length) {
throw new Error(mixitup.messages.errorDatasetPrerenderedMismatch());
}
if (self.dom.targets.length) {
for (i = 0; el = self.dom.targets[i]; i++) {
target = new mixitup.Target();
target.init(el, self, dataset ? dataset[i] : void(0));
target.isInDom = true;
self.targets.push(target);
}
self.dom.parent = self.dom.targets[0].parentElement === self.dom.container ?
self.dom.container :
self.dom.targets[0].parentElement;
}
self.origOrder = self.targets;
self.callActions('afterIndexTargets', arguments);
}
|
javascript
|
function() {
var self = this,
target = null,
el = null,
dataset = null,
i = -1;
self.callActions('beforeIndexTargets', arguments);
self.dom.targets = self.config.layout.allowNestedTargets ?
self.dom.container.querySelectorAll(self.config.selectors.target) :
h.children(self.dom.container, self.config.selectors.target, self.dom.document);
self.dom.targets = h.arrayFromList(self.dom.targets);
self.targets = [];
if ((dataset = self.config.load.dataset) && dataset.length !== self.dom.targets.length) {
throw new Error(mixitup.messages.errorDatasetPrerenderedMismatch());
}
if (self.dom.targets.length) {
for (i = 0; el = self.dom.targets[i]; i++) {
target = new mixitup.Target();
target.init(el, self, dataset ? dataset[i] : void(0));
target.isInDom = true;
self.targets.push(target);
}
self.dom.parent = self.dom.targets[0].parentElement === self.dom.container ?
self.dom.container :
self.dom.targets[0].parentElement;
}
self.origOrder = self.targets;
self.callActions('afterIndexTargets', arguments);
}
|
[
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"target",
"=",
"null",
",",
"el",
"=",
"null",
",",
"dataset",
"=",
"null",
",",
"i",
"=",
"-",
"1",
";",
"self",
".",
"callActions",
"(",
"'beforeIndexTargets'",
",",
"arguments",
")",
";",
"self",
".",
"dom",
".",
"targets",
"=",
"self",
".",
"config",
".",
"layout",
".",
"allowNestedTargets",
"?",
"self",
".",
"dom",
".",
"container",
".",
"querySelectorAll",
"(",
"self",
".",
"config",
".",
"selectors",
".",
"target",
")",
":",
"h",
".",
"children",
"(",
"self",
".",
"dom",
".",
"container",
",",
"self",
".",
"config",
".",
"selectors",
".",
"target",
",",
"self",
".",
"dom",
".",
"document",
")",
";",
"self",
".",
"dom",
".",
"targets",
"=",
"h",
".",
"arrayFromList",
"(",
"self",
".",
"dom",
".",
"targets",
")",
";",
"self",
".",
"targets",
"=",
"[",
"]",
";",
"if",
"(",
"(",
"dataset",
"=",
"self",
".",
"config",
".",
"load",
".",
"dataset",
")",
"&&",
"dataset",
".",
"length",
"!==",
"self",
".",
"dom",
".",
"targets",
".",
"length",
")",
"{",
"throw",
"new",
"Error",
"(",
"mixitup",
".",
"messages",
".",
"errorDatasetPrerenderedMismatch",
"(",
")",
")",
";",
"}",
"if",
"(",
"self",
".",
"dom",
".",
"targets",
".",
"length",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"el",
"=",
"self",
".",
"dom",
".",
"targets",
"[",
"i",
"]",
";",
"i",
"++",
")",
"{",
"target",
"=",
"new",
"mixitup",
".",
"Target",
"(",
")",
";",
"target",
".",
"init",
"(",
"el",
",",
"self",
",",
"dataset",
"?",
"dataset",
"[",
"i",
"]",
":",
"void",
"(",
"0",
")",
")",
";",
"target",
".",
"isInDom",
"=",
"true",
";",
"self",
".",
"targets",
".",
"push",
"(",
"target",
")",
";",
"}",
"self",
".",
"dom",
".",
"parent",
"=",
"self",
".",
"dom",
".",
"targets",
"[",
"0",
"]",
".",
"parentElement",
"===",
"self",
".",
"dom",
".",
"container",
"?",
"self",
".",
"dom",
".",
"container",
":",
"self",
".",
"dom",
".",
"targets",
"[",
"0",
"]",
".",
"parentElement",
";",
"}",
"self",
".",
"origOrder",
"=",
"self",
".",
"targets",
";",
"self",
".",
"callActions",
"(",
"'afterIndexTargets'",
",",
"arguments",
")",
";",
"}"
] |
Indexes all child elements of the mixer matching the `selectors.target`
selector, instantiating a mixitup.Target for each one.
@private
@instance
@since 3.0.0
@return {void}
|
[
"Indexes",
"all",
"child",
"elements",
"of",
"the",
"mixer",
"matching",
"the",
"selectors",
".",
"target",
"selector",
"instantiating",
"a",
"mixitup",
".",
"Target",
"for",
"each",
"one",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5161-L5201
|
|
19,997
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function() {
var self = this,
delineator = self.config.controls.toggleLogic === 'or' ? ', ' : '',
toggleSelector = '';
self.callActions('beforeGetToggleSelector', arguments);
self.toggleArray = h.clean(self.toggleArray);
toggleSelector = self.toggleArray.join(delineator);
if (toggleSelector === '') {
toggleSelector = self.config.controls.toggleDefault;
}
return self.callFilters('selectorGetToggleSelector', toggleSelector, arguments);
}
|
javascript
|
function() {
var self = this,
delineator = self.config.controls.toggleLogic === 'or' ? ', ' : '',
toggleSelector = '';
self.callActions('beforeGetToggleSelector', arguments);
self.toggleArray = h.clean(self.toggleArray);
toggleSelector = self.toggleArray.join(delineator);
if (toggleSelector === '') {
toggleSelector = self.config.controls.toggleDefault;
}
return self.callFilters('selectorGetToggleSelector', toggleSelector, arguments);
}
|
[
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"delineator",
"=",
"self",
".",
"config",
".",
"controls",
".",
"toggleLogic",
"===",
"'or'",
"?",
"', '",
":",
"''",
",",
"toggleSelector",
"=",
"''",
";",
"self",
".",
"callActions",
"(",
"'beforeGetToggleSelector'",
",",
"arguments",
")",
";",
"self",
".",
"toggleArray",
"=",
"h",
".",
"clean",
"(",
"self",
".",
"toggleArray",
")",
";",
"toggleSelector",
"=",
"self",
".",
"toggleArray",
".",
"join",
"(",
"delineator",
")",
";",
"if",
"(",
"toggleSelector",
"===",
"''",
")",
"{",
"toggleSelector",
"=",
"self",
".",
"config",
".",
"controls",
".",
"toggleDefault",
";",
"}",
"return",
"self",
".",
"callFilters",
"(",
"'selectorGetToggleSelector'",
",",
"toggleSelector",
",",
"arguments",
")",
";",
"}"
] |
Creates a compound selector by joining the `toggleArray` value as per the
defined toggle logic.
@private
@instance
@since 3.0.0
@return {string}
|
[
"Creates",
"a",
"compound",
"selector",
"by",
"joining",
"the",
"toggleArray",
"value",
"as",
"per",
"the",
"defined",
"toggle",
"logic",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5329-L5345
|
|
19,998
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(command, state) {
var self = this,
activeFilterSelector = '';
self.callActions('beforeBuildToggleArray', arguments);
if (command && command.filter) {
activeFilterSelector = command.filter.selector.replace(/\s/g, '');
} else if (state) {
activeFilterSelector = state.activeFilter.selector.replace(/\s/g, '');
} else {
return;
}
if (activeFilterSelector === self.config.selectors.target || activeFilterSelector === 'all') {
activeFilterSelector = '';
}
if (self.config.controls.toggleLogic === 'or') {
self.toggleArray = activeFilterSelector.split(',');
} else {
self.toggleArray = self.splitCompoundSelector(activeFilterSelector);
}
self.toggleArray = h.clean(self.toggleArray);
self.callActions('afterBuildToggleArray', arguments);
}
|
javascript
|
function(command, state) {
var self = this,
activeFilterSelector = '';
self.callActions('beforeBuildToggleArray', arguments);
if (command && command.filter) {
activeFilterSelector = command.filter.selector.replace(/\s/g, '');
} else if (state) {
activeFilterSelector = state.activeFilter.selector.replace(/\s/g, '');
} else {
return;
}
if (activeFilterSelector === self.config.selectors.target || activeFilterSelector === 'all') {
activeFilterSelector = '';
}
if (self.config.controls.toggleLogic === 'or') {
self.toggleArray = activeFilterSelector.split(',');
} else {
self.toggleArray = self.splitCompoundSelector(activeFilterSelector);
}
self.toggleArray = h.clean(self.toggleArray);
self.callActions('afterBuildToggleArray', arguments);
}
|
[
"function",
"(",
"command",
",",
"state",
")",
"{",
"var",
"self",
"=",
"this",
",",
"activeFilterSelector",
"=",
"''",
";",
"self",
".",
"callActions",
"(",
"'beforeBuildToggleArray'",
",",
"arguments",
")",
";",
"if",
"(",
"command",
"&&",
"command",
".",
"filter",
")",
"{",
"activeFilterSelector",
"=",
"command",
".",
"filter",
".",
"selector",
".",
"replace",
"(",
"/",
"\\s",
"/",
"g",
",",
"''",
")",
";",
"}",
"else",
"if",
"(",
"state",
")",
"{",
"activeFilterSelector",
"=",
"state",
".",
"activeFilter",
".",
"selector",
".",
"replace",
"(",
"/",
"\\s",
"/",
"g",
",",
"''",
")",
";",
"}",
"else",
"{",
"return",
";",
"}",
"if",
"(",
"activeFilterSelector",
"===",
"self",
".",
"config",
".",
"selectors",
".",
"target",
"||",
"activeFilterSelector",
"===",
"'all'",
")",
"{",
"activeFilterSelector",
"=",
"''",
";",
"}",
"if",
"(",
"self",
".",
"config",
".",
"controls",
".",
"toggleLogic",
"===",
"'or'",
")",
"{",
"self",
".",
"toggleArray",
"=",
"activeFilterSelector",
".",
"split",
"(",
"','",
")",
";",
"}",
"else",
"{",
"self",
".",
"toggleArray",
"=",
"self",
".",
"splitCompoundSelector",
"(",
"activeFilterSelector",
")",
";",
"}",
"self",
".",
"toggleArray",
"=",
"h",
".",
"clean",
"(",
"self",
".",
"toggleArray",
")",
";",
"self",
".",
"callActions",
"(",
"'afterBuildToggleArray'",
",",
"arguments",
")",
";",
"}"
] |
Breaks compound selector strings in an array of discreet selectors,
as per the active `controls.toggleLogic` configuration option. Accepts
either a dynamic command object, or a state object.
@private
@instance
@since 2.0.0
@param {object} [command]
@param {mixitup.State} [state]
@return {void}
|
[
"Breaks",
"compound",
"selector",
"strings",
"in",
"an",
"array",
"of",
"discreet",
"selectors",
"as",
"per",
"the",
"active",
"controls",
".",
"toggleLogic",
"configuration",
"option",
".",
"Accepts",
"either",
"a",
"dynamic",
"command",
"object",
"or",
"a",
"state",
"object",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5360-L5387
|
|
19,999
|
octoblu/meshblu
|
docs/vendor/mixitup/mixitup.js
|
function(target, attribute) {
var self = this,
value = '';
value = target.dom.el.getAttribute('data-' + attribute);
if (value === null) {
if (self.config.debug.showWarnings) {
// Encourage users to assign values to all targets to avoid erroneous sorting
// when types are mixed
console.warn(mixitup.messages.warningInconsistentSortingAttributes({
attribute: 'data-' + attribute
}));
}
}
// If an attribute is not present, return 0 as a safety value
return self.callFilters('valueGetAttributeValue', value || 0, arguments);
}
|
javascript
|
function(target, attribute) {
var self = this,
value = '';
value = target.dom.el.getAttribute('data-' + attribute);
if (value === null) {
if (self.config.debug.showWarnings) {
// Encourage users to assign values to all targets to avoid erroneous sorting
// when types are mixed
console.warn(mixitup.messages.warningInconsistentSortingAttributes({
attribute: 'data-' + attribute
}));
}
}
// If an attribute is not present, return 0 as a safety value
return self.callFilters('valueGetAttributeValue', value || 0, arguments);
}
|
[
"function",
"(",
"target",
",",
"attribute",
")",
"{",
"var",
"self",
"=",
"this",
",",
"value",
"=",
"''",
";",
"value",
"=",
"target",
".",
"dom",
".",
"el",
".",
"getAttribute",
"(",
"'data-'",
"+",
"attribute",
")",
";",
"if",
"(",
"value",
"===",
"null",
")",
"{",
"if",
"(",
"self",
".",
"config",
".",
"debug",
".",
"showWarnings",
")",
"{",
"// Encourage users to assign values to all targets to avoid erroneous sorting",
"// when types are mixed",
"console",
".",
"warn",
"(",
"mixitup",
".",
"messages",
".",
"warningInconsistentSortingAttributes",
"(",
"{",
"attribute",
":",
"'data-'",
"+",
"attribute",
"}",
")",
")",
";",
"}",
"}",
"// If an attribute is not present, return 0 as a safety value",
"return",
"self",
".",
"callFilters",
"(",
"'valueGetAttributeValue'",
",",
"value",
"||",
"0",
",",
"arguments",
")",
";",
"}"
] |
Reads the values of any data attributes present the provided target element
which match the current sort command.
@private
@instance
@since 3.0.0
@param {mixitup.Target} target
@param {string} [attribute]
@return {(String|Number)}
|
[
"Reads",
"the",
"values",
"of",
"any",
"data",
"attributes",
"present",
"the",
"provided",
"target",
"element",
"which",
"match",
"the",
"current",
"sort",
"command",
"."
] |
4e7a5a0460b4eb097dfe9ff2db15853eccc779d7
|
https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5807-L5827
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.