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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
12,600
|
aframevr/aframe-inspector
|
src/lib/entity.js
|
optimizeComponents
|
function optimizeComponents(copy, source) {
var removeAttribute = HTMLElement.prototype.removeAttribute;
var setAttribute = HTMLElement.prototype.setAttribute;
var components = source.components || {};
Object.keys(components).forEach(function(name) {
var component = components[name];
var result = getImplicitValue(component, source);
var isInherited = result[1];
var implicitValue = result[0];
var currentValue = source.getAttribute(name);
var optimalUpdate = getOptimalUpdate(
component,
implicitValue,
currentValue
);
var doesNotNeedUpdate = optimalUpdate === null;
if (isInherited && doesNotNeedUpdate) {
removeAttribute.call(copy, name);
} else {
var schema = component.schema;
var value = stringifyComponentValue(schema, optimalUpdate);
setAttribute.call(copy, name, value);
}
});
}
|
javascript
|
function optimizeComponents(copy, source) {
var removeAttribute = HTMLElement.prototype.removeAttribute;
var setAttribute = HTMLElement.prototype.setAttribute;
var components = source.components || {};
Object.keys(components).forEach(function(name) {
var component = components[name];
var result = getImplicitValue(component, source);
var isInherited = result[1];
var implicitValue = result[0];
var currentValue = source.getAttribute(name);
var optimalUpdate = getOptimalUpdate(
component,
implicitValue,
currentValue
);
var doesNotNeedUpdate = optimalUpdate === null;
if (isInherited && doesNotNeedUpdate) {
removeAttribute.call(copy, name);
} else {
var schema = component.schema;
var value = stringifyComponentValue(schema, optimalUpdate);
setAttribute.call(copy, name, value);
}
});
}
|
[
"function",
"optimizeComponents",
"(",
"copy",
",",
"source",
")",
"{",
"var",
"removeAttribute",
"=",
"HTMLElement",
".",
"prototype",
".",
"removeAttribute",
";",
"var",
"setAttribute",
"=",
"HTMLElement",
".",
"prototype",
".",
"setAttribute",
";",
"var",
"components",
"=",
"source",
".",
"components",
"||",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"components",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"var",
"component",
"=",
"components",
"[",
"name",
"]",
";",
"var",
"result",
"=",
"getImplicitValue",
"(",
"component",
",",
"source",
")",
";",
"var",
"isInherited",
"=",
"result",
"[",
"1",
"]",
";",
"var",
"implicitValue",
"=",
"result",
"[",
"0",
"]",
";",
"var",
"currentValue",
"=",
"source",
".",
"getAttribute",
"(",
"name",
")",
";",
"var",
"optimalUpdate",
"=",
"getOptimalUpdate",
"(",
"component",
",",
"implicitValue",
",",
"currentValue",
")",
";",
"var",
"doesNotNeedUpdate",
"=",
"optimalUpdate",
"===",
"null",
";",
"if",
"(",
"isInherited",
"&&",
"doesNotNeedUpdate",
")",
"{",
"removeAttribute",
".",
"call",
"(",
"copy",
",",
"name",
")",
";",
"}",
"else",
"{",
"var",
"schema",
"=",
"component",
".",
"schema",
";",
"var",
"value",
"=",
"stringifyComponentValue",
"(",
"schema",
",",
"optimalUpdate",
")",
";",
"setAttribute",
".",
"call",
"(",
"copy",
",",
"name",
",",
"value",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Removes from copy those components or components' properties that comes from
primitive attributes, mixins, injected default components or schema defaults.
@param {Element} copy Destinatary element for the optimization.
@param {Element} source Element to be optimized.
|
[
"Removes",
"from",
"copy",
"those",
"components",
"or",
"components",
"properties",
"that",
"comes",
"from",
"primitive",
"attributes",
"mixins",
"injected",
"default",
"components",
"or",
"schema",
"defaults",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L196-L220
|
12,601
|
aframevr/aframe-inspector
|
src/lib/entity.js
|
getImplicitValue
|
function getImplicitValue(component, source) {
var isInherited = false;
var value = (isSingleProperty(component.schema) ? _single : _multi)();
return [value, isInherited];
function _single() {
var value = getMixedValue(component, null, source);
if (value === undefined) {
value = getInjectedValue(component, null, source);
}
if (value !== undefined) {
isInherited = true;
} else {
value = getDefaultValue(component, null, source);
}
if (value !== undefined) {
// XXX: This assumes parse is idempotent
return component.schema.parse(value);
}
return value;
}
function _multi() {
var value;
Object.keys(component.schema).forEach(function(propertyName) {
var propertyValue = getFromAttribute(component, propertyName, source);
if (propertyValue === undefined) {
propertyValue = getMixedValue(component, propertyName, source);
}
if (propertyValue === undefined) {
propertyValue = getInjectedValue(component, propertyName, source);
}
if (propertyValue !== undefined) {
isInherited = isInherited || true;
} else {
propertyValue = getDefaultValue(component, propertyName, source);
}
if (propertyValue !== undefined) {
var parse = component.schema[propertyName].parse;
value = value || {};
// XXX: This assumes parse is idempotent
value[propertyName] = parse(propertyValue);
}
});
return value;
}
}
|
javascript
|
function getImplicitValue(component, source) {
var isInherited = false;
var value = (isSingleProperty(component.schema) ? _single : _multi)();
return [value, isInherited];
function _single() {
var value = getMixedValue(component, null, source);
if (value === undefined) {
value = getInjectedValue(component, null, source);
}
if (value !== undefined) {
isInherited = true;
} else {
value = getDefaultValue(component, null, source);
}
if (value !== undefined) {
// XXX: This assumes parse is idempotent
return component.schema.parse(value);
}
return value;
}
function _multi() {
var value;
Object.keys(component.schema).forEach(function(propertyName) {
var propertyValue = getFromAttribute(component, propertyName, source);
if (propertyValue === undefined) {
propertyValue = getMixedValue(component, propertyName, source);
}
if (propertyValue === undefined) {
propertyValue = getInjectedValue(component, propertyName, source);
}
if (propertyValue !== undefined) {
isInherited = isInherited || true;
} else {
propertyValue = getDefaultValue(component, propertyName, source);
}
if (propertyValue !== undefined) {
var parse = component.schema[propertyName].parse;
value = value || {};
// XXX: This assumes parse is idempotent
value[propertyName] = parse(propertyValue);
}
});
return value;
}
}
|
[
"function",
"getImplicitValue",
"(",
"component",
",",
"source",
")",
"{",
"var",
"isInherited",
"=",
"false",
";",
"var",
"value",
"=",
"(",
"isSingleProperty",
"(",
"component",
".",
"schema",
")",
"?",
"_single",
":",
"_multi",
")",
"(",
")",
";",
"return",
"[",
"value",
",",
"isInherited",
"]",
";",
"function",
"_single",
"(",
")",
"{",
"var",
"value",
"=",
"getMixedValue",
"(",
"component",
",",
"null",
",",
"source",
")",
";",
"if",
"(",
"value",
"===",
"undefined",
")",
"{",
"value",
"=",
"getInjectedValue",
"(",
"component",
",",
"null",
",",
"source",
")",
";",
"}",
"if",
"(",
"value",
"!==",
"undefined",
")",
"{",
"isInherited",
"=",
"true",
";",
"}",
"else",
"{",
"value",
"=",
"getDefaultValue",
"(",
"component",
",",
"null",
",",
"source",
")",
";",
"}",
"if",
"(",
"value",
"!==",
"undefined",
")",
"{",
"// XXX: This assumes parse is idempotent",
"return",
"component",
".",
"schema",
".",
"parse",
"(",
"value",
")",
";",
"}",
"return",
"value",
";",
"}",
"function",
"_multi",
"(",
")",
"{",
"var",
"value",
";",
"Object",
".",
"keys",
"(",
"component",
".",
"schema",
")",
".",
"forEach",
"(",
"function",
"(",
"propertyName",
")",
"{",
"var",
"propertyValue",
"=",
"getFromAttribute",
"(",
"component",
",",
"propertyName",
",",
"source",
")",
";",
"if",
"(",
"propertyValue",
"===",
"undefined",
")",
"{",
"propertyValue",
"=",
"getMixedValue",
"(",
"component",
",",
"propertyName",
",",
"source",
")",
";",
"}",
"if",
"(",
"propertyValue",
"===",
"undefined",
")",
"{",
"propertyValue",
"=",
"getInjectedValue",
"(",
"component",
",",
"propertyName",
",",
"source",
")",
";",
"}",
"if",
"(",
"propertyValue",
"!==",
"undefined",
")",
"{",
"isInherited",
"=",
"isInherited",
"||",
"true",
";",
"}",
"else",
"{",
"propertyValue",
"=",
"getDefaultValue",
"(",
"component",
",",
"propertyName",
",",
"source",
")",
";",
"}",
"if",
"(",
"propertyValue",
"!==",
"undefined",
")",
"{",
"var",
"parse",
"=",
"component",
".",
"schema",
"[",
"propertyName",
"]",
".",
"parse",
";",
"value",
"=",
"value",
"||",
"{",
"}",
";",
"// XXX: This assumes parse is idempotent",
"value",
"[",
"propertyName",
"]",
"=",
"parse",
"(",
"propertyValue",
")",
";",
"}",
"}",
")",
";",
"return",
"value",
";",
"}",
"}"
] |
Computes the value for a component coming from primitive attributes,
mixins, primitive defaults, a-frame default components and schema defaults.
In this specific order.
In other words, it is the value of the component if the author would have not
overridden it explicitly.
@param {Component} component Component to calculate the value of.
@param {Element} source Element owning the component.
@return A pair with the computed value for the component of source and a flag indicating if the component is completely inherited from other sources (`true`) or genuinely owned by the source entity (`false`).
|
[
"Computes",
"the",
"value",
"for",
"a",
"component",
"coming",
"from",
"primitive",
"attributes",
"mixins",
"primitive",
"defaults",
"a",
"-",
"frame",
"default",
"components",
"and",
"schema",
"defaults",
".",
"In",
"this",
"specific",
"order",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L262-L310
|
12,602
|
aframevr/aframe-inspector
|
src/lib/entity.js
|
getFromAttribute
|
function getFromAttribute(component, propertyName, source) {
var value;
var mappings = source.mappings || {};
var route = component.name + '.' + propertyName;
var primitiveAttribute = findAttribute(mappings, route);
if (primitiveAttribute && source.hasAttribute(primitiveAttribute)) {
value = source.getAttribute(primitiveAttribute);
}
return value;
function findAttribute(mappings, route) {
var attributes = Object.keys(mappings);
for (var i = 0, l = attributes.length; i < l; i++) {
var attribute = attributes[i];
if (mappings[attribute] === route) {
return attribute;
}
}
return undefined;
}
}
|
javascript
|
function getFromAttribute(component, propertyName, source) {
var value;
var mappings = source.mappings || {};
var route = component.name + '.' + propertyName;
var primitiveAttribute = findAttribute(mappings, route);
if (primitiveAttribute && source.hasAttribute(primitiveAttribute)) {
value = source.getAttribute(primitiveAttribute);
}
return value;
function findAttribute(mappings, route) {
var attributes = Object.keys(mappings);
for (var i = 0, l = attributes.length; i < l; i++) {
var attribute = attributes[i];
if (mappings[attribute] === route) {
return attribute;
}
}
return undefined;
}
}
|
[
"function",
"getFromAttribute",
"(",
"component",
",",
"propertyName",
",",
"source",
")",
"{",
"var",
"value",
";",
"var",
"mappings",
"=",
"source",
".",
"mappings",
"||",
"{",
"}",
";",
"var",
"route",
"=",
"component",
".",
"name",
"+",
"'.'",
"+",
"propertyName",
";",
"var",
"primitiveAttribute",
"=",
"findAttribute",
"(",
"mappings",
",",
"route",
")",
";",
"if",
"(",
"primitiveAttribute",
"&&",
"source",
".",
"hasAttribute",
"(",
"primitiveAttribute",
")",
")",
"{",
"value",
"=",
"source",
".",
"getAttribute",
"(",
"primitiveAttribute",
")",
";",
"}",
"return",
"value",
";",
"function",
"findAttribute",
"(",
"mappings",
",",
"route",
")",
"{",
"var",
"attributes",
"=",
"Object",
".",
"keys",
"(",
"mappings",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"attributes",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"attribute",
"=",
"attributes",
"[",
"i",
"]",
";",
"if",
"(",
"mappings",
"[",
"attribute",
"]",
"===",
"route",
")",
"{",
"return",
"attribute",
";",
"}",
"}",
"return",
"undefined",
";",
"}",
"}"
] |
Gets the value for the component's property coming from a primitive
attribute.
Primitives have mappings from attributes to component's properties.
The function looks for a present attribute in the source element which
maps to the specified component's property.
@param {Component} component Component to be found.
@param {string} propertyName Component's property to be found.
@param {Element} source Element owning the component.
@return {any} The value of the component's property coming
from the primitive's attribute if any or
`undefined`, otherwise.
|
[
"Gets",
"the",
"value",
"for",
"the",
"component",
"s",
"property",
"coming",
"from",
"a",
"primitive",
"attribute",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L327-L347
|
12,603
|
aframevr/aframe-inspector
|
src/lib/entity.js
|
getMixedValue
|
function getMixedValue(component, propertyName, source) {
var value;
var reversedMixins = source.mixinEls.reverse();
for (var i = 0; value === undefined && i < reversedMixins.length; i++) {
var mixin = reversedMixins[i];
if (mixin.attributes.hasOwnProperty(component.name)) {
if (!propertyName) {
value = mixin.getAttribute(component.name);
} else {
value = mixin.getAttribute(component.name)[propertyName];
}
}
}
return value;
}
|
javascript
|
function getMixedValue(component, propertyName, source) {
var value;
var reversedMixins = source.mixinEls.reverse();
for (var i = 0; value === undefined && i < reversedMixins.length; i++) {
var mixin = reversedMixins[i];
if (mixin.attributes.hasOwnProperty(component.name)) {
if (!propertyName) {
value = mixin.getAttribute(component.name);
} else {
value = mixin.getAttribute(component.name)[propertyName];
}
}
}
return value;
}
|
[
"function",
"getMixedValue",
"(",
"component",
",",
"propertyName",
",",
"source",
")",
"{",
"var",
"value",
";",
"var",
"reversedMixins",
"=",
"source",
".",
"mixinEls",
".",
"reverse",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"value",
"===",
"undefined",
"&&",
"i",
"<",
"reversedMixins",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"mixin",
"=",
"reversedMixins",
"[",
"i",
"]",
";",
"if",
"(",
"mixin",
".",
"attributes",
".",
"hasOwnProperty",
"(",
"component",
".",
"name",
")",
")",
"{",
"if",
"(",
"!",
"propertyName",
")",
"{",
"value",
"=",
"mixin",
".",
"getAttribute",
"(",
"component",
".",
"name",
")",
";",
"}",
"else",
"{",
"value",
"=",
"mixin",
".",
"getAttribute",
"(",
"component",
".",
"name",
")",
"[",
"propertyName",
"]",
";",
"}",
"}",
"}",
"return",
"value",
";",
"}"
] |
Gets the value for a component or component's property coming from mixins of
an element.
If the component or component's property is not provided by mixins, the
functions will return `undefined`.
@param {Component} component Component to be found.
@param {string} [propertyName] If provided, component's property to be
found.
@param {Element} source Element owning the component.
@return The value of the component or components'
property coming from mixins of the source.
|
[
"Gets",
"the",
"value",
"for",
"a",
"component",
"or",
"component",
"s",
"property",
"coming",
"from",
"mixins",
"of",
"an",
"element",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L363-L377
|
12,604
|
aframevr/aframe-inspector
|
src/lib/entity.js
|
getInjectedValue
|
function getInjectedValue(component, propertyName, source) {
var value;
var primitiveDefaults = source.defaultComponentsFromPrimitive || {};
var aFrameDefaults = source.defaultComponents || {};
var defaultSources = [primitiveDefaults, aFrameDefaults];
for (var i = 0; value === undefined && i < defaultSources.length; i++) {
var defaults = defaultSources[i];
if (defaults.hasOwnProperty(component.name)) {
if (!propertyName) {
value = defaults[component.name];
} else {
value = defaults[component.name][propertyName];
}
}
}
return value;
}
|
javascript
|
function getInjectedValue(component, propertyName, source) {
var value;
var primitiveDefaults = source.defaultComponentsFromPrimitive || {};
var aFrameDefaults = source.defaultComponents || {};
var defaultSources = [primitiveDefaults, aFrameDefaults];
for (var i = 0; value === undefined && i < defaultSources.length; i++) {
var defaults = defaultSources[i];
if (defaults.hasOwnProperty(component.name)) {
if (!propertyName) {
value = defaults[component.name];
} else {
value = defaults[component.name][propertyName];
}
}
}
return value;
}
|
[
"function",
"getInjectedValue",
"(",
"component",
",",
"propertyName",
",",
"source",
")",
"{",
"var",
"value",
";",
"var",
"primitiveDefaults",
"=",
"source",
".",
"defaultComponentsFromPrimitive",
"||",
"{",
"}",
";",
"var",
"aFrameDefaults",
"=",
"source",
".",
"defaultComponents",
"||",
"{",
"}",
";",
"var",
"defaultSources",
"=",
"[",
"primitiveDefaults",
",",
"aFrameDefaults",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"value",
"===",
"undefined",
"&&",
"i",
"<",
"defaultSources",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"defaults",
"=",
"defaultSources",
"[",
"i",
"]",
";",
"if",
"(",
"defaults",
".",
"hasOwnProperty",
"(",
"component",
".",
"name",
")",
")",
"{",
"if",
"(",
"!",
"propertyName",
")",
"{",
"value",
"=",
"defaults",
"[",
"component",
".",
"name",
"]",
";",
"}",
"else",
"{",
"value",
"=",
"defaults",
"[",
"component",
".",
"name",
"]",
"[",
"propertyName",
"]",
";",
"}",
"}",
"}",
"return",
"value",
";",
"}"
] |
Gets the value for a component or component's property coming from primitive
defaults or a-frame defaults. In this specific order.
@param {Component} component Component to be found.
@param {string} [propertyName] If provided, component's property to be
found.
@param {Element} source Element owning the component.
@return The component value coming from the
injected default components of source.
|
[
"Gets",
"the",
"value",
"for",
"a",
"component",
"or",
"component",
"s",
"property",
"coming",
"from",
"primitive",
"defaults",
"or",
"a",
"-",
"frame",
"defaults",
".",
"In",
"this",
"specific",
"order",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L390-L406
|
12,605
|
aframevr/aframe-inspector
|
src/lib/entity.js
|
getDefaultValue
|
function getDefaultValue(component, propertyName, source) {
if (!propertyName) {
return component.schema.default;
}
return component.schema[propertyName].default;
}
|
javascript
|
function getDefaultValue(component, propertyName, source) {
if (!propertyName) {
return component.schema.default;
}
return component.schema[propertyName].default;
}
|
[
"function",
"getDefaultValue",
"(",
"component",
",",
"propertyName",
",",
"source",
")",
"{",
"if",
"(",
"!",
"propertyName",
")",
"{",
"return",
"component",
".",
"schema",
".",
"default",
";",
"}",
"return",
"component",
".",
"schema",
"[",
"propertyName",
"]",
".",
"default",
";",
"}"
] |
Gets the value for a component or component's property coming from schema
defaults.
@param {Component} component Component to be found.
@param {string} [propertyName] If provided, component's property to be
found.
@param {Element} source Element owning the component.
@return The component value coming from the schema
default.
|
[
"Gets",
"the",
"value",
"for",
"a",
"component",
"or",
"component",
"s",
"property",
"coming",
"from",
"schema",
"defaults",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L419-L424
|
12,606
|
aframevr/aframe-inspector
|
src/lib/entity.js
|
getOptimalUpdate
|
function getOptimalUpdate(component, implicit, reference) {
if (equal(implicit, reference)) {
return null;
}
if (isSingleProperty(component.schema)) {
return reference;
}
var optimal = {};
Object.keys(reference).forEach(function(key) {
var needsUpdate = !equal(reference[key], implicit[key]);
if (needsUpdate) {
optimal[key] = reference[key];
}
});
return optimal;
}
|
javascript
|
function getOptimalUpdate(component, implicit, reference) {
if (equal(implicit, reference)) {
return null;
}
if (isSingleProperty(component.schema)) {
return reference;
}
var optimal = {};
Object.keys(reference).forEach(function(key) {
var needsUpdate = !equal(reference[key], implicit[key]);
if (needsUpdate) {
optimal[key] = reference[key];
}
});
return optimal;
}
|
[
"function",
"getOptimalUpdate",
"(",
"component",
",",
"implicit",
",",
"reference",
")",
"{",
"if",
"(",
"equal",
"(",
"implicit",
",",
"reference",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"isSingleProperty",
"(",
"component",
".",
"schema",
")",
")",
"{",
"return",
"reference",
";",
"}",
"var",
"optimal",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"reference",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"needsUpdate",
"=",
"!",
"equal",
"(",
"reference",
"[",
"key",
"]",
",",
"implicit",
"[",
"key",
"]",
")",
";",
"if",
"(",
"needsUpdate",
")",
"{",
"optimal",
"[",
"key",
"]",
"=",
"reference",
"[",
"key",
"]",
";",
"}",
"}",
")",
";",
"return",
"optimal",
";",
"}"
] |
Returns the minimum value for a component with an implicit value to equal a
reference value. A `null` optimal value means that there is no need for an
update since the implicit value and the reference are equal.
@param {Component} component Component of the computed value.
@param {any} implicit The implicit value of the component.
@param {any} reference The reference value for the component.
@return the minimum value making the component to equal
the reference value.
|
[
"Returns",
"the",
"minimum",
"value",
"for",
"a",
"component",
"with",
"an",
"implicit",
"value",
"to",
"equal",
"a",
"reference",
"value",
".",
"A",
"null",
"optimal",
"value",
"means",
"that",
"there",
"is",
"no",
"need",
"for",
"an",
"update",
"since",
"the",
"implicit",
"value",
"and",
"the",
"reference",
"are",
"equal",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L437-L452
|
12,607
|
aframevr/aframe-inspector
|
src/lib/entity.js
|
getUniqueId
|
function getUniqueId(baseId) {
if (!document.getElementById(baseId)) {
return baseId;
}
var i = 2;
// If the baseId ends with _#, it extracts the baseId removing the suffix
var groups = baseId.match(/(\w+)-(\d+)/);
if (groups) {
baseId = groups[1];
i = groups[2];
}
while (document.getElementById(baseId + '-' + i)) {
i++;
}
return baseId + '-' + i;
}
|
javascript
|
function getUniqueId(baseId) {
if (!document.getElementById(baseId)) {
return baseId;
}
var i = 2;
// If the baseId ends with _#, it extracts the baseId removing the suffix
var groups = baseId.match(/(\w+)-(\d+)/);
if (groups) {
baseId = groups[1];
i = groups[2];
}
while (document.getElementById(baseId + '-' + i)) {
i++;
}
return baseId + '-' + i;
}
|
[
"function",
"getUniqueId",
"(",
"baseId",
")",
"{",
"if",
"(",
"!",
"document",
".",
"getElementById",
"(",
"baseId",
")",
")",
"{",
"return",
"baseId",
";",
"}",
"var",
"i",
"=",
"2",
";",
"// If the baseId ends with _#, it extracts the baseId removing the suffix",
"var",
"groups",
"=",
"baseId",
".",
"match",
"(",
"/",
"(\\w+)-(\\d+)",
"/",
")",
";",
"if",
"(",
"groups",
")",
"{",
"baseId",
"=",
"groups",
"[",
"1",
"]",
";",
"i",
"=",
"groups",
"[",
"2",
"]",
";",
"}",
"while",
"(",
"document",
".",
"getElementById",
"(",
"baseId",
"+",
"'-'",
"+",
"i",
")",
")",
"{",
"i",
"++",
";",
"}",
"return",
"baseId",
"+",
"'-'",
"+",
"i",
";",
"}"
] |
Detect element's Id collision and returns a valid one
@param {string} baseId Proposed Id
@return {string} Valid Id based on the proposed Id
|
[
"Detect",
"element",
"s",
"Id",
"collision",
"and",
"returns",
"a",
"valid",
"one"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L467-L485
|
12,608
|
aframevr/aframe-inspector
|
src/lib/entity.js
|
getModifiedProperties
|
function getModifiedProperties(entity, componentName) {
var data = entity.components[componentName].data;
var defaultData = entity.components[componentName].schema;
var diff = {};
for (var key in data) {
// Prevent adding unknown attributes
if (!defaultData[key]) {
continue;
}
var defaultValue = defaultData[key].default;
var currentValue = data[key];
// Some parameters could be null and '' like mergeTo
if ((currentValue || defaultValue) && currentValue !== defaultValue) {
diff[key] = data[key];
}
}
return diff;
}
|
javascript
|
function getModifiedProperties(entity, componentName) {
var data = entity.components[componentName].data;
var defaultData = entity.components[componentName].schema;
var diff = {};
for (var key in data) {
// Prevent adding unknown attributes
if (!defaultData[key]) {
continue;
}
var defaultValue = defaultData[key].default;
var currentValue = data[key];
// Some parameters could be null and '' like mergeTo
if ((currentValue || defaultValue) && currentValue !== defaultValue) {
diff[key] = data[key];
}
}
return diff;
}
|
[
"function",
"getModifiedProperties",
"(",
"entity",
",",
"componentName",
")",
"{",
"var",
"data",
"=",
"entity",
".",
"components",
"[",
"componentName",
"]",
".",
"data",
";",
"var",
"defaultData",
"=",
"entity",
".",
"components",
"[",
"componentName",
"]",
".",
"schema",
";",
"var",
"diff",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"data",
")",
"{",
"// Prevent adding unknown attributes",
"if",
"(",
"!",
"defaultData",
"[",
"key",
"]",
")",
"{",
"continue",
";",
"}",
"var",
"defaultValue",
"=",
"defaultData",
"[",
"key",
"]",
".",
"default",
";",
"var",
"currentValue",
"=",
"data",
"[",
"key",
"]",
";",
"// Some parameters could be null and '' like mergeTo",
"if",
"(",
"(",
"currentValue",
"||",
"defaultValue",
")",
"&&",
"currentValue",
"!==",
"defaultValue",
")",
"{",
"diff",
"[",
"key",
"]",
"=",
"data",
"[",
"key",
"]",
";",
"}",
"}",
"return",
"diff",
";",
"}"
] |
Get the list of modified properties
@param {Element} entity Entity where the component belongs
@param {string} componentName Component name
@return {object} List of modified properties with their value
|
[
"Get",
"the",
"list",
"of",
"modified",
"properties"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L494-L513
|
12,609
|
aframevr/aframe-inspector
|
src/index.js
|
function(focusEl) {
this.opened = true;
Events.emit('inspectortoggle', true);
if (this.sceneEl.hasAttribute('embedded')) {
// Remove embedded styles, but keep track of it.
this.sceneEl.removeAttribute('embedded');
this.sceneEl.setAttribute('aframe-inspector-removed-embedded');
}
document.body.classList.add('aframe-inspector-opened');
this.sceneEl.resize();
this.sceneEl.pause();
this.sceneEl.exitVR();
Shortcuts.enable();
// Trick scene to run the cursor tick.
this.sceneEl.isPlaying = true;
this.cursor.play();
if (
!focusEl &&
this.isFirstOpen &&
AFRAME.utils.getUrlParameter('inspector')
) {
// Focus entity with URL parameter on first open.
focusEl = document.getElementById(
AFRAME.utils.getUrlParameter('inspector')
);
}
if (focusEl) {
this.selectEntity(focusEl);
Events.emit('objectfocus', focusEl.object3D);
}
this.isFirstOpen = false;
}
|
javascript
|
function(focusEl) {
this.opened = true;
Events.emit('inspectortoggle', true);
if (this.sceneEl.hasAttribute('embedded')) {
// Remove embedded styles, but keep track of it.
this.sceneEl.removeAttribute('embedded');
this.sceneEl.setAttribute('aframe-inspector-removed-embedded');
}
document.body.classList.add('aframe-inspector-opened');
this.sceneEl.resize();
this.sceneEl.pause();
this.sceneEl.exitVR();
Shortcuts.enable();
// Trick scene to run the cursor tick.
this.sceneEl.isPlaying = true;
this.cursor.play();
if (
!focusEl &&
this.isFirstOpen &&
AFRAME.utils.getUrlParameter('inspector')
) {
// Focus entity with URL parameter on first open.
focusEl = document.getElementById(
AFRAME.utils.getUrlParameter('inspector')
);
}
if (focusEl) {
this.selectEntity(focusEl);
Events.emit('objectfocus', focusEl.object3D);
}
this.isFirstOpen = false;
}
|
[
"function",
"(",
"focusEl",
")",
"{",
"this",
".",
"opened",
"=",
"true",
";",
"Events",
".",
"emit",
"(",
"'inspectortoggle'",
",",
"true",
")",
";",
"if",
"(",
"this",
".",
"sceneEl",
".",
"hasAttribute",
"(",
"'embedded'",
")",
")",
"{",
"// Remove embedded styles, but keep track of it.",
"this",
".",
"sceneEl",
".",
"removeAttribute",
"(",
"'embedded'",
")",
";",
"this",
".",
"sceneEl",
".",
"setAttribute",
"(",
"'aframe-inspector-removed-embedded'",
")",
";",
"}",
"document",
".",
"body",
".",
"classList",
".",
"add",
"(",
"'aframe-inspector-opened'",
")",
";",
"this",
".",
"sceneEl",
".",
"resize",
"(",
")",
";",
"this",
".",
"sceneEl",
".",
"pause",
"(",
")",
";",
"this",
".",
"sceneEl",
".",
"exitVR",
"(",
")",
";",
"Shortcuts",
".",
"enable",
"(",
")",
";",
"// Trick scene to run the cursor tick.",
"this",
".",
"sceneEl",
".",
"isPlaying",
"=",
"true",
";",
"this",
".",
"cursor",
".",
"play",
"(",
")",
";",
"if",
"(",
"!",
"focusEl",
"&&",
"this",
".",
"isFirstOpen",
"&&",
"AFRAME",
".",
"utils",
".",
"getUrlParameter",
"(",
"'inspector'",
")",
")",
"{",
"// Focus entity with URL parameter on first open.",
"focusEl",
"=",
"document",
".",
"getElementById",
"(",
"AFRAME",
".",
"utils",
".",
"getUrlParameter",
"(",
"'inspector'",
")",
")",
";",
"}",
"if",
"(",
"focusEl",
")",
"{",
"this",
".",
"selectEntity",
"(",
"focusEl",
")",
";",
"Events",
".",
"emit",
"(",
"'objectfocus'",
",",
"focusEl",
".",
"object3D",
")",
";",
"}",
"this",
".",
"isFirstOpen",
"=",
"false",
";",
"}"
] |
Open the editor UI
|
[
"Open",
"the",
"editor",
"UI"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/index.js#L244-L280
|
|
12,610
|
aframevr/aframe-inspector
|
src/index.js
|
function() {
this.opened = false;
Events.emit('inspectortoggle', false);
// Untrick scene when we enabled this to run the cursor tick.
this.sceneEl.isPlaying = false;
this.sceneEl.play();
this.cursor.pause();
if (this.sceneEl.hasAttribute('aframe-inspector-removed-embedded')) {
this.sceneEl.setAttribute('embedded', '');
this.sceneEl.removeAttribute('aframe-inspector-removed-embedded');
}
document.body.classList.remove('aframe-inspector-opened');
this.sceneEl.resize();
Shortcuts.disable();
}
|
javascript
|
function() {
this.opened = false;
Events.emit('inspectortoggle', false);
// Untrick scene when we enabled this to run the cursor tick.
this.sceneEl.isPlaying = false;
this.sceneEl.play();
this.cursor.pause();
if (this.sceneEl.hasAttribute('aframe-inspector-removed-embedded')) {
this.sceneEl.setAttribute('embedded', '');
this.sceneEl.removeAttribute('aframe-inspector-removed-embedded');
}
document.body.classList.remove('aframe-inspector-opened');
this.sceneEl.resize();
Shortcuts.disable();
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"opened",
"=",
"false",
";",
"Events",
".",
"emit",
"(",
"'inspectortoggle'",
",",
"false",
")",
";",
"// Untrick scene when we enabled this to run the cursor tick.",
"this",
".",
"sceneEl",
".",
"isPlaying",
"=",
"false",
";",
"this",
".",
"sceneEl",
".",
"play",
"(",
")",
";",
"this",
".",
"cursor",
".",
"pause",
"(",
")",
";",
"if",
"(",
"this",
".",
"sceneEl",
".",
"hasAttribute",
"(",
"'aframe-inspector-removed-embedded'",
")",
")",
"{",
"this",
".",
"sceneEl",
".",
"setAttribute",
"(",
"'embedded'",
",",
"''",
")",
";",
"this",
".",
"sceneEl",
".",
"removeAttribute",
"(",
"'aframe-inspector-removed-embedded'",
")",
";",
"}",
"document",
".",
"body",
".",
"classList",
".",
"remove",
"(",
"'aframe-inspector-opened'",
")",
";",
"this",
".",
"sceneEl",
".",
"resize",
"(",
")",
";",
"Shortcuts",
".",
"disable",
"(",
")",
";",
"}"
] |
Closes the editor and gives the control back to the scene
@return {[type]} [description]
|
[
"Closes",
"the",
"editor",
"and",
"gives",
"the",
"control",
"back",
"to",
"the",
"scene"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/index.js#L286-L303
|
|
12,611
|
aframevr/aframe-inspector
|
src/lib/assetsLoader.js
|
function() {
var xhr = new XMLHttpRequest();
var url = assetsBaseUrl + assetsRelativeUrl['images'];
// @todo Remove the sync call and use a callback
xhr.open('GET', url);
xhr.onload = () => {
var data = JSON.parse(xhr.responseText);
this.images = data.images;
this.images.forEach(image => {
image.fullPath = assetsBaseUrl + data.basepath.images + image.path;
image.fullThumbPath =
assetsBaseUrl + data.basepath.images_thumbnails + image.thumbnail;
});
Events.emit('assetsimagesload', this.images);
};
xhr.onerror = () => {
console.error('Error loading registry file.');
};
xhr.send();
this.hasLoaded = true;
}
|
javascript
|
function() {
var xhr = new XMLHttpRequest();
var url = assetsBaseUrl + assetsRelativeUrl['images'];
// @todo Remove the sync call and use a callback
xhr.open('GET', url);
xhr.onload = () => {
var data = JSON.parse(xhr.responseText);
this.images = data.images;
this.images.forEach(image => {
image.fullPath = assetsBaseUrl + data.basepath.images + image.path;
image.fullThumbPath =
assetsBaseUrl + data.basepath.images_thumbnails + image.thumbnail;
});
Events.emit('assetsimagesload', this.images);
};
xhr.onerror = () => {
console.error('Error loading registry file.');
};
xhr.send();
this.hasLoaded = true;
}
|
[
"function",
"(",
")",
"{",
"var",
"xhr",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"var",
"url",
"=",
"assetsBaseUrl",
"+",
"assetsRelativeUrl",
"[",
"'images'",
"]",
";",
"// @todo Remove the sync call and use a callback",
"xhr",
".",
"open",
"(",
"'GET'",
",",
"url",
")",
";",
"xhr",
".",
"onload",
"=",
"(",
")",
"=>",
"{",
"var",
"data",
"=",
"JSON",
".",
"parse",
"(",
"xhr",
".",
"responseText",
")",
";",
"this",
".",
"images",
"=",
"data",
".",
"images",
";",
"this",
".",
"images",
".",
"forEach",
"(",
"image",
"=>",
"{",
"image",
".",
"fullPath",
"=",
"assetsBaseUrl",
"+",
"data",
".",
"basepath",
".",
"images",
"+",
"image",
".",
"path",
";",
"image",
".",
"fullThumbPath",
"=",
"assetsBaseUrl",
"+",
"data",
".",
"basepath",
".",
"images_thumbnails",
"+",
"image",
".",
"thumbnail",
";",
"}",
")",
";",
"Events",
".",
"emit",
"(",
"'assetsimagesload'",
",",
"this",
".",
"images",
")",
";",
"}",
";",
"xhr",
".",
"onerror",
"=",
"(",
")",
"=>",
"{",
"console",
".",
"error",
"(",
"'Error loading registry file.'",
")",
";",
"}",
";",
"xhr",
".",
"send",
"(",
")",
";",
"this",
".",
"hasLoaded",
"=",
"true",
";",
"}"
] |
XHR the assets JSON.
|
[
"XHR",
"the",
"assets",
"JSON",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/assetsLoader.js#L19-L42
|
|
12,612
|
aframevr/aframe-inspector
|
src/lib/raycaster.js
|
onDoubleClick
|
function onDoubleClick(event) {
const array = getMousePosition(
inspector.container,
event.clientX,
event.clientY
);
onDoubleClickPosition.fromArray(array);
const intersectedEl = mouseCursor.components.cursor.intersectedEl;
if (!intersectedEl) {
return;
}
Events.emit('objectfocus', intersectedEl.object3D);
}
|
javascript
|
function onDoubleClick(event) {
const array = getMousePosition(
inspector.container,
event.clientX,
event.clientY
);
onDoubleClickPosition.fromArray(array);
const intersectedEl = mouseCursor.components.cursor.intersectedEl;
if (!intersectedEl) {
return;
}
Events.emit('objectfocus', intersectedEl.object3D);
}
|
[
"function",
"onDoubleClick",
"(",
"event",
")",
"{",
"const",
"array",
"=",
"getMousePosition",
"(",
"inspector",
".",
"container",
",",
"event",
".",
"clientX",
",",
"event",
".",
"clientY",
")",
";",
"onDoubleClickPosition",
".",
"fromArray",
"(",
"array",
")",
";",
"const",
"intersectedEl",
"=",
"mouseCursor",
".",
"components",
".",
"cursor",
".",
"intersectedEl",
";",
"if",
"(",
"!",
"intersectedEl",
")",
"{",
"return",
";",
"}",
"Events",
".",
"emit",
"(",
"'objectfocus'",
",",
"intersectedEl",
".",
"object3D",
")",
";",
"}"
] |
Focus on double click.
|
[
"Focus",
"on",
"double",
"click",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/raycaster.js#L127-L139
|
12,613
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
equalArray
|
function equalArray(array1, array2) {
return (
array1.length === array2.length &&
array1.every(function(element, index) {
return element === array2[index];
})
);
}
|
javascript
|
function equalArray(array1, array2) {
return (
array1.length === array2.length &&
array1.every(function(element, index) {
return element === array2[index];
})
);
}
|
[
"function",
"equalArray",
"(",
"array1",
",",
"array2",
")",
"{",
"return",
"(",
"array1",
".",
"length",
"===",
"array2",
".",
"length",
"&&",
"array1",
".",
"every",
"(",
"function",
"(",
"element",
",",
"index",
")",
"{",
"return",
"element",
"===",
"array2",
"[",
"index",
"]",
";",
"}",
")",
")",
";",
"}"
] |
Compare two arrays
Compare two arrays
@param {Array} array1 Array 1 to compare
@param {Array} array2 Array 2 to compare
@return {Boolean} Returns true if both arrays are equal
|
[
"Compare",
"two",
"arrays",
"Compare",
"two",
"arrays"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L115-L122
|
12,614
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
stringToArrayBuffer
|
function stringToArrayBuffer(text) {
if (window.TextEncoder !== undefined) {
return new TextEncoder().encode(text).buffer;
}
var array = new Uint8Array(new ArrayBuffer(text.length));
for (var i = 0, il = text.length; i < il; i++) {
var value = text.charCodeAt(i);
// Replacing multi-byte character with space(0x20).
array[i] = value > 0xff ? 0x20 : value;
}
return array.buffer;
}
|
javascript
|
function stringToArrayBuffer(text) {
if (window.TextEncoder !== undefined) {
return new TextEncoder().encode(text).buffer;
}
var array = new Uint8Array(new ArrayBuffer(text.length));
for (var i = 0, il = text.length; i < il; i++) {
var value = text.charCodeAt(i);
// Replacing multi-byte character with space(0x20).
array[i] = value > 0xff ? 0x20 : value;
}
return array.buffer;
}
|
[
"function",
"stringToArrayBuffer",
"(",
"text",
")",
"{",
"if",
"(",
"window",
".",
"TextEncoder",
"!==",
"undefined",
")",
"{",
"return",
"new",
"TextEncoder",
"(",
")",
".",
"encode",
"(",
"text",
")",
".",
"buffer",
";",
"}",
"var",
"array",
"=",
"new",
"Uint8Array",
"(",
"new",
"ArrayBuffer",
"(",
"text",
".",
"length",
")",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"text",
".",
"length",
";",
"i",
"<",
"il",
";",
"i",
"++",
")",
"{",
"var",
"value",
"=",
"text",
".",
"charCodeAt",
"(",
"i",
")",
";",
"// Replacing multi-byte character with space(0x20).",
"array",
"[",
"i",
"]",
"=",
"value",
">",
"0xff",
"?",
"0x20",
":",
"value",
";",
"}",
"return",
"array",
".",
"buffer",
";",
"}"
] |
Converts a string to an ArrayBuffer.
@param {string} text
@return {ArrayBuffer}
|
[
"Converts",
"a",
"string",
"to",
"an",
"ArrayBuffer",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L129-L144
|
12,615
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
getMinMax
|
function getMinMax(attribute, start, count) {
var output = {
min: new Array(attribute.itemSize).fill(Number.POSITIVE_INFINITY),
max: new Array(attribute.itemSize).fill(Number.NEGATIVE_INFINITY)
};
for (var i = start; i < start + count; i++) {
for (var a = 0; a < attribute.itemSize; a++) {
var value = attribute.array[i * attribute.itemSize + a];
output.min[a] = Math.min(output.min[a], value);
output.max[a] = Math.max(output.max[a], value);
}
}
return output;
}
|
javascript
|
function getMinMax(attribute, start, count) {
var output = {
min: new Array(attribute.itemSize).fill(Number.POSITIVE_INFINITY),
max: new Array(attribute.itemSize).fill(Number.NEGATIVE_INFINITY)
};
for (var i = start; i < start + count; i++) {
for (var a = 0; a < attribute.itemSize; a++) {
var value = attribute.array[i * attribute.itemSize + a];
output.min[a] = Math.min(output.min[a], value);
output.max[a] = Math.max(output.max[a], value);
}
}
return output;
}
|
[
"function",
"getMinMax",
"(",
"attribute",
",",
"start",
",",
"count",
")",
"{",
"var",
"output",
"=",
"{",
"min",
":",
"new",
"Array",
"(",
"attribute",
".",
"itemSize",
")",
".",
"fill",
"(",
"Number",
".",
"POSITIVE_INFINITY",
")",
",",
"max",
":",
"new",
"Array",
"(",
"attribute",
".",
"itemSize",
")",
".",
"fill",
"(",
"Number",
".",
"NEGATIVE_INFINITY",
")",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"start",
";",
"i",
"<",
"start",
"+",
"count",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"a",
"=",
"0",
";",
"a",
"<",
"attribute",
".",
"itemSize",
";",
"a",
"++",
")",
"{",
"var",
"value",
"=",
"attribute",
".",
"array",
"[",
"i",
"*",
"attribute",
".",
"itemSize",
"+",
"a",
"]",
";",
"output",
".",
"min",
"[",
"a",
"]",
"=",
"Math",
".",
"min",
"(",
"output",
".",
"min",
"[",
"a",
"]",
",",
"value",
")",
";",
"output",
".",
"max",
"[",
"a",
"]",
"=",
"Math",
".",
"max",
"(",
"output",
".",
"max",
"[",
"a",
"]",
",",
"value",
")",
";",
"}",
"}",
"return",
"output",
";",
"}"
] |
Get the min and max vectors from the given attribute
@param {THREE.BufferAttribute} attribute Attribute to find the min/max in range from start to start + count
@param {Integer} start
@param {Integer} count
@return {Object} Object containing the `min` and `max` values (As an array of attribute.itemSize components)
|
[
"Get",
"the",
"min",
"and",
"max",
"vectors",
"from",
"the",
"given",
"attribute"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L153-L168
|
12,616
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
isNormalizedNormalAttribute
|
function isNormalizedNormalAttribute(normal) {
if (cachedData.attributes.has(normal)) {
return false;
}
var v = new THREE.Vector3();
for (var i = 0, il = normal.count; i < il; i++) {
// 0.0005 is from glTF-validator
if (Math.abs(v.fromArray(normal.array, i * 3).length() - 1.0) > 0.0005)
return false;
}
return true;
}
|
javascript
|
function isNormalizedNormalAttribute(normal) {
if (cachedData.attributes.has(normal)) {
return false;
}
var v = new THREE.Vector3();
for (var i = 0, il = normal.count; i < il; i++) {
// 0.0005 is from glTF-validator
if (Math.abs(v.fromArray(normal.array, i * 3).length() - 1.0) > 0.0005)
return false;
}
return true;
}
|
[
"function",
"isNormalizedNormalAttribute",
"(",
"normal",
")",
"{",
"if",
"(",
"cachedData",
".",
"attributes",
".",
"has",
"(",
"normal",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"v",
"=",
"new",
"THREE",
".",
"Vector3",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"normal",
".",
"count",
";",
"i",
"<",
"il",
";",
"i",
"++",
")",
"{",
"// 0.0005 is from glTF-validator",
"if",
"(",
"Math",
".",
"abs",
"(",
"v",
".",
"fromArray",
"(",
"normal",
".",
"array",
",",
"i",
"*",
"3",
")",
".",
"length",
"(",
")",
"-",
"1.0",
")",
">",
"0.0005",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if normal attribute values are normalized.
@param {THREE.BufferAttribute} normal
@returns {Boolean}
|
[
"Checks",
"if",
"normal",
"attribute",
"values",
"are",
"normalized",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L191-L205
|
12,617
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
createNormalizedNormalAttribute
|
function createNormalizedNormalAttribute(normal) {
if (cachedData.attributes.has(normal)) {
return cachedData.attributes.get(normal);
}
var attribute = normal.clone();
var v = new THREE.Vector3();
for (var i = 0, il = attribute.count; i < il; i++) {
v.fromArray(attribute.array, i * 3);
if (v.x === 0 && v.y === 0 && v.z === 0) {
// if values can't be normalized set (1, 0, 0)
v.setX(1.0);
} else {
v.normalize();
}
v.toArray(attribute.array, i * 3);
}
cachedData.attributes.set(normal, attribute);
return attribute;
}
|
javascript
|
function createNormalizedNormalAttribute(normal) {
if (cachedData.attributes.has(normal)) {
return cachedData.attributes.get(normal);
}
var attribute = normal.clone();
var v = new THREE.Vector3();
for (var i = 0, il = attribute.count; i < il; i++) {
v.fromArray(attribute.array, i * 3);
if (v.x === 0 && v.y === 0 && v.z === 0) {
// if values can't be normalized set (1, 0, 0)
v.setX(1.0);
} else {
v.normalize();
}
v.toArray(attribute.array, i * 3);
}
cachedData.attributes.set(normal, attribute);
return attribute;
}
|
[
"function",
"createNormalizedNormalAttribute",
"(",
"normal",
")",
"{",
"if",
"(",
"cachedData",
".",
"attributes",
".",
"has",
"(",
"normal",
")",
")",
"{",
"return",
"cachedData",
".",
"attributes",
".",
"get",
"(",
"normal",
")",
";",
"}",
"var",
"attribute",
"=",
"normal",
".",
"clone",
"(",
")",
";",
"var",
"v",
"=",
"new",
"THREE",
".",
"Vector3",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"attribute",
".",
"count",
";",
"i",
"<",
"il",
";",
"i",
"++",
")",
"{",
"v",
".",
"fromArray",
"(",
"attribute",
".",
"array",
",",
"i",
"*",
"3",
")",
";",
"if",
"(",
"v",
".",
"x",
"===",
"0",
"&&",
"v",
".",
"y",
"===",
"0",
"&&",
"v",
".",
"z",
"===",
"0",
")",
"{",
"// if values can't be normalized set (1, 0, 0)",
"v",
".",
"setX",
"(",
"1.0",
")",
";",
"}",
"else",
"{",
"v",
".",
"normalize",
"(",
")",
";",
"}",
"v",
".",
"toArray",
"(",
"attribute",
".",
"array",
",",
"i",
"*",
"3",
")",
";",
"}",
"cachedData",
".",
"attributes",
".",
"set",
"(",
"normal",
",",
"attribute",
")",
";",
"return",
"attribute",
";",
"}"
] |
Creates normalized normal buffer attribute.
@param {THREE.BufferAttribute} normal
@returns {THREE.BufferAttribute}
|
[
"Creates",
"normalized",
"normal",
"buffer",
"attribute",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L214-L239
|
12,618
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
getPaddedArrayBuffer
|
function getPaddedArrayBuffer(arrayBuffer, paddingByte) {
paddingByte = paddingByte || 0;
var paddedLength = getPaddedBufferSize(arrayBuffer.byteLength);
if (paddedLength !== arrayBuffer.byteLength) {
var array = new Uint8Array(paddedLength);
array.set(new Uint8Array(arrayBuffer));
if (paddingByte !== 0) {
for (var i = arrayBuffer.byteLength; i < paddedLength; i++) {
array[i] = paddingByte;
}
}
return array.buffer;
}
return arrayBuffer;
}
|
javascript
|
function getPaddedArrayBuffer(arrayBuffer, paddingByte) {
paddingByte = paddingByte || 0;
var paddedLength = getPaddedBufferSize(arrayBuffer.byteLength);
if (paddedLength !== arrayBuffer.byteLength) {
var array = new Uint8Array(paddedLength);
array.set(new Uint8Array(arrayBuffer));
if (paddingByte !== 0) {
for (var i = arrayBuffer.byteLength; i < paddedLength; i++) {
array[i] = paddingByte;
}
}
return array.buffer;
}
return arrayBuffer;
}
|
[
"function",
"getPaddedArrayBuffer",
"(",
"arrayBuffer",
",",
"paddingByte",
")",
"{",
"paddingByte",
"=",
"paddingByte",
"||",
"0",
";",
"var",
"paddedLength",
"=",
"getPaddedBufferSize",
"(",
"arrayBuffer",
".",
"byteLength",
")",
";",
"if",
"(",
"paddedLength",
"!==",
"arrayBuffer",
".",
"byteLength",
")",
"{",
"var",
"array",
"=",
"new",
"Uint8Array",
"(",
"paddedLength",
")",
";",
"array",
".",
"set",
"(",
"new",
"Uint8Array",
"(",
"arrayBuffer",
")",
")",
";",
"if",
"(",
"paddingByte",
"!==",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"arrayBuffer",
".",
"byteLength",
";",
"i",
"<",
"paddedLength",
";",
"i",
"++",
")",
"{",
"array",
"[",
"i",
"]",
"=",
"paddingByte",
";",
"}",
"}",
"return",
"array",
".",
"buffer",
";",
"}",
"return",
"arrayBuffer",
";",
"}"
] |
Returns a buffer aligned to 4-byte boundary.
@param {ArrayBuffer} arrayBuffer Buffer to pad
@param {Integer} paddingByte (Optional)
@returns {ArrayBuffer} The same buffer if it's already aligned to 4-byte boundary or a new buffer
|
[
"Returns",
"a",
"buffer",
"aligned",
"to",
"4",
"-",
"byte",
"boundary",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L260-L279
|
12,619
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
serializeUserData
|
function serializeUserData(object) {
try {
return JSON.parse(JSON.stringify(object.userData));
} catch (error) {
console.warn(
"THREE.GLTFExporter: userData of '" +
object.name +
"' " +
"won't be serialized because of JSON.stringify error - " +
error.message
);
return {};
}
}
|
javascript
|
function serializeUserData(object) {
try {
return JSON.parse(JSON.stringify(object.userData));
} catch (error) {
console.warn(
"THREE.GLTFExporter: userData of '" +
object.name +
"' " +
"won't be serialized because of JSON.stringify error - " +
error.message
);
return {};
}
}
|
[
"function",
"serializeUserData",
"(",
"object",
")",
"{",
"try",
"{",
"return",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"object",
".",
"userData",
")",
")",
";",
"}",
"catch",
"(",
"error",
")",
"{",
"console",
".",
"warn",
"(",
"\"THREE.GLTFExporter: userData of '\"",
"+",
"object",
".",
"name",
"+",
"\"' \"",
"+",
"\"won't be serialized because of JSON.stringify error - \"",
"+",
"error",
".",
"message",
")",
";",
"return",
"{",
"}",
";",
"}",
"}"
] |
Serializes a userData.
@param {THREE.Object3D|THREE.Material} object
@returns {Object}
|
[
"Serializes",
"a",
"userData",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L287-L301
|
12,620
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
processBuffer
|
function processBuffer(buffer) {
if (!outputJSON.buffers) {
outputJSON.buffers = [{ byteLength: 0 }];
}
// All buffers are merged before export.
buffers.push(buffer);
return 0;
}
|
javascript
|
function processBuffer(buffer) {
if (!outputJSON.buffers) {
outputJSON.buffers = [{ byteLength: 0 }];
}
// All buffers are merged before export.
buffers.push(buffer);
return 0;
}
|
[
"function",
"processBuffer",
"(",
"buffer",
")",
"{",
"if",
"(",
"!",
"outputJSON",
".",
"buffers",
")",
"{",
"outputJSON",
".",
"buffers",
"=",
"[",
"{",
"byteLength",
":",
"0",
"}",
"]",
";",
"}",
"// All buffers are merged before export.",
"buffers",
".",
"push",
"(",
"buffer",
")",
";",
"return",
"0",
";",
"}"
] |
Process a buffer to append to the default one.
@param {ArrayBuffer} buffer
@return {Integer}
|
[
"Process",
"a",
"buffer",
"to",
"append",
"to",
"the",
"default",
"one",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L308-L317
|
12,621
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
processBufferView
|
function processBufferView(attribute, componentType, start, count, target) {
if (!outputJSON.bufferViews) {
outputJSON.bufferViews = [];
}
// Create a new dataview and dump the attribute's array into it
var componentSize;
if (componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE) {
componentSize = 1;
} else if (componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT) {
componentSize = 2;
} else {
componentSize = 4;
}
var byteLength = getPaddedBufferSize(
count * attribute.itemSize * componentSize
);
var dataView = new DataView(new ArrayBuffer(byteLength));
var offset = 0;
for (var i = start; i < start + count; i++) {
for (var a = 0; a < attribute.itemSize; a++) {
// @TODO Fails on InterleavedBufferAttribute, and could probably be
// optimized for normal BufferAttribute.
var value = attribute.array[i * attribute.itemSize + a];
if (componentType === WEBGL_CONSTANTS.FLOAT) {
dataView.setFloat32(offset, value, true);
} else if (componentType === WEBGL_CONSTANTS.UNSIGNED_INT) {
dataView.setUint32(offset, value, true);
} else if (componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT) {
dataView.setUint16(offset, value, true);
} else if (componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE) {
dataView.setUint8(offset, value);
}
offset += componentSize;
}
}
var gltfBufferView = {
buffer: processBuffer(dataView.buffer),
byteOffset: byteOffset,
byteLength: byteLength
};
if (target !== undefined) gltfBufferView.target = target;
if (target === WEBGL_CONSTANTS.ARRAY_BUFFER) {
// Only define byteStride for vertex attributes.
gltfBufferView.byteStride = attribute.itemSize * componentSize;
}
byteOffset += byteLength;
outputJSON.bufferViews.push(gltfBufferView);
// @TODO Merge bufferViews where possible.
var output = {
id: outputJSON.bufferViews.length - 1,
byteLength: 0
};
return output;
}
|
javascript
|
function processBufferView(attribute, componentType, start, count, target) {
if (!outputJSON.bufferViews) {
outputJSON.bufferViews = [];
}
// Create a new dataview and dump the attribute's array into it
var componentSize;
if (componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE) {
componentSize = 1;
} else if (componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT) {
componentSize = 2;
} else {
componentSize = 4;
}
var byteLength = getPaddedBufferSize(
count * attribute.itemSize * componentSize
);
var dataView = new DataView(new ArrayBuffer(byteLength));
var offset = 0;
for (var i = start; i < start + count; i++) {
for (var a = 0; a < attribute.itemSize; a++) {
// @TODO Fails on InterleavedBufferAttribute, and could probably be
// optimized for normal BufferAttribute.
var value = attribute.array[i * attribute.itemSize + a];
if (componentType === WEBGL_CONSTANTS.FLOAT) {
dataView.setFloat32(offset, value, true);
} else if (componentType === WEBGL_CONSTANTS.UNSIGNED_INT) {
dataView.setUint32(offset, value, true);
} else if (componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT) {
dataView.setUint16(offset, value, true);
} else if (componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE) {
dataView.setUint8(offset, value);
}
offset += componentSize;
}
}
var gltfBufferView = {
buffer: processBuffer(dataView.buffer),
byteOffset: byteOffset,
byteLength: byteLength
};
if (target !== undefined) gltfBufferView.target = target;
if (target === WEBGL_CONSTANTS.ARRAY_BUFFER) {
// Only define byteStride for vertex attributes.
gltfBufferView.byteStride = attribute.itemSize * componentSize;
}
byteOffset += byteLength;
outputJSON.bufferViews.push(gltfBufferView);
// @TODO Merge bufferViews where possible.
var output = {
id: outputJSON.bufferViews.length - 1,
byteLength: 0
};
return output;
}
|
[
"function",
"processBufferView",
"(",
"attribute",
",",
"componentType",
",",
"start",
",",
"count",
",",
"target",
")",
"{",
"if",
"(",
"!",
"outputJSON",
".",
"bufferViews",
")",
"{",
"outputJSON",
".",
"bufferViews",
"=",
"[",
"]",
";",
"}",
"// Create a new dataview and dump the attribute's array into it",
"var",
"componentSize",
";",
"if",
"(",
"componentType",
"===",
"WEBGL_CONSTANTS",
".",
"UNSIGNED_BYTE",
")",
"{",
"componentSize",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"componentType",
"===",
"WEBGL_CONSTANTS",
".",
"UNSIGNED_SHORT",
")",
"{",
"componentSize",
"=",
"2",
";",
"}",
"else",
"{",
"componentSize",
"=",
"4",
";",
"}",
"var",
"byteLength",
"=",
"getPaddedBufferSize",
"(",
"count",
"*",
"attribute",
".",
"itemSize",
"*",
"componentSize",
")",
";",
"var",
"dataView",
"=",
"new",
"DataView",
"(",
"new",
"ArrayBuffer",
"(",
"byteLength",
")",
")",
";",
"var",
"offset",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"start",
";",
"i",
"<",
"start",
"+",
"count",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"a",
"=",
"0",
";",
"a",
"<",
"attribute",
".",
"itemSize",
";",
"a",
"++",
")",
"{",
"// @TODO Fails on InterleavedBufferAttribute, and could probably be",
"// optimized for normal BufferAttribute.",
"var",
"value",
"=",
"attribute",
".",
"array",
"[",
"i",
"*",
"attribute",
".",
"itemSize",
"+",
"a",
"]",
";",
"if",
"(",
"componentType",
"===",
"WEBGL_CONSTANTS",
".",
"FLOAT",
")",
"{",
"dataView",
".",
"setFloat32",
"(",
"offset",
",",
"value",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"componentType",
"===",
"WEBGL_CONSTANTS",
".",
"UNSIGNED_INT",
")",
"{",
"dataView",
".",
"setUint32",
"(",
"offset",
",",
"value",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"componentType",
"===",
"WEBGL_CONSTANTS",
".",
"UNSIGNED_SHORT",
")",
"{",
"dataView",
".",
"setUint16",
"(",
"offset",
",",
"value",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"componentType",
"===",
"WEBGL_CONSTANTS",
".",
"UNSIGNED_BYTE",
")",
"{",
"dataView",
".",
"setUint8",
"(",
"offset",
",",
"value",
")",
";",
"}",
"offset",
"+=",
"componentSize",
";",
"}",
"}",
"var",
"gltfBufferView",
"=",
"{",
"buffer",
":",
"processBuffer",
"(",
"dataView",
".",
"buffer",
")",
",",
"byteOffset",
":",
"byteOffset",
",",
"byteLength",
":",
"byteLength",
"}",
";",
"if",
"(",
"target",
"!==",
"undefined",
")",
"gltfBufferView",
".",
"target",
"=",
"target",
";",
"if",
"(",
"target",
"===",
"WEBGL_CONSTANTS",
".",
"ARRAY_BUFFER",
")",
"{",
"// Only define byteStride for vertex attributes.",
"gltfBufferView",
".",
"byteStride",
"=",
"attribute",
".",
"itemSize",
"*",
"componentSize",
";",
"}",
"byteOffset",
"+=",
"byteLength",
";",
"outputJSON",
".",
"bufferViews",
".",
"push",
"(",
"gltfBufferView",
")",
";",
"// @TODO Merge bufferViews where possible.",
"var",
"output",
"=",
"{",
"id",
":",
"outputJSON",
".",
"bufferViews",
".",
"length",
"-",
"1",
",",
"byteLength",
":",
"0",
"}",
";",
"return",
"output",
";",
"}"
] |
Process and generate a BufferView
@param {THREE.BufferAttribute} attribute
@param {number} componentType
@param {number} start
@param {number} count
@param {number} target (Optional) Target usage of the BufferView
@return {Object}
|
[
"Process",
"and",
"generate",
"a",
"BufferView"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L328-L395
|
12,622
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
processBufferViewImage
|
function processBufferViewImage(blob) {
if (!outputJSON.bufferViews) {
outputJSON.bufferViews = [];
}
return new Promise(function(resolve) {
var reader = new window.FileReader();
reader.readAsArrayBuffer(blob);
reader.onloadend = function() {
var buffer = getPaddedArrayBuffer(reader.result);
var bufferView = {
buffer: processBuffer(buffer),
byteOffset: byteOffset,
byteLength: buffer.byteLength
};
byteOffset += buffer.byteLength;
outputJSON.bufferViews.push(bufferView);
resolve(outputJSON.bufferViews.length - 1);
};
});
}
|
javascript
|
function processBufferViewImage(blob) {
if (!outputJSON.bufferViews) {
outputJSON.bufferViews = [];
}
return new Promise(function(resolve) {
var reader = new window.FileReader();
reader.readAsArrayBuffer(blob);
reader.onloadend = function() {
var buffer = getPaddedArrayBuffer(reader.result);
var bufferView = {
buffer: processBuffer(buffer),
byteOffset: byteOffset,
byteLength: buffer.byteLength
};
byteOffset += buffer.byteLength;
outputJSON.bufferViews.push(bufferView);
resolve(outputJSON.bufferViews.length - 1);
};
});
}
|
[
"function",
"processBufferViewImage",
"(",
"blob",
")",
"{",
"if",
"(",
"!",
"outputJSON",
".",
"bufferViews",
")",
"{",
"outputJSON",
".",
"bufferViews",
"=",
"[",
"]",
";",
"}",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"var",
"reader",
"=",
"new",
"window",
".",
"FileReader",
"(",
")",
";",
"reader",
".",
"readAsArrayBuffer",
"(",
"blob",
")",
";",
"reader",
".",
"onloadend",
"=",
"function",
"(",
")",
"{",
"var",
"buffer",
"=",
"getPaddedArrayBuffer",
"(",
"reader",
".",
"result",
")",
";",
"var",
"bufferView",
"=",
"{",
"buffer",
":",
"processBuffer",
"(",
"buffer",
")",
",",
"byteOffset",
":",
"byteOffset",
",",
"byteLength",
":",
"buffer",
".",
"byteLength",
"}",
";",
"byteOffset",
"+=",
"buffer",
".",
"byteLength",
";",
"outputJSON",
".",
"bufferViews",
".",
"push",
"(",
"bufferView",
")",
";",
"resolve",
"(",
"outputJSON",
".",
"bufferViews",
".",
"length",
"-",
"1",
")",
";",
"}",
";",
"}",
")",
";",
"}"
] |
Process and generate a BufferView from an image Blob.
@param {Blob} blob
@return {Promise<Integer>}
|
[
"Process",
"and",
"generate",
"a",
"BufferView",
"from",
"an",
"image",
"Blob",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L402-L426
|
12,623
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
processAccessor
|
function processAccessor(attribute, geometry, start, count) {
var types = {
1: 'SCALAR',
2: 'VEC2',
3: 'VEC3',
4: 'VEC4',
16: 'MAT4'
};
var componentType;
// Detect the component type of the attribute array (float, uint or ushort)
if (attribute.array.constructor === Float32Array) {
componentType = WEBGL_CONSTANTS.FLOAT;
} else if (attribute.array.constructor === Uint32Array) {
componentType = WEBGL_CONSTANTS.UNSIGNED_INT;
} else if (attribute.array.constructor === Uint16Array) {
componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT;
} else if (attribute.array.constructor === Uint8Array) {
componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE;
} else {
throw new Error(
'THREE.GLTFExporter: Unsupported bufferAttribute component type.'
);
}
if (start === undefined) start = 0;
if (count === undefined) count = attribute.count;
// @TODO Indexed buffer geometry with drawRange not supported yet
if (
options.truncateDrawRange &&
geometry !== undefined &&
geometry.index === null
) {
var end = start + count;
var end2 =
geometry.drawRange.count === Infinity
? attribute.count
: geometry.drawRange.start + geometry.drawRange.count;
start = Math.max(start, geometry.drawRange.start);
count = Math.min(end, end2) - start;
if (count < 0) count = 0;
}
// Skip creating an accessor if the attribute doesn't have data to export
if (count === 0) {
return null;
}
var minMax = getMinMax(attribute, start, count);
var bufferViewTarget;
// If geometry isn't provided, don't infer the target usage of the bufferView. For
// animation samplers, target must not be set.
if (geometry !== undefined) {
bufferViewTarget =
attribute === geometry.index
? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER
: WEBGL_CONSTANTS.ARRAY_BUFFER;
}
var bufferView = processBufferView(
attribute,
componentType,
start,
count,
bufferViewTarget
);
var gltfAccessor = {
bufferView: bufferView.id,
byteOffset: bufferView.byteOffset,
componentType: componentType,
count: count,
max: minMax.max,
min: minMax.min,
type: types[attribute.itemSize]
};
if (!outputJSON.accessors) {
outputJSON.accessors = [];
}
outputJSON.accessors.push(gltfAccessor);
return outputJSON.accessors.length - 1;
}
|
javascript
|
function processAccessor(attribute, geometry, start, count) {
var types = {
1: 'SCALAR',
2: 'VEC2',
3: 'VEC3',
4: 'VEC4',
16: 'MAT4'
};
var componentType;
// Detect the component type of the attribute array (float, uint or ushort)
if (attribute.array.constructor === Float32Array) {
componentType = WEBGL_CONSTANTS.FLOAT;
} else if (attribute.array.constructor === Uint32Array) {
componentType = WEBGL_CONSTANTS.UNSIGNED_INT;
} else if (attribute.array.constructor === Uint16Array) {
componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT;
} else if (attribute.array.constructor === Uint8Array) {
componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE;
} else {
throw new Error(
'THREE.GLTFExporter: Unsupported bufferAttribute component type.'
);
}
if (start === undefined) start = 0;
if (count === undefined) count = attribute.count;
// @TODO Indexed buffer geometry with drawRange not supported yet
if (
options.truncateDrawRange &&
geometry !== undefined &&
geometry.index === null
) {
var end = start + count;
var end2 =
geometry.drawRange.count === Infinity
? attribute.count
: geometry.drawRange.start + geometry.drawRange.count;
start = Math.max(start, geometry.drawRange.start);
count = Math.min(end, end2) - start;
if (count < 0) count = 0;
}
// Skip creating an accessor if the attribute doesn't have data to export
if (count === 0) {
return null;
}
var minMax = getMinMax(attribute, start, count);
var bufferViewTarget;
// If geometry isn't provided, don't infer the target usage of the bufferView. For
// animation samplers, target must not be set.
if (geometry !== undefined) {
bufferViewTarget =
attribute === geometry.index
? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER
: WEBGL_CONSTANTS.ARRAY_BUFFER;
}
var bufferView = processBufferView(
attribute,
componentType,
start,
count,
bufferViewTarget
);
var gltfAccessor = {
bufferView: bufferView.id,
byteOffset: bufferView.byteOffset,
componentType: componentType,
count: count,
max: minMax.max,
min: minMax.min,
type: types[attribute.itemSize]
};
if (!outputJSON.accessors) {
outputJSON.accessors = [];
}
outputJSON.accessors.push(gltfAccessor);
return outputJSON.accessors.length - 1;
}
|
[
"function",
"processAccessor",
"(",
"attribute",
",",
"geometry",
",",
"start",
",",
"count",
")",
"{",
"var",
"types",
"=",
"{",
"1",
":",
"'SCALAR'",
",",
"2",
":",
"'VEC2'",
",",
"3",
":",
"'VEC3'",
",",
"4",
":",
"'VEC4'",
",",
"16",
":",
"'MAT4'",
"}",
";",
"var",
"componentType",
";",
"// Detect the component type of the attribute array (float, uint or ushort)",
"if",
"(",
"attribute",
".",
"array",
".",
"constructor",
"===",
"Float32Array",
")",
"{",
"componentType",
"=",
"WEBGL_CONSTANTS",
".",
"FLOAT",
";",
"}",
"else",
"if",
"(",
"attribute",
".",
"array",
".",
"constructor",
"===",
"Uint32Array",
")",
"{",
"componentType",
"=",
"WEBGL_CONSTANTS",
".",
"UNSIGNED_INT",
";",
"}",
"else",
"if",
"(",
"attribute",
".",
"array",
".",
"constructor",
"===",
"Uint16Array",
")",
"{",
"componentType",
"=",
"WEBGL_CONSTANTS",
".",
"UNSIGNED_SHORT",
";",
"}",
"else",
"if",
"(",
"attribute",
".",
"array",
".",
"constructor",
"===",
"Uint8Array",
")",
"{",
"componentType",
"=",
"WEBGL_CONSTANTS",
".",
"UNSIGNED_BYTE",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'THREE.GLTFExporter: Unsupported bufferAttribute component type.'",
")",
";",
"}",
"if",
"(",
"start",
"===",
"undefined",
")",
"start",
"=",
"0",
";",
"if",
"(",
"count",
"===",
"undefined",
")",
"count",
"=",
"attribute",
".",
"count",
";",
"// @TODO Indexed buffer geometry with drawRange not supported yet",
"if",
"(",
"options",
".",
"truncateDrawRange",
"&&",
"geometry",
"!==",
"undefined",
"&&",
"geometry",
".",
"index",
"===",
"null",
")",
"{",
"var",
"end",
"=",
"start",
"+",
"count",
";",
"var",
"end2",
"=",
"geometry",
".",
"drawRange",
".",
"count",
"===",
"Infinity",
"?",
"attribute",
".",
"count",
":",
"geometry",
".",
"drawRange",
".",
"start",
"+",
"geometry",
".",
"drawRange",
".",
"count",
";",
"start",
"=",
"Math",
".",
"max",
"(",
"start",
",",
"geometry",
".",
"drawRange",
".",
"start",
")",
";",
"count",
"=",
"Math",
".",
"min",
"(",
"end",
",",
"end2",
")",
"-",
"start",
";",
"if",
"(",
"count",
"<",
"0",
")",
"count",
"=",
"0",
";",
"}",
"// Skip creating an accessor if the attribute doesn't have data to export",
"if",
"(",
"count",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"var",
"minMax",
"=",
"getMinMax",
"(",
"attribute",
",",
"start",
",",
"count",
")",
";",
"var",
"bufferViewTarget",
";",
"// If geometry isn't provided, don't infer the target usage of the bufferView. For",
"// animation samplers, target must not be set.",
"if",
"(",
"geometry",
"!==",
"undefined",
")",
"{",
"bufferViewTarget",
"=",
"attribute",
"===",
"geometry",
".",
"index",
"?",
"WEBGL_CONSTANTS",
".",
"ELEMENT_ARRAY_BUFFER",
":",
"WEBGL_CONSTANTS",
".",
"ARRAY_BUFFER",
";",
"}",
"var",
"bufferView",
"=",
"processBufferView",
"(",
"attribute",
",",
"componentType",
",",
"start",
",",
"count",
",",
"bufferViewTarget",
")",
";",
"var",
"gltfAccessor",
"=",
"{",
"bufferView",
":",
"bufferView",
".",
"id",
",",
"byteOffset",
":",
"bufferView",
".",
"byteOffset",
",",
"componentType",
":",
"componentType",
",",
"count",
":",
"count",
",",
"max",
":",
"minMax",
".",
"max",
",",
"min",
":",
"minMax",
".",
"min",
",",
"type",
":",
"types",
"[",
"attribute",
".",
"itemSize",
"]",
"}",
";",
"if",
"(",
"!",
"outputJSON",
".",
"accessors",
")",
"{",
"outputJSON",
".",
"accessors",
"=",
"[",
"]",
";",
"}",
"outputJSON",
".",
"accessors",
".",
"push",
"(",
"gltfAccessor",
")",
";",
"return",
"outputJSON",
".",
"accessors",
".",
"length",
"-",
"1",
";",
"}"
] |
Process attribute to generate an accessor
@param {THREE.BufferAttribute} attribute Attribute to process
@param {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range
@param {Integer} start (Optional)
@param {Integer} count (Optional)
@return {Integer} Index of the processed accessor on the "accessors" array
|
[
"Process",
"attribute",
"to",
"generate",
"an",
"accessor"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L436-L526
|
12,624
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
processAnimation
|
function processAnimation(clip, root) {
if (!outputJSON.animations) {
outputJSON.animations = [];
}
var channels = [];
var samplers = [];
for (var i = 0; i < clip.tracks.length; ++i) {
var track = clip.tracks[i];
var trackBinding = THREE.PropertyBinding.parseTrackName(track.name);
var trackNode = THREE.PropertyBinding.findNode(
root,
trackBinding.nodeName
);
var trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
if (trackBinding.objectName === 'bones') {
if (trackNode.isSkinnedMesh === true) {
trackNode = trackNode.skeleton.getBoneByName(
trackBinding.objectIndex
);
} else {
trackNode = undefined;
}
}
if (!trackNode || !trackProperty) {
console.warn(
'THREE.GLTFExporter: Could not export animation track "%s".',
track.name
);
return null;
}
var inputItemSize = 1;
var outputItemSize = track.values.length / track.times.length;
if (trackProperty === PATH_PROPERTIES.morphTargetInfluences) {
if (
trackNode.morphTargetInfluences.length !== 1 &&
trackBinding.propertyIndex !== undefined
) {
console.warn(
'THREE.GLTFExporter: Skipping animation track "%s". ' +
'Morph target keyframe tracks must target all available morph targets ' +
'for the given mesh.',
track.name
);
continue;
}
outputItemSize /= trackNode.morphTargetInfluences.length;
}
var interpolation;
// @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE
// Detecting glTF cubic spline interpolant by checking factory method's special property
// GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return
// valid value from .getInterpolation().
if (
track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ===
true
) {
interpolation = 'CUBICSPLINE';
// itemSize of CUBICSPLINE keyframe is 9
// (VEC3 * 3: inTangent, splineVertex, and outTangent)
// but needs to be stored as VEC3 so dividing by 3 here.
outputItemSize /= 3;
} else if (track.getInterpolation() === THREE.InterpolateDiscrete) {
interpolation = 'STEP';
} else {
interpolation = 'LINEAR';
}
samplers.push({
input: processAccessor(
new THREE.BufferAttribute(track.times, inputItemSize)
),
output: processAccessor(
new THREE.BufferAttribute(track.values, outputItemSize)
),
interpolation: interpolation
});
channels.push({
sampler: samplers.length - 1,
target: {
node: nodeMap.get(trackNode),
path: trackProperty
}
});
}
outputJSON.animations.push({
name: clip.name || 'clip_' + outputJSON.animations.length,
samplers: samplers,
channels: channels
});
return outputJSON.animations.length - 1;
}
|
javascript
|
function processAnimation(clip, root) {
if (!outputJSON.animations) {
outputJSON.animations = [];
}
var channels = [];
var samplers = [];
for (var i = 0; i < clip.tracks.length; ++i) {
var track = clip.tracks[i];
var trackBinding = THREE.PropertyBinding.parseTrackName(track.name);
var trackNode = THREE.PropertyBinding.findNode(
root,
trackBinding.nodeName
);
var trackProperty = PATH_PROPERTIES[trackBinding.propertyName];
if (trackBinding.objectName === 'bones') {
if (trackNode.isSkinnedMesh === true) {
trackNode = trackNode.skeleton.getBoneByName(
trackBinding.objectIndex
);
} else {
trackNode = undefined;
}
}
if (!trackNode || !trackProperty) {
console.warn(
'THREE.GLTFExporter: Could not export animation track "%s".',
track.name
);
return null;
}
var inputItemSize = 1;
var outputItemSize = track.values.length / track.times.length;
if (trackProperty === PATH_PROPERTIES.morphTargetInfluences) {
if (
trackNode.morphTargetInfluences.length !== 1 &&
trackBinding.propertyIndex !== undefined
) {
console.warn(
'THREE.GLTFExporter: Skipping animation track "%s". ' +
'Morph target keyframe tracks must target all available morph targets ' +
'for the given mesh.',
track.name
);
continue;
}
outputItemSize /= trackNode.morphTargetInfluences.length;
}
var interpolation;
// @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE
// Detecting glTF cubic spline interpolant by checking factory method's special property
// GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return
// valid value from .getInterpolation().
if (
track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ===
true
) {
interpolation = 'CUBICSPLINE';
// itemSize of CUBICSPLINE keyframe is 9
// (VEC3 * 3: inTangent, splineVertex, and outTangent)
// but needs to be stored as VEC3 so dividing by 3 here.
outputItemSize /= 3;
} else if (track.getInterpolation() === THREE.InterpolateDiscrete) {
interpolation = 'STEP';
} else {
interpolation = 'LINEAR';
}
samplers.push({
input: processAccessor(
new THREE.BufferAttribute(track.times, inputItemSize)
),
output: processAccessor(
new THREE.BufferAttribute(track.values, outputItemSize)
),
interpolation: interpolation
});
channels.push({
sampler: samplers.length - 1,
target: {
node: nodeMap.get(trackNode),
path: trackProperty
}
});
}
outputJSON.animations.push({
name: clip.name || 'clip_' + outputJSON.animations.length,
samplers: samplers,
channels: channels
});
return outputJSON.animations.length - 1;
}
|
[
"function",
"processAnimation",
"(",
"clip",
",",
"root",
")",
"{",
"if",
"(",
"!",
"outputJSON",
".",
"animations",
")",
"{",
"outputJSON",
".",
"animations",
"=",
"[",
"]",
";",
"}",
"var",
"channels",
"=",
"[",
"]",
";",
"var",
"samplers",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"clip",
".",
"tracks",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"track",
"=",
"clip",
".",
"tracks",
"[",
"i",
"]",
";",
"var",
"trackBinding",
"=",
"THREE",
".",
"PropertyBinding",
".",
"parseTrackName",
"(",
"track",
".",
"name",
")",
";",
"var",
"trackNode",
"=",
"THREE",
".",
"PropertyBinding",
".",
"findNode",
"(",
"root",
",",
"trackBinding",
".",
"nodeName",
")",
";",
"var",
"trackProperty",
"=",
"PATH_PROPERTIES",
"[",
"trackBinding",
".",
"propertyName",
"]",
";",
"if",
"(",
"trackBinding",
".",
"objectName",
"===",
"'bones'",
")",
"{",
"if",
"(",
"trackNode",
".",
"isSkinnedMesh",
"===",
"true",
")",
"{",
"trackNode",
"=",
"trackNode",
".",
"skeleton",
".",
"getBoneByName",
"(",
"trackBinding",
".",
"objectIndex",
")",
";",
"}",
"else",
"{",
"trackNode",
"=",
"undefined",
";",
"}",
"}",
"if",
"(",
"!",
"trackNode",
"||",
"!",
"trackProperty",
")",
"{",
"console",
".",
"warn",
"(",
"'THREE.GLTFExporter: Could not export animation track \"%s\".'",
",",
"track",
".",
"name",
")",
";",
"return",
"null",
";",
"}",
"var",
"inputItemSize",
"=",
"1",
";",
"var",
"outputItemSize",
"=",
"track",
".",
"values",
".",
"length",
"/",
"track",
".",
"times",
".",
"length",
";",
"if",
"(",
"trackProperty",
"===",
"PATH_PROPERTIES",
".",
"morphTargetInfluences",
")",
"{",
"if",
"(",
"trackNode",
".",
"morphTargetInfluences",
".",
"length",
"!==",
"1",
"&&",
"trackBinding",
".",
"propertyIndex",
"!==",
"undefined",
")",
"{",
"console",
".",
"warn",
"(",
"'THREE.GLTFExporter: Skipping animation track \"%s\". '",
"+",
"'Morph target keyframe tracks must target all available morph targets '",
"+",
"'for the given mesh.'",
",",
"track",
".",
"name",
")",
";",
"continue",
";",
"}",
"outputItemSize",
"/=",
"trackNode",
".",
"morphTargetInfluences",
".",
"length",
";",
"}",
"var",
"interpolation",
";",
"// @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE",
"// Detecting glTF cubic spline interpolant by checking factory method's special property",
"// GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return",
"// valid value from .getInterpolation().",
"if",
"(",
"track",
".",
"createInterpolant",
".",
"isInterpolantFactoryMethodGLTFCubicSpline",
"===",
"true",
")",
"{",
"interpolation",
"=",
"'CUBICSPLINE'",
";",
"// itemSize of CUBICSPLINE keyframe is 9",
"// (VEC3 * 3: inTangent, splineVertex, and outTangent)",
"// but needs to be stored as VEC3 so dividing by 3 here.",
"outputItemSize",
"/=",
"3",
";",
"}",
"else",
"if",
"(",
"track",
".",
"getInterpolation",
"(",
")",
"===",
"THREE",
".",
"InterpolateDiscrete",
")",
"{",
"interpolation",
"=",
"'STEP'",
";",
"}",
"else",
"{",
"interpolation",
"=",
"'LINEAR'",
";",
"}",
"samplers",
".",
"push",
"(",
"{",
"input",
":",
"processAccessor",
"(",
"new",
"THREE",
".",
"BufferAttribute",
"(",
"track",
".",
"times",
",",
"inputItemSize",
")",
")",
",",
"output",
":",
"processAccessor",
"(",
"new",
"THREE",
".",
"BufferAttribute",
"(",
"track",
".",
"values",
",",
"outputItemSize",
")",
")",
",",
"interpolation",
":",
"interpolation",
"}",
")",
";",
"channels",
".",
"push",
"(",
"{",
"sampler",
":",
"samplers",
".",
"length",
"-",
"1",
",",
"target",
":",
"{",
"node",
":",
"nodeMap",
".",
"get",
"(",
"trackNode",
")",
",",
"path",
":",
"trackProperty",
"}",
"}",
")",
";",
"}",
"outputJSON",
".",
"animations",
".",
"push",
"(",
"{",
"name",
":",
"clip",
".",
"name",
"||",
"'clip_'",
"+",
"outputJSON",
".",
"animations",
".",
"length",
",",
"samplers",
":",
"samplers",
",",
"channels",
":",
"channels",
"}",
")",
";",
"return",
"outputJSON",
".",
"animations",
".",
"length",
"-",
"1",
";",
"}"
] |
Creates glTF animation entry from AnimationClip object.
Status:
- Only properties listed in PATH_PROPERTIES may be animated.
@param {THREE.AnimationClip} clip
@param {THREE.Object3D} root
@return {number}
|
[
"Creates",
"glTF",
"animation",
"entry",
"from",
"AnimationClip",
"object",
"."
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L1128-L1232
|
12,625
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
processNode
|
function processNode(object) {
if (object.isLight) {
console.warn(
'GLTFExporter: Unsupported node type:',
object.constructor.name
);
return null;
}
if (!outputJSON.nodes) {
outputJSON.nodes = [];
}
var gltfNode = {};
if (options.trs) {
var rotation = object.quaternion.toArray();
var position = object.position.toArray();
var scale = object.scale.toArray();
if (!equalArray(rotation, [0, 0, 0, 1])) {
gltfNode.rotation = rotation;
}
if (!equalArray(position, [0, 0, 0])) {
gltfNode.translation = position;
}
if (!equalArray(scale, [1, 1, 1])) {
gltfNode.scale = scale;
}
} else {
object.updateMatrix();
if (
!equalArray(object.matrix.elements, [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
])
) {
gltfNode.matrix = object.matrix.elements;
}
}
// We don't export empty strings name because it represents no-name in Three.js.
if (object.name !== '') {
gltfNode.name = String(object.name);
}
if (object.userData && Object.keys(object.userData).length > 0) {
gltfNode.extras = serializeUserData(object);
}
if (object.isMesh || object.isLine || object.isPoints) {
var mesh = processMesh(object);
if (mesh !== null) {
gltfNode.mesh = mesh;
}
} else if (object.isCamera) {
gltfNode.camera = processCamera(object);
}
if (object.isSkinnedMesh) {
skins.push(object);
}
if (object.children.length > 0) {
var children = [];
for (var i = 0, l = object.children.length; i < l; i++) {
var child = object.children[i];
if (child.visible || options.onlyVisible === false) {
var node = processNode(child);
if (node !== null) {
children.push(node);
}
}
}
if (children.length > 0) {
gltfNode.children = children;
}
}
outputJSON.nodes.push(gltfNode);
var nodeIndex = outputJSON.nodes.length - 1;
nodeMap.set(object, nodeIndex);
return nodeIndex;
}
|
javascript
|
function processNode(object) {
if (object.isLight) {
console.warn(
'GLTFExporter: Unsupported node type:',
object.constructor.name
);
return null;
}
if (!outputJSON.nodes) {
outputJSON.nodes = [];
}
var gltfNode = {};
if (options.trs) {
var rotation = object.quaternion.toArray();
var position = object.position.toArray();
var scale = object.scale.toArray();
if (!equalArray(rotation, [0, 0, 0, 1])) {
gltfNode.rotation = rotation;
}
if (!equalArray(position, [0, 0, 0])) {
gltfNode.translation = position;
}
if (!equalArray(scale, [1, 1, 1])) {
gltfNode.scale = scale;
}
} else {
object.updateMatrix();
if (
!equalArray(object.matrix.elements, [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
])
) {
gltfNode.matrix = object.matrix.elements;
}
}
// We don't export empty strings name because it represents no-name in Three.js.
if (object.name !== '') {
gltfNode.name = String(object.name);
}
if (object.userData && Object.keys(object.userData).length > 0) {
gltfNode.extras = serializeUserData(object);
}
if (object.isMesh || object.isLine || object.isPoints) {
var mesh = processMesh(object);
if (mesh !== null) {
gltfNode.mesh = mesh;
}
} else if (object.isCamera) {
gltfNode.camera = processCamera(object);
}
if (object.isSkinnedMesh) {
skins.push(object);
}
if (object.children.length > 0) {
var children = [];
for (var i = 0, l = object.children.length; i < l; i++) {
var child = object.children[i];
if (child.visible || options.onlyVisible === false) {
var node = processNode(child);
if (node !== null) {
children.push(node);
}
}
}
if (children.length > 0) {
gltfNode.children = children;
}
}
outputJSON.nodes.push(gltfNode);
var nodeIndex = outputJSON.nodes.length - 1;
nodeMap.set(object, nodeIndex);
return nodeIndex;
}
|
[
"function",
"processNode",
"(",
"object",
")",
"{",
"if",
"(",
"object",
".",
"isLight",
")",
"{",
"console",
".",
"warn",
"(",
"'GLTFExporter: Unsupported node type:'",
",",
"object",
".",
"constructor",
".",
"name",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"outputJSON",
".",
"nodes",
")",
"{",
"outputJSON",
".",
"nodes",
"=",
"[",
"]",
";",
"}",
"var",
"gltfNode",
"=",
"{",
"}",
";",
"if",
"(",
"options",
".",
"trs",
")",
"{",
"var",
"rotation",
"=",
"object",
".",
"quaternion",
".",
"toArray",
"(",
")",
";",
"var",
"position",
"=",
"object",
".",
"position",
".",
"toArray",
"(",
")",
";",
"var",
"scale",
"=",
"object",
".",
"scale",
".",
"toArray",
"(",
")",
";",
"if",
"(",
"!",
"equalArray",
"(",
"rotation",
",",
"[",
"0",
",",
"0",
",",
"0",
",",
"1",
"]",
")",
")",
"{",
"gltfNode",
".",
"rotation",
"=",
"rotation",
";",
"}",
"if",
"(",
"!",
"equalArray",
"(",
"position",
",",
"[",
"0",
",",
"0",
",",
"0",
"]",
")",
")",
"{",
"gltfNode",
".",
"translation",
"=",
"position",
";",
"}",
"if",
"(",
"!",
"equalArray",
"(",
"scale",
",",
"[",
"1",
",",
"1",
",",
"1",
"]",
")",
")",
"{",
"gltfNode",
".",
"scale",
"=",
"scale",
";",
"}",
"}",
"else",
"{",
"object",
".",
"updateMatrix",
"(",
")",
";",
"if",
"(",
"!",
"equalArray",
"(",
"object",
".",
"matrix",
".",
"elements",
",",
"[",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"1",
"]",
")",
")",
"{",
"gltfNode",
".",
"matrix",
"=",
"object",
".",
"matrix",
".",
"elements",
";",
"}",
"}",
"// We don't export empty strings name because it represents no-name in Three.js.",
"if",
"(",
"object",
".",
"name",
"!==",
"''",
")",
"{",
"gltfNode",
".",
"name",
"=",
"String",
"(",
"object",
".",
"name",
")",
";",
"}",
"if",
"(",
"object",
".",
"userData",
"&&",
"Object",
".",
"keys",
"(",
"object",
".",
"userData",
")",
".",
"length",
">",
"0",
")",
"{",
"gltfNode",
".",
"extras",
"=",
"serializeUserData",
"(",
"object",
")",
";",
"}",
"if",
"(",
"object",
".",
"isMesh",
"||",
"object",
".",
"isLine",
"||",
"object",
".",
"isPoints",
")",
"{",
"var",
"mesh",
"=",
"processMesh",
"(",
"object",
")",
";",
"if",
"(",
"mesh",
"!==",
"null",
")",
"{",
"gltfNode",
".",
"mesh",
"=",
"mesh",
";",
"}",
"}",
"else",
"if",
"(",
"object",
".",
"isCamera",
")",
"{",
"gltfNode",
".",
"camera",
"=",
"processCamera",
"(",
"object",
")",
";",
"}",
"if",
"(",
"object",
".",
"isSkinnedMesh",
")",
"{",
"skins",
".",
"push",
"(",
"object",
")",
";",
"}",
"if",
"(",
"object",
".",
"children",
".",
"length",
">",
"0",
")",
"{",
"var",
"children",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"object",
".",
"children",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"child",
"=",
"object",
".",
"children",
"[",
"i",
"]",
";",
"if",
"(",
"child",
".",
"visible",
"||",
"options",
".",
"onlyVisible",
"===",
"false",
")",
"{",
"var",
"node",
"=",
"processNode",
"(",
"child",
")",
";",
"if",
"(",
"node",
"!==",
"null",
")",
"{",
"children",
".",
"push",
"(",
"node",
")",
";",
"}",
"}",
"}",
"if",
"(",
"children",
".",
"length",
">",
"0",
")",
"{",
"gltfNode",
".",
"children",
"=",
"children",
";",
"}",
"}",
"outputJSON",
".",
"nodes",
".",
"push",
"(",
"gltfNode",
")",
";",
"var",
"nodeIndex",
"=",
"outputJSON",
".",
"nodes",
".",
"length",
"-",
"1",
";",
"nodeMap",
".",
"set",
"(",
"object",
",",
"nodeIndex",
")",
";",
"return",
"nodeIndex",
";",
"}"
] |
Process Object3D node
@param {THREE.Object3D} node Object3D to processNode
@return {Integer} Index of the node in the nodes list
|
[
"Process",
"Object3D",
"node"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L1273-L1379
|
12,626
|
aframevr/aframe-inspector
|
vendor/GLTFExporter.js
|
processObjects
|
function processObjects(objects) {
var scene = new THREE.Scene();
scene.name = 'AuxScene';
for (var i = 0; i < objects.length; i++) {
// We push directly to children instead of calling `add` to prevent
// modify the .parent and break its original scene and hierarchy
scene.children.push(objects[i]);
}
processScene(scene);
}
|
javascript
|
function processObjects(objects) {
var scene = new THREE.Scene();
scene.name = 'AuxScene';
for (var i = 0; i < objects.length; i++) {
// We push directly to children instead of calling `add` to prevent
// modify the .parent and break its original scene and hierarchy
scene.children.push(objects[i]);
}
processScene(scene);
}
|
[
"function",
"processObjects",
"(",
"objects",
")",
"{",
"var",
"scene",
"=",
"new",
"THREE",
".",
"Scene",
"(",
")",
";",
"scene",
".",
"name",
"=",
"'AuxScene'",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"objects",
".",
"length",
";",
"i",
"++",
")",
"{",
"// We push directly to children instead of calling `add` to prevent",
"// modify the .parent and break its original scene and hierarchy",
"scene",
".",
"children",
".",
"push",
"(",
"objects",
"[",
"i",
"]",
")",
";",
"}",
"processScene",
"(",
"scene",
")",
";",
"}"
] |
Creates a THREE.Scene to hold a list of objects and parse it
@param {Array} objects List of objects to process
|
[
"Creates",
"a",
"THREE",
".",
"Scene",
"to",
"hold",
"a",
"list",
"of",
"objects",
"and",
"parse",
"it"
] |
bb0de5e92e4f0ee727726d5f580a0876d5e49047
|
https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/vendor/GLTFExporter.js#L1424-L1435
|
12,627
|
Intellicode/eslint-plugin-react-native
|
lib/util/Components.js
|
function () {
let scope = context.getScope();
while (scope) {
const node = scope.block && scope.block.parent && scope.block.parent.parent;
if (node && utils.isES5Component(node)) {
return node;
}
scope = scope.upper;
}
return null;
}
|
javascript
|
function () {
let scope = context.getScope();
while (scope) {
const node = scope.block && scope.block.parent && scope.block.parent.parent;
if (node && utils.isES5Component(node)) {
return node;
}
scope = scope.upper;
}
return null;
}
|
[
"function",
"(",
")",
"{",
"let",
"scope",
"=",
"context",
".",
"getScope",
"(",
")",
";",
"while",
"(",
"scope",
")",
"{",
"const",
"node",
"=",
"scope",
".",
"block",
"&&",
"scope",
".",
"block",
".",
"parent",
"&&",
"scope",
".",
"block",
".",
"parent",
".",
"parent",
";",
"if",
"(",
"node",
"&&",
"utils",
".",
"isES5Component",
"(",
"node",
")",
")",
"{",
"return",
"node",
";",
"}",
"scope",
"=",
"scope",
".",
"upper",
";",
"}",
"return",
"null",
";",
"}"
] |
Get the parent ES5 component node from the current scope
@returns {ASTNode} component node, null if we are not in a component
|
[
"Get",
"the",
"parent",
"ES5",
"component",
"node",
"from",
"the",
"current",
"scope"
] |
da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5
|
https://github.com/Intellicode/eslint-plugin-react-native/blob/da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5/lib/util/Components.js#L186-L196
|
|
12,628
|
Intellicode/eslint-plugin-react-native
|
lib/util/Components.js
|
function () {
let scope = context.getScope();
while (scope && scope.type !== 'class') {
scope = scope.upper;
}
const node = scope && scope.block;
if (!node || !utils.isES6Component(node)) {
return null;
}
return node;
}
|
javascript
|
function () {
let scope = context.getScope();
while (scope && scope.type !== 'class') {
scope = scope.upper;
}
const node = scope && scope.block;
if (!node || !utils.isES6Component(node)) {
return null;
}
return node;
}
|
[
"function",
"(",
")",
"{",
"let",
"scope",
"=",
"context",
".",
"getScope",
"(",
")",
";",
"while",
"(",
"scope",
"&&",
"scope",
".",
"type",
"!==",
"'class'",
")",
"{",
"scope",
"=",
"scope",
".",
"upper",
";",
"}",
"const",
"node",
"=",
"scope",
"&&",
"scope",
".",
"block",
";",
"if",
"(",
"!",
"node",
"||",
"!",
"utils",
".",
"isES6Component",
"(",
"node",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"node",
";",
"}"
] |
Get the parent ES6 component node from the current scope
@returns {ASTNode} component node, null if we are not in a component
|
[
"Get",
"the",
"parent",
"ES6",
"component",
"node",
"from",
"the",
"current",
"scope"
] |
da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5
|
https://github.com/Intellicode/eslint-plugin-react-native/blob/da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5/lib/util/Components.js#L203-L213
|
|
12,629
|
Intellicode/eslint-plugin-react-native
|
lib/util/variable.js
|
markVariableAsUsed
|
function markVariableAsUsed(context, name) {
let scope = context.getScope();
let variables;
let i;
let len;
let found = false;
// Special Node.js scope means we need to start one level deeper
if (scope.type === 'global') {
while (scope.childScopes.length) {
scope = scope.childScopes[0];
}
}
do {
variables = scope.variables;
for (i = 0, len = variables.length; i < len; i++) { // eslint-disable-line no-plusplus
if (variables[i].name === name) {
variables[i].eslintUsed = true;
found = true;
}
}
scope = scope.upper;
} while (scope);
return found;
}
|
javascript
|
function markVariableAsUsed(context, name) {
let scope = context.getScope();
let variables;
let i;
let len;
let found = false;
// Special Node.js scope means we need to start one level deeper
if (scope.type === 'global') {
while (scope.childScopes.length) {
scope = scope.childScopes[0];
}
}
do {
variables = scope.variables;
for (i = 0, len = variables.length; i < len; i++) { // eslint-disable-line no-plusplus
if (variables[i].name === name) {
variables[i].eslintUsed = true;
found = true;
}
}
scope = scope.upper;
} while (scope);
return found;
}
|
[
"function",
"markVariableAsUsed",
"(",
"context",
",",
"name",
")",
"{",
"let",
"scope",
"=",
"context",
".",
"getScope",
"(",
")",
";",
"let",
"variables",
";",
"let",
"i",
";",
"let",
"len",
";",
"let",
"found",
"=",
"false",
";",
"// Special Node.js scope means we need to start one level deeper",
"if",
"(",
"scope",
".",
"type",
"===",
"'global'",
")",
"{",
"while",
"(",
"scope",
".",
"childScopes",
".",
"length",
")",
"{",
"scope",
"=",
"scope",
".",
"childScopes",
"[",
"0",
"]",
";",
"}",
"}",
"do",
"{",
"variables",
"=",
"scope",
".",
"variables",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"variables",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"// eslint-disable-line no-plusplus",
"if",
"(",
"variables",
"[",
"i",
"]",
".",
"name",
"===",
"name",
")",
"{",
"variables",
"[",
"i",
"]",
".",
"eslintUsed",
"=",
"true",
";",
"found",
"=",
"true",
";",
"}",
"}",
"scope",
"=",
"scope",
".",
"upper",
";",
"}",
"while",
"(",
"scope",
")",
";",
"return",
"found",
";",
"}"
] |
Record that a particular variable has been used in code
@param {String} name The name of the variable to mark as used.
@returns {Boolean} True if the variable was found and marked as used, false if not.
|
[
"Record",
"that",
"a",
"particular",
"variable",
"has",
"been",
"used",
"in",
"code"
] |
da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5
|
https://github.com/Intellicode/eslint-plugin-react-native/blob/da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5/lib/util/variable.js#L14-L40
|
12,630
|
Intellicode/eslint-plugin-react-native
|
lib/util/variable.js
|
findVariable
|
function findVariable(variables, name) {
let i;
let len;
for (i = 0, len = variables.length; i < len; i++) { // eslint-disable-line no-plusplus
if (variables[i].name === name) {
return true;
}
}
return false;
}
|
javascript
|
function findVariable(variables, name) {
let i;
let len;
for (i = 0, len = variables.length; i < len; i++) { // eslint-disable-line no-plusplus
if (variables[i].name === name) {
return true;
}
}
return false;
}
|
[
"function",
"findVariable",
"(",
"variables",
",",
"name",
")",
"{",
"let",
"i",
";",
"let",
"len",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"variables",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"// eslint-disable-line no-plusplus",
"if",
"(",
"variables",
"[",
"i",
"]",
".",
"name",
"===",
"name",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Search a particular variable in a list
@param {Array} variables The variables list.
@param {Array} name The name of the variable to search.
@returns {Boolean} True if the variable was found, false if not.
|
[
"Search",
"a",
"particular",
"variable",
"in",
"a",
"list"
] |
da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5
|
https://github.com/Intellicode/eslint-plugin-react-native/blob/da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5/lib/util/variable.js#L48-L59
|
12,631
|
Intellicode/eslint-plugin-react-native
|
lib/util/variable.js
|
variablesInScope
|
function variablesInScope(context) {
let scope = context.getScope();
let variables = scope.variables;
while (scope.type !== 'global') {
scope = scope.upper;
variables = scope.variables.concat(variables);
}
if (scope.childScopes.length) {
variables = scope.childScopes[0].variables.concat(variables);
if (scope.childScopes[0].childScopes.length) {
variables = scope.childScopes[0].childScopes[0].variables.concat(variables);
}
}
return variables;
}
|
javascript
|
function variablesInScope(context) {
let scope = context.getScope();
let variables = scope.variables;
while (scope.type !== 'global') {
scope = scope.upper;
variables = scope.variables.concat(variables);
}
if (scope.childScopes.length) {
variables = scope.childScopes[0].variables.concat(variables);
if (scope.childScopes[0].childScopes.length) {
variables = scope.childScopes[0].childScopes[0].variables.concat(variables);
}
}
return variables;
}
|
[
"function",
"variablesInScope",
"(",
"context",
")",
"{",
"let",
"scope",
"=",
"context",
".",
"getScope",
"(",
")",
";",
"let",
"variables",
"=",
"scope",
".",
"variables",
";",
"while",
"(",
"scope",
".",
"type",
"!==",
"'global'",
")",
"{",
"scope",
"=",
"scope",
".",
"upper",
";",
"variables",
"=",
"scope",
".",
"variables",
".",
"concat",
"(",
"variables",
")",
";",
"}",
"if",
"(",
"scope",
".",
"childScopes",
".",
"length",
")",
"{",
"variables",
"=",
"scope",
".",
"childScopes",
"[",
"0",
"]",
".",
"variables",
".",
"concat",
"(",
"variables",
")",
";",
"if",
"(",
"scope",
".",
"childScopes",
"[",
"0",
"]",
".",
"childScopes",
".",
"length",
")",
"{",
"variables",
"=",
"scope",
".",
"childScopes",
"[",
"0",
"]",
".",
"childScopes",
"[",
"0",
"]",
".",
"variables",
".",
"concat",
"(",
"variables",
")",
";",
"}",
"}",
"return",
"variables",
";",
"}"
] |
List all variable in a given scope
Contain a patch for babel-eslint to avoid https://github.com/babel/babel-eslint/issues/21
@param {Object} context The current rule context.
@param {Array} name The name of the variable to search.
@returns {Boolean} True if the variable was found, false if not.
|
[
"List",
"all",
"variable",
"in",
"a",
"given",
"scope"
] |
da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5
|
https://github.com/Intellicode/eslint-plugin-react-native/blob/da07c9ae222a98c7a1652ebe6d9d13dcc2225ef5/lib/util/variable.js#L70-L86
|
12,632
|
darrenscerri/duplicate-package-checker-webpack-plugin
|
src/index.js
|
getClosestPackage
|
function getClosestPackage(modulePath) {
let root;
let pkg;
// Catch findRoot or require errors
try {
root = findRoot(modulePath);
pkg = require(path.join(root, "package.json"));
} catch (e) {
return null;
}
// If the package.json does not have a name property, try again from
// one level higher.
// https://github.com/jsdnxx/find-root/issues/2
// https://github.com/date-fns/date-fns/issues/264#issuecomment-265128399
if (!pkg.name) {
return getClosestPackage(path.resolve(root, ".."));
}
return {
package: pkg,
path: root
};
}
|
javascript
|
function getClosestPackage(modulePath) {
let root;
let pkg;
// Catch findRoot or require errors
try {
root = findRoot(modulePath);
pkg = require(path.join(root, "package.json"));
} catch (e) {
return null;
}
// If the package.json does not have a name property, try again from
// one level higher.
// https://github.com/jsdnxx/find-root/issues/2
// https://github.com/date-fns/date-fns/issues/264#issuecomment-265128399
if (!pkg.name) {
return getClosestPackage(path.resolve(root, ".."));
}
return {
package: pkg,
path: root
};
}
|
[
"function",
"getClosestPackage",
"(",
"modulePath",
")",
"{",
"let",
"root",
";",
"let",
"pkg",
";",
"// Catch findRoot or require errors",
"try",
"{",
"root",
"=",
"findRoot",
"(",
"modulePath",
")",
";",
"pkg",
"=",
"require",
"(",
"path",
".",
"join",
"(",
"root",
",",
"\"package.json\"",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"null",
";",
"}",
"// If the package.json does not have a name property, try again from",
"// one level higher.",
"// https://github.com/jsdnxx/find-root/issues/2",
"// https://github.com/date-fns/date-fns/issues/264#issuecomment-265128399",
"if",
"(",
"!",
"pkg",
".",
"name",
")",
"{",
"return",
"getClosestPackage",
"(",
"path",
".",
"resolve",
"(",
"root",
",",
"\"..\"",
")",
")",
";",
"}",
"return",
"{",
"package",
":",
"pkg",
",",
"path",
":",
"root",
"}",
";",
"}"
] |
Get closest package definition from path
|
[
"Get",
"closest",
"package",
"definition",
"from",
"path"
] |
f78729d8042055387528bf0c493b7560ac0bf149
|
https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin/blob/f78729d8042055387528bf0c493b7560ac0bf149/src/index.js#L24-L48
|
12,633
|
Raathigesh/dazzle
|
lib/components/Row.js
|
Row
|
function Row(props) {
const {
rowClass,
columns,
widgets,
onRemove,
layout,
rowIndex,
editable,
frameComponent,
editableColumnClass,
droppableColumnClass,
addWidgetComponentText,
addWidgetComponent,
onAdd,
onMove,
onEdit,
} = props;
const items = columns.map((column, index) => { // eslint-disable-line arrow-body-style
return (
<Column
key={index}
className={column.className}
onAdd={onAdd}
layout={layout}
rowIndex={rowIndex}
columnIndex={index}
editable={editable}
onMove={onMove}
editableColumnClass={editableColumnClass}
droppableColumnClass={droppableColumnClass}
addWidgetComponent={addWidgetComponent}
addWidgetComponentText={addWidgetComponentText}
>
<Widgets
key={index}
widgets={column.widgets}
containerClassName={column.containerClassName}
widgetTypes={widgets}
onRemove={onRemove}
layout={layout}
rowIndex={rowIndex}
columnIndex={index}
editable={editable}
frameComponent={frameComponent}
onMove={onMove}
onEdit={onEdit}
/>
</Column>
);
});
return (
<div className={rowClass}>
{items}
</div>
);
}
|
javascript
|
function Row(props) {
const {
rowClass,
columns,
widgets,
onRemove,
layout,
rowIndex,
editable,
frameComponent,
editableColumnClass,
droppableColumnClass,
addWidgetComponentText,
addWidgetComponent,
onAdd,
onMove,
onEdit,
} = props;
const items = columns.map((column, index) => { // eslint-disable-line arrow-body-style
return (
<Column
key={index}
className={column.className}
onAdd={onAdd}
layout={layout}
rowIndex={rowIndex}
columnIndex={index}
editable={editable}
onMove={onMove}
editableColumnClass={editableColumnClass}
droppableColumnClass={droppableColumnClass}
addWidgetComponent={addWidgetComponent}
addWidgetComponentText={addWidgetComponentText}
>
<Widgets
key={index}
widgets={column.widgets}
containerClassName={column.containerClassName}
widgetTypes={widgets}
onRemove={onRemove}
layout={layout}
rowIndex={rowIndex}
columnIndex={index}
editable={editable}
frameComponent={frameComponent}
onMove={onMove}
onEdit={onEdit}
/>
</Column>
);
});
return (
<div className={rowClass}>
{items}
</div>
);
}
|
[
"function",
"Row",
"(",
"props",
")",
"{",
"const",
"{",
"rowClass",
",",
"columns",
",",
"widgets",
",",
"onRemove",
",",
"layout",
",",
"rowIndex",
",",
"editable",
",",
"frameComponent",
",",
"editableColumnClass",
",",
"droppableColumnClass",
",",
"addWidgetComponentText",
",",
"addWidgetComponent",
",",
"onAdd",
",",
"onMove",
",",
"onEdit",
",",
"}",
"=",
"props",
";",
"const",
"items",
"=",
"columns",
".",
"map",
"(",
"(",
"column",
",",
"index",
")",
"=>",
"{",
"// eslint-disable-line arrow-body-style",
"return",
"(",
"<",
"Column",
"key",
"=",
"{",
"index",
"}",
"className",
"=",
"{",
"column",
".",
"className",
"}",
"onAdd",
"=",
"{",
"onAdd",
"}",
"layout",
"=",
"{",
"layout",
"}",
"rowIndex",
"=",
"{",
"rowIndex",
"}",
"columnIndex",
"=",
"{",
"index",
"}",
"editable",
"=",
"{",
"editable",
"}",
"onMove",
"=",
"{",
"onMove",
"}",
"editableColumnClass",
"=",
"{",
"editableColumnClass",
"}",
"droppableColumnClass",
"=",
"{",
"droppableColumnClass",
"}",
"addWidgetComponent",
"=",
"{",
"addWidgetComponent",
"}",
"addWidgetComponentText",
"=",
"{",
"addWidgetComponentText",
"}",
">",
"\n ",
"<",
"Widgets",
"key",
"=",
"{",
"index",
"}",
"widgets",
"=",
"{",
"column",
".",
"widgets",
"}",
"containerClassName",
"=",
"{",
"column",
".",
"containerClassName",
"}",
"widgetTypes",
"=",
"{",
"widgets",
"}",
"onRemove",
"=",
"{",
"onRemove",
"}",
"layout",
"=",
"{",
"layout",
"}",
"rowIndex",
"=",
"{",
"rowIndex",
"}",
"columnIndex",
"=",
"{",
"index",
"}",
"editable",
"=",
"{",
"editable",
"}",
"frameComponent",
"=",
"{",
"frameComponent",
"}",
"onMove",
"=",
"{",
"onMove",
"}",
"onEdit",
"=",
"{",
"onEdit",
"}",
"/",
">",
"\n ",
"<",
"/",
"Column",
">",
")",
";",
"}",
")",
";",
"return",
"(",
"<",
"div",
"className",
"=",
"{",
"rowClass",
"}",
">",
"\n ",
"{",
"items",
"}",
"\n ",
"<",
"/",
"div",
">",
")",
";",
"}"
] |
Returns a set of columns that belongs to a row.
|
[
"Returns",
"a",
"set",
"of",
"columns",
"that",
"belongs",
"to",
"a",
"row",
"."
] |
c4a46f62401a0a1b34efa3a45134a6a34a121770
|
https://github.com/Raathigesh/dazzle/blob/c4a46f62401a0a1b34efa3a45134a6a34a121770/lib/components/Row.js#L9-L67
|
12,634
|
jeffbski/wait-on
|
lib/wait-on.js
|
waitOn
|
function waitOn(opts, cb) {
if (cb !== undefined) {
return waitOnImpl(opts, cb);
} else {
return new Promise(function (resolve, reject) {
waitOnImpl(opts, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
})
});
}
}
|
javascript
|
function waitOn(opts, cb) {
if (cb !== undefined) {
return waitOnImpl(opts, cb);
} else {
return new Promise(function (resolve, reject) {
waitOnImpl(opts, function(err) {
if (err) {
reject(err);
} else {
resolve();
}
})
});
}
}
|
[
"function",
"waitOn",
"(",
"opts",
",",
"cb",
")",
"{",
"if",
"(",
"cb",
"!==",
"undefined",
")",
"{",
"return",
"waitOnImpl",
"(",
"opts",
",",
"cb",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"waitOnImpl",
"(",
"opts",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"reject",
"(",
"err",
")",
";",
"}",
"else",
"{",
"resolve",
"(",
")",
";",
"}",
"}",
")",
"}",
")",
";",
"}",
"}"
] |
Waits for resources to become available before calling callback
Polls file, http(s), tcp ports, sockets for availability.
Resource types are distinquished by their prefix with default being `file:`
- file:/path/to/file - waits for file to be available and size to stabilize
- http://foo.com:8000/bar verifies HTTP HEAD request returns 2XX
- https://my.bar.com/cat verifies HTTPS HEAD request returns 2XX
- http-get: - HTTP GET returns 2XX response. ex: http://m.com:90/foo
- https-get: - HTTPS GET returns 2XX response. ex: https://my/bar
- tcp:my.server.com:3000 verifies a service is listening on port
- socket:/path/sock verifies a service is listening on (UDS) socket
@param opts object configuring waitOn
@param opts.resources array of string resources to wait for. prefix determines the type of resource with the default type of `file:`
@param opts.delay integer - optional initial delay in ms, default 0
@param opts.interval integer - optional poll resource interval in ms, default 250ms
@param opts.log boolean - optional flag to turn on logging to stdout
@param opts.timeout integer - optional timeout in ms, default Infinity. Aborts with error.
@param opts.verbose boolean - optional flag to turn on debug output
@param opts.window integer - optional stabilization time in ms, default 750ms. Waits this amount of time for file sizes to stabilize or other resource availability to remain unchanged. If less than interval then will be reset to interval
@param cb optional callback function with signature cb(err) - if err is provided then, resource checks did not succeed
if not specified, wait-on will return a promise that will be rejected if resource checks did not succeed or resolved otherwise
|
[
"Waits",
"for",
"resources",
"to",
"become",
"available",
"before",
"calling",
"callback"
] |
f45bcd580f2647c7db4f61d79fdcb9005e556720
|
https://github.com/jeffbski/wait-on/blob/f45bcd580f2647c7db4f61d79fdcb9005e556720/lib/wait-on.js#L71-L85
|
12,635
|
adam-cowley/neode
|
src/Services/GenerateDefaultValues.js
|
GenerateDefaultValues
|
function GenerateDefaultValues(neode, model, properties) {
const output = GenerateDefaultValuesAsync(neode, model, properties);
return Promise.resolve(output);
}
|
javascript
|
function GenerateDefaultValues(neode, model, properties) {
const output = GenerateDefaultValuesAsync(neode, model, properties);
return Promise.resolve(output);
}
|
[
"function",
"GenerateDefaultValues",
"(",
"neode",
",",
"model",
",",
"properties",
")",
"{",
"const",
"output",
"=",
"GenerateDefaultValuesAsync",
"(",
"neode",
",",
"model",
",",
"properties",
")",
";",
"return",
"Promise",
".",
"resolve",
"(",
"output",
")",
";",
"}"
] |
Generate default values where no values are not currently set.
@param {Neode} neode
@param {Model} model
@param {Object} properties
@return {Promise}
|
[
"Generate",
"default",
"values",
"where",
"no",
"values",
"are",
"not",
"currently",
"set",
"."
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/src/Services/GenerateDefaultValues.js#L49-L53
|
12,636
|
adam-cowley/neode
|
build/Services/WriteUtils.js
|
splitProperties
|
function splitProperties(mode, model, properties) {
var merge_on = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
var inline = {};
var set = {};
var on_create = {};
var on_match = {};
// Calculate Set Properties
model.properties().forEach(function (property) {
var name = property.name();
// Skip if not set
if (!properties.hasOwnProperty(name)) {
return;
}
var value = (0, _Entity.valueToCypher)(property, properties[name]);
// If mode is create, go ahead and set everything
if (mode == 'create') {
inline[name] = value;
} else if (merge_on.indexOf(name) > -1) {
inline[name] = value;
}
// Only set protected properties on creation
else if (property.protected() || property.primary()) {
on_create[name] = value;
}
// Read-only property?
else if (!property.readonly()) {
set[name] = value;
}
});
return {
inline: inline,
on_create: on_create,
on_match: on_match,
set: set
};
}
|
javascript
|
function splitProperties(mode, model, properties) {
var merge_on = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
var inline = {};
var set = {};
var on_create = {};
var on_match = {};
// Calculate Set Properties
model.properties().forEach(function (property) {
var name = property.name();
// Skip if not set
if (!properties.hasOwnProperty(name)) {
return;
}
var value = (0, _Entity.valueToCypher)(property, properties[name]);
// If mode is create, go ahead and set everything
if (mode == 'create') {
inline[name] = value;
} else if (merge_on.indexOf(name) > -1) {
inline[name] = value;
}
// Only set protected properties on creation
else if (property.protected() || property.primary()) {
on_create[name] = value;
}
// Read-only property?
else if (!property.readonly()) {
set[name] = value;
}
});
return {
inline: inline,
on_create: on_create,
on_match: on_match,
set: set
};
}
|
[
"function",
"splitProperties",
"(",
"mode",
",",
"model",
",",
"properties",
")",
"{",
"var",
"merge_on",
"=",
"arguments",
".",
"length",
">",
"3",
"&&",
"arguments",
"[",
"3",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"3",
"]",
":",
"[",
"]",
";",
"var",
"inline",
"=",
"{",
"}",
";",
"var",
"set",
"=",
"{",
"}",
";",
"var",
"on_create",
"=",
"{",
"}",
";",
"var",
"on_match",
"=",
"{",
"}",
";",
"// Calculate Set Properties",
"model",
".",
"properties",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"property",
")",
"{",
"var",
"name",
"=",
"property",
".",
"name",
"(",
")",
";",
"// Skip if not set",
"if",
"(",
"!",
"properties",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"return",
";",
"}",
"var",
"value",
"=",
"(",
"0",
",",
"_Entity",
".",
"valueToCypher",
")",
"(",
"property",
",",
"properties",
"[",
"name",
"]",
")",
";",
"// If mode is create, go ahead and set everything",
"if",
"(",
"mode",
"==",
"'create'",
")",
"{",
"inline",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"else",
"if",
"(",
"merge_on",
".",
"indexOf",
"(",
"name",
")",
">",
"-",
"1",
")",
"{",
"inline",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"// Only set protected properties on creation",
"else",
"if",
"(",
"property",
".",
"protected",
"(",
")",
"||",
"property",
".",
"primary",
"(",
")",
")",
"{",
"on_create",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"// Read-only property?",
"else",
"if",
"(",
"!",
"property",
".",
"readonly",
"(",
")",
")",
"{",
"set",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"}",
")",
";",
"return",
"{",
"inline",
":",
"inline",
",",
"on_create",
":",
"on_create",
",",
"on_match",
":",
"on_match",
",",
"set",
":",
"set",
"}",
";",
"}"
] |
Split properties into
@param {String} mode 'create' or 'merge'
@param {Model} model Model to merge on
@param {Object} properties Map of properties
@param {Array} merge_on Array of properties explicitly stated to merge on
@return {Object} { inline, set, on_create, on_match }
|
[
"Split",
"properties",
"into"
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/build/Services/WriteUtils.js#L42-L85
|
12,637
|
adam-cowley/neode
|
build/Services/WriteUtils.js
|
addRelationshipToStatement
|
function addRelationshipToStatement(neode, builder, alias, rel_alias, target_alias, relationship, value, aliases, mode) {
if (aliases.length > MAX_CREATE_DEPTH) {
return;
}
// Extract Node
var node_alias = relationship.nodeAlias();
var node_value = value[node_alias];
delete value[node_alias];
// Create Node
// If Node is passed, attempt to create a relationship to that specific node
if (node_value instanceof _Node2.default) {
builder.match(target_alias).whereId(target_alias, node_value.identity());
}
// If Primary key is passed then try to match on that
else if (typeof node_value == 'string' || typeof node_value == 'number') {
var model = neode.model(relationship.target());
builder.merge(target_alias, model, _defineProperty({}, model.primaryKey(), node_value));
}
// If Map is passed, attempt to create that node and then relate
else if (Object.keys(node_value).length) {
var _model = neode.model(relationship.target());
node_value = _GenerateDefaultValues2.default.async(neode, _model, node_value);
addNodeToStatement(neode, builder, target_alias, _model, node_value, aliases, mode, _model.mergeFields());
}
// Create the Relationship
builder[mode](alias).relationship(relationship.relationship(), relationship.direction(), rel_alias).to(target_alias);
// Set Relationship Properties
relationship.properties().forEach(function (property) {
var name = property.name();
if (value.hasOwnProperty(name)) {
builder.set(rel_alias + '.' + name, value[name]);
}
});
}
|
javascript
|
function addRelationshipToStatement(neode, builder, alias, rel_alias, target_alias, relationship, value, aliases, mode) {
if (aliases.length > MAX_CREATE_DEPTH) {
return;
}
// Extract Node
var node_alias = relationship.nodeAlias();
var node_value = value[node_alias];
delete value[node_alias];
// Create Node
// If Node is passed, attempt to create a relationship to that specific node
if (node_value instanceof _Node2.default) {
builder.match(target_alias).whereId(target_alias, node_value.identity());
}
// If Primary key is passed then try to match on that
else if (typeof node_value == 'string' || typeof node_value == 'number') {
var model = neode.model(relationship.target());
builder.merge(target_alias, model, _defineProperty({}, model.primaryKey(), node_value));
}
// If Map is passed, attempt to create that node and then relate
else if (Object.keys(node_value).length) {
var _model = neode.model(relationship.target());
node_value = _GenerateDefaultValues2.default.async(neode, _model, node_value);
addNodeToStatement(neode, builder, target_alias, _model, node_value, aliases, mode, _model.mergeFields());
}
// Create the Relationship
builder[mode](alias).relationship(relationship.relationship(), relationship.direction(), rel_alias).to(target_alias);
// Set Relationship Properties
relationship.properties().forEach(function (property) {
var name = property.name();
if (value.hasOwnProperty(name)) {
builder.set(rel_alias + '.' + name, value[name]);
}
});
}
|
[
"function",
"addRelationshipToStatement",
"(",
"neode",
",",
"builder",
",",
"alias",
",",
"rel_alias",
",",
"target_alias",
",",
"relationship",
",",
"value",
",",
"aliases",
",",
"mode",
")",
"{",
"if",
"(",
"aliases",
".",
"length",
">",
"MAX_CREATE_DEPTH",
")",
"{",
"return",
";",
"}",
"// Extract Node",
"var",
"node_alias",
"=",
"relationship",
".",
"nodeAlias",
"(",
")",
";",
"var",
"node_value",
"=",
"value",
"[",
"node_alias",
"]",
";",
"delete",
"value",
"[",
"node_alias",
"]",
";",
"// Create Node",
"// If Node is passed, attempt to create a relationship to that specific node",
"if",
"(",
"node_value",
"instanceof",
"_Node2",
".",
"default",
")",
"{",
"builder",
".",
"match",
"(",
"target_alias",
")",
".",
"whereId",
"(",
"target_alias",
",",
"node_value",
".",
"identity",
"(",
")",
")",
";",
"}",
"// If Primary key is passed then try to match on that",
"else",
"if",
"(",
"typeof",
"node_value",
"==",
"'string'",
"||",
"typeof",
"node_value",
"==",
"'number'",
")",
"{",
"var",
"model",
"=",
"neode",
".",
"model",
"(",
"relationship",
".",
"target",
"(",
")",
")",
";",
"builder",
".",
"merge",
"(",
"target_alias",
",",
"model",
",",
"_defineProperty",
"(",
"{",
"}",
",",
"model",
".",
"primaryKey",
"(",
")",
",",
"node_value",
")",
")",
";",
"}",
"// If Map is passed, attempt to create that node and then relate",
"else",
"if",
"(",
"Object",
".",
"keys",
"(",
"node_value",
")",
".",
"length",
")",
"{",
"var",
"_model",
"=",
"neode",
".",
"model",
"(",
"relationship",
".",
"target",
"(",
")",
")",
";",
"node_value",
"=",
"_GenerateDefaultValues2",
".",
"default",
".",
"async",
"(",
"neode",
",",
"_model",
",",
"node_value",
")",
";",
"addNodeToStatement",
"(",
"neode",
",",
"builder",
",",
"target_alias",
",",
"_model",
",",
"node_value",
",",
"aliases",
",",
"mode",
",",
"_model",
".",
"mergeFields",
"(",
")",
")",
";",
"}",
"// Create the Relationship",
"builder",
"[",
"mode",
"]",
"(",
"alias",
")",
".",
"relationship",
"(",
"relationship",
".",
"relationship",
"(",
")",
",",
"relationship",
".",
"direction",
"(",
")",
",",
"rel_alias",
")",
".",
"to",
"(",
"target_alias",
")",
";",
"// Set Relationship Properties",
"relationship",
".",
"properties",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"property",
")",
"{",
"var",
"name",
"=",
"property",
".",
"name",
"(",
")",
";",
"if",
"(",
"value",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"builder",
".",
"set",
"(",
"rel_alias",
"+",
"'.'",
"+",
"name",
",",
"value",
"[",
"name",
"]",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Add a relationship to the current statement
@param {Neode} neode Neode instance
@param {Builder} builder Query builder
@param {String} alias Current node alias
@param {String} rel_alias Generated alias for the relationship
@param {String} target_alias Generated alias for the relationship
@param {Relationship} relationship Model
@param {Object} value Value map
@param {Array} aliases Aliases to carry through in with statement
@param {String} mode 'create' or 'merge'
|
[
"Add",
"a",
"relationship",
"to",
"the",
"current",
"statement"
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/build/Services/WriteUtils.js#L220-L264
|
12,638
|
adam-cowley/neode
|
build/Services/WriteUtils.js
|
addNodeRelationshipToStatement
|
function addNodeRelationshipToStatement(neode, builder, alias, rel_alias, target_alias, relationship, value, aliases, mode) {
if (aliases.length > MAX_CREATE_DEPTH) {
return;
}
// If Node is passed, attempt to create a relationship to that specific node
if (value instanceof _Node2.default) {
builder.match(target_alias).whereId(target_alias, value.identity());
}
// If Primary key is passed then try to match on that
else if (typeof value == 'string' || typeof value == 'number') {
var model = neode.model(relationship.target());
builder.merge(target_alias, model, _defineProperty({}, model.primaryKey(), value));
}
// If Map is passed, attempt to create that node and then relate
// TODO: What happens when we need to validate this?
// TODO: Is mergeFields() the right option here?
else if (Object.keys(value).length) {
var _model2 = neode.model(relationship.target());
value = _GenerateDefaultValues2.default.async(neode, _model2, value);
addNodeToStatement(neode, builder, target_alias, _model2, value, aliases, mode, _model2.mergeFields());
}
// Create the Relationship
builder[mode](alias).relationship(relationship.relationship(), relationship.direction(), rel_alias).to(target_alias);
}
|
javascript
|
function addNodeRelationshipToStatement(neode, builder, alias, rel_alias, target_alias, relationship, value, aliases, mode) {
if (aliases.length > MAX_CREATE_DEPTH) {
return;
}
// If Node is passed, attempt to create a relationship to that specific node
if (value instanceof _Node2.default) {
builder.match(target_alias).whereId(target_alias, value.identity());
}
// If Primary key is passed then try to match on that
else if (typeof value == 'string' || typeof value == 'number') {
var model = neode.model(relationship.target());
builder.merge(target_alias, model, _defineProperty({}, model.primaryKey(), value));
}
// If Map is passed, attempt to create that node and then relate
// TODO: What happens when we need to validate this?
// TODO: Is mergeFields() the right option here?
else if (Object.keys(value).length) {
var _model2 = neode.model(relationship.target());
value = _GenerateDefaultValues2.default.async(neode, _model2, value);
addNodeToStatement(neode, builder, target_alias, _model2, value, aliases, mode, _model2.mergeFields());
}
// Create the Relationship
builder[mode](alias).relationship(relationship.relationship(), relationship.direction(), rel_alias).to(target_alias);
}
|
[
"function",
"addNodeRelationshipToStatement",
"(",
"neode",
",",
"builder",
",",
"alias",
",",
"rel_alias",
",",
"target_alias",
",",
"relationship",
",",
"value",
",",
"aliases",
",",
"mode",
")",
"{",
"if",
"(",
"aliases",
".",
"length",
">",
"MAX_CREATE_DEPTH",
")",
"{",
"return",
";",
"}",
"// If Node is passed, attempt to create a relationship to that specific node",
"if",
"(",
"value",
"instanceof",
"_Node2",
".",
"default",
")",
"{",
"builder",
".",
"match",
"(",
"target_alias",
")",
".",
"whereId",
"(",
"target_alias",
",",
"value",
".",
"identity",
"(",
")",
")",
";",
"}",
"// If Primary key is passed then try to match on that",
"else",
"if",
"(",
"typeof",
"value",
"==",
"'string'",
"||",
"typeof",
"value",
"==",
"'number'",
")",
"{",
"var",
"model",
"=",
"neode",
".",
"model",
"(",
"relationship",
".",
"target",
"(",
")",
")",
";",
"builder",
".",
"merge",
"(",
"target_alias",
",",
"model",
",",
"_defineProperty",
"(",
"{",
"}",
",",
"model",
".",
"primaryKey",
"(",
")",
",",
"value",
")",
")",
";",
"}",
"// If Map is passed, attempt to create that node and then relate",
"// TODO: What happens when we need to validate this?",
"// TODO: Is mergeFields() the right option here?",
"else",
"if",
"(",
"Object",
".",
"keys",
"(",
"value",
")",
".",
"length",
")",
"{",
"var",
"_model2",
"=",
"neode",
".",
"model",
"(",
"relationship",
".",
"target",
"(",
")",
")",
";",
"value",
"=",
"_GenerateDefaultValues2",
".",
"default",
".",
"async",
"(",
"neode",
",",
"_model2",
",",
"value",
")",
";",
"addNodeToStatement",
"(",
"neode",
",",
"builder",
",",
"target_alias",
",",
"_model2",
",",
"value",
",",
"aliases",
",",
"mode",
",",
"_model2",
".",
"mergeFields",
"(",
")",
")",
";",
"}",
"// Create the Relationship",
"builder",
"[",
"mode",
"]",
"(",
"alias",
")",
".",
"relationship",
"(",
"relationship",
".",
"relationship",
"(",
")",
",",
"relationship",
".",
"direction",
"(",
")",
",",
"rel_alias",
")",
".",
"to",
"(",
"target_alias",
")",
";",
"}"
] |
Add a node relationship to the current statement
@param {Neode} neode Neode instance
@param {Builder} builder Query builder
@param {String} alias Current node alias
@param {String} rel_alias Generated alias for the relationship
@param {String} target_alias Generated alias for the relationship
@param {Relationship} relationship Model
@param {Object} value Value map
@param {Array} aliases Aliases to carry through in with statement
@param {String} mode 'create' or 'merge'
|
[
"Add",
"a",
"node",
"relationship",
"to",
"the",
"current",
"statement"
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/build/Services/WriteUtils.js#L279-L306
|
12,639
|
adam-cowley/neode
|
build/Entity.js
|
_valueToJson
|
function _valueToJson(property, value) {
if (_neo4jDriver.v1.isInt(value)) {
return value.toNumber();
} else if (_neo4jDriver.v1.temporal.isDate(value) || _neo4jDriver.v1.temporal.isDateTime(value) || _neo4jDriver.v1.temporal.isTime(value) || _neo4jDriver.v1.temporal.isLocalDateTime(value) || _neo4jDriver.v1.temporal.isLocalTime(value) || _neo4jDriver.v1.temporal.isDuration(value)) {
return value.toString();
} else if (_neo4jDriver.v1.spatial.isPoint(value)) {
switch (value.srid.toString()) {
// SRID values: @https://neo4j.com/docs/developer-manual/current/cypher/functions/spatial/
case '4326':
// WGS 84 2D
return { longitude: value.x, latitude: value.y };
case '4979':
// WGS 84 3D
return { longitude: value.x, latitude: value.y, height: value.z };
case '7203':
// Cartesian 2D
return { x: value.x, y: value.y };
case '9157':
// Cartesian 3D
return { x: value.x, y: value.y, z: value.z };
}
}
return value;
}
|
javascript
|
function _valueToJson(property, value) {
if (_neo4jDriver.v1.isInt(value)) {
return value.toNumber();
} else if (_neo4jDriver.v1.temporal.isDate(value) || _neo4jDriver.v1.temporal.isDateTime(value) || _neo4jDriver.v1.temporal.isTime(value) || _neo4jDriver.v1.temporal.isLocalDateTime(value) || _neo4jDriver.v1.temporal.isLocalTime(value) || _neo4jDriver.v1.temporal.isDuration(value)) {
return value.toString();
} else if (_neo4jDriver.v1.spatial.isPoint(value)) {
switch (value.srid.toString()) {
// SRID values: @https://neo4j.com/docs/developer-manual/current/cypher/functions/spatial/
case '4326':
// WGS 84 2D
return { longitude: value.x, latitude: value.y };
case '4979':
// WGS 84 3D
return { longitude: value.x, latitude: value.y, height: value.z };
case '7203':
// Cartesian 2D
return { x: value.x, y: value.y };
case '9157':
// Cartesian 3D
return { x: value.x, y: value.y, z: value.z };
}
}
return value;
}
|
[
"function",
"_valueToJson",
"(",
"property",
",",
"value",
")",
"{",
"if",
"(",
"_neo4jDriver",
".",
"v1",
".",
"isInt",
"(",
"value",
")",
")",
"{",
"return",
"value",
".",
"toNumber",
"(",
")",
";",
"}",
"else",
"if",
"(",
"_neo4jDriver",
".",
"v1",
".",
"temporal",
".",
"isDate",
"(",
"value",
")",
"||",
"_neo4jDriver",
".",
"v1",
".",
"temporal",
".",
"isDateTime",
"(",
"value",
")",
"||",
"_neo4jDriver",
".",
"v1",
".",
"temporal",
".",
"isTime",
"(",
"value",
")",
"||",
"_neo4jDriver",
".",
"v1",
".",
"temporal",
".",
"isLocalDateTime",
"(",
"value",
")",
"||",
"_neo4jDriver",
".",
"v1",
".",
"temporal",
".",
"isLocalTime",
"(",
"value",
")",
"||",
"_neo4jDriver",
".",
"v1",
".",
"temporal",
".",
"isDuration",
"(",
"value",
")",
")",
"{",
"return",
"value",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"_neo4jDriver",
".",
"v1",
".",
"spatial",
".",
"isPoint",
"(",
"value",
")",
")",
"{",
"switch",
"(",
"value",
".",
"srid",
".",
"toString",
"(",
")",
")",
"{",
"// SRID values: @https://neo4j.com/docs/developer-manual/current/cypher/functions/spatial/",
"case",
"'4326'",
":",
"// WGS 84 2D",
"return",
"{",
"longitude",
":",
"value",
".",
"x",
",",
"latitude",
":",
"value",
".",
"y",
"}",
";",
"case",
"'4979'",
":",
"// WGS 84 3D",
"return",
"{",
"longitude",
":",
"value",
".",
"x",
",",
"latitude",
":",
"value",
".",
"y",
",",
"height",
":",
"value",
".",
"z",
"}",
";",
"case",
"'7203'",
":",
"// Cartesian 2D",
"return",
"{",
"x",
":",
"value",
".",
"x",
",",
"y",
":",
"value",
".",
"y",
"}",
";",
"case",
"'9157'",
":",
"// Cartesian 3D",
"return",
"{",
"x",
":",
"value",
".",
"x",
",",
"y",
":",
"value",
".",
"y",
",",
"z",
":",
"value",
".",
"z",
"}",
";",
"}",
"}",
"return",
"value",
";",
"}"
] |
Convert a raw property into a JSON friendly format
@param {Property} property
@param {Mixed} value
@return {Mixed}
|
[
"Convert",
"a",
"raw",
"property",
"into",
"a",
"JSON",
"friendly",
"format"
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/build/Entity.js#L24-L51
|
12,640
|
adam-cowley/neode
|
build/Services/CleanValue.js
|
CleanValue
|
function CleanValue(config, value) {
// Convert temporal to a native date?
if (temporal.indexOf(config.type.toLowerCase()) > -1 && typeof value == 'number') {
value = new Date(value);
}
// Clean Values
switch (config.type.toLowerCase()) {
case 'float':
value = parseFloat(value);
break;
case 'int':
case 'integer':
value = parseInt(value);
break;
case 'bool':
case 'boolean':
value = !!value;
break;
case 'timestamp':
value = value instanceof Date ? value.getTime() : value;
break;
case 'date':
value = value instanceof Date ? _neo4jDriver.v1.types.Date.fromStandardDate(value) : value;
break;
case 'datetime':
value = value instanceof Date ? _neo4jDriver.v1.types.DateTime.fromStandardDate(value) : value;
break;
case 'localdatetime':
value = value instanceof Date ? _neo4jDriver.v1.types.LocalDateTime.fromStandardDate(value) : value;
break;
case 'time':
value = value instanceof Date ? _neo4jDriver.v1.types.Time.fromStandardDate(value) : value;
break;
case 'localtime':
value = value instanceof Date ? _neo4jDriver.v1.types.LocalTime.fromStandardDate(value) : value;
break;
case 'point':
// SRID values: @https://neo4j.com/docs/developer-manual/current/cypher/functions/spatial/
if (isNaN(value.x)) {
// WGS 84
if (isNaN(value.height)) {
value = new _neo4jDriver.v1.types.Point(4326, // WGS 84 2D
value.longitude, value.latitude);
} else {
value = new _neo4jDriver.v1.types.Point(4979, // WGS 84 3D
value.longitude, value.latitude, value.height);
}
} else {
if (isNaN(value.z)) {
value = new _neo4jDriver.v1.types.Point(7203, // Cartesian 2D
value.x, value.y);
} else {
value = new _neo4jDriver.v1.types.Point(9157, // Cartesian 3D
value.x, value.y, value.z);
}
}
break;
}
return value;
}
|
javascript
|
function CleanValue(config, value) {
// Convert temporal to a native date?
if (temporal.indexOf(config.type.toLowerCase()) > -1 && typeof value == 'number') {
value = new Date(value);
}
// Clean Values
switch (config.type.toLowerCase()) {
case 'float':
value = parseFloat(value);
break;
case 'int':
case 'integer':
value = parseInt(value);
break;
case 'bool':
case 'boolean':
value = !!value;
break;
case 'timestamp':
value = value instanceof Date ? value.getTime() : value;
break;
case 'date':
value = value instanceof Date ? _neo4jDriver.v1.types.Date.fromStandardDate(value) : value;
break;
case 'datetime':
value = value instanceof Date ? _neo4jDriver.v1.types.DateTime.fromStandardDate(value) : value;
break;
case 'localdatetime':
value = value instanceof Date ? _neo4jDriver.v1.types.LocalDateTime.fromStandardDate(value) : value;
break;
case 'time':
value = value instanceof Date ? _neo4jDriver.v1.types.Time.fromStandardDate(value) : value;
break;
case 'localtime':
value = value instanceof Date ? _neo4jDriver.v1.types.LocalTime.fromStandardDate(value) : value;
break;
case 'point':
// SRID values: @https://neo4j.com/docs/developer-manual/current/cypher/functions/spatial/
if (isNaN(value.x)) {
// WGS 84
if (isNaN(value.height)) {
value = new _neo4jDriver.v1.types.Point(4326, // WGS 84 2D
value.longitude, value.latitude);
} else {
value = new _neo4jDriver.v1.types.Point(4979, // WGS 84 3D
value.longitude, value.latitude, value.height);
}
} else {
if (isNaN(value.z)) {
value = new _neo4jDriver.v1.types.Point(7203, // Cartesian 2D
value.x, value.y);
} else {
value = new _neo4jDriver.v1.types.Point(9157, // Cartesian 3D
value.x, value.y, value.z);
}
}
break;
}
return value;
}
|
[
"function",
"CleanValue",
"(",
"config",
",",
"value",
")",
"{",
"// Convert temporal to a native date?",
"if",
"(",
"temporal",
".",
"indexOf",
"(",
"config",
".",
"type",
".",
"toLowerCase",
"(",
")",
")",
">",
"-",
"1",
"&&",
"typeof",
"value",
"==",
"'number'",
")",
"{",
"value",
"=",
"new",
"Date",
"(",
"value",
")",
";",
"}",
"// Clean Values",
"switch",
"(",
"config",
".",
"type",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"'float'",
":",
"value",
"=",
"parseFloat",
"(",
"value",
")",
";",
"break",
";",
"case",
"'int'",
":",
"case",
"'integer'",
":",
"value",
"=",
"parseInt",
"(",
"value",
")",
";",
"break",
";",
"case",
"'bool'",
":",
"case",
"'boolean'",
":",
"value",
"=",
"!",
"!",
"value",
";",
"break",
";",
"case",
"'timestamp'",
":",
"value",
"=",
"value",
"instanceof",
"Date",
"?",
"value",
".",
"getTime",
"(",
")",
":",
"value",
";",
"break",
";",
"case",
"'date'",
":",
"value",
"=",
"value",
"instanceof",
"Date",
"?",
"_neo4jDriver",
".",
"v1",
".",
"types",
".",
"Date",
".",
"fromStandardDate",
"(",
"value",
")",
":",
"value",
";",
"break",
";",
"case",
"'datetime'",
":",
"value",
"=",
"value",
"instanceof",
"Date",
"?",
"_neo4jDriver",
".",
"v1",
".",
"types",
".",
"DateTime",
".",
"fromStandardDate",
"(",
"value",
")",
":",
"value",
";",
"break",
";",
"case",
"'localdatetime'",
":",
"value",
"=",
"value",
"instanceof",
"Date",
"?",
"_neo4jDriver",
".",
"v1",
".",
"types",
".",
"LocalDateTime",
".",
"fromStandardDate",
"(",
"value",
")",
":",
"value",
";",
"break",
";",
"case",
"'time'",
":",
"value",
"=",
"value",
"instanceof",
"Date",
"?",
"_neo4jDriver",
".",
"v1",
".",
"types",
".",
"Time",
".",
"fromStandardDate",
"(",
"value",
")",
":",
"value",
";",
"break",
";",
"case",
"'localtime'",
":",
"value",
"=",
"value",
"instanceof",
"Date",
"?",
"_neo4jDriver",
".",
"v1",
".",
"types",
".",
"LocalTime",
".",
"fromStandardDate",
"(",
"value",
")",
":",
"value",
";",
"break",
";",
"case",
"'point'",
":",
"// SRID values: @https://neo4j.com/docs/developer-manual/current/cypher/functions/spatial/",
"if",
"(",
"isNaN",
"(",
"value",
".",
"x",
")",
")",
"{",
"// WGS 84",
"if",
"(",
"isNaN",
"(",
"value",
".",
"height",
")",
")",
"{",
"value",
"=",
"new",
"_neo4jDriver",
".",
"v1",
".",
"types",
".",
"Point",
"(",
"4326",
",",
"// WGS 84 2D",
"value",
".",
"longitude",
",",
"value",
".",
"latitude",
")",
";",
"}",
"else",
"{",
"value",
"=",
"new",
"_neo4jDriver",
".",
"v1",
".",
"types",
".",
"Point",
"(",
"4979",
",",
"// WGS 84 3D",
"value",
".",
"longitude",
",",
"value",
".",
"latitude",
",",
"value",
".",
"height",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isNaN",
"(",
"value",
".",
"z",
")",
")",
"{",
"value",
"=",
"new",
"_neo4jDriver",
".",
"v1",
".",
"types",
".",
"Point",
"(",
"7203",
",",
"// Cartesian 2D",
"value",
".",
"x",
",",
"value",
".",
"y",
")",
";",
"}",
"else",
"{",
"value",
"=",
"new",
"_neo4jDriver",
".",
"v1",
".",
"types",
".",
"Point",
"(",
"9157",
",",
"// Cartesian 3D",
"value",
".",
"x",
",",
"value",
".",
"y",
",",
"value",
".",
"z",
")",
";",
"}",
"}",
"break",
";",
"}",
"return",
"value",
";",
"}"
] |
Convert a value to it's native type
@param {Object} config Field Configuration
@param {mixed} value Value to be converted
@return {mixed}
/* eslint-disable
|
[
"Convert",
"a",
"value",
"to",
"it",
"s",
"native",
"type"
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/build/Services/CleanValue.js#L20-L90
|
12,641
|
adam-cowley/neode
|
src/Services/DeleteNode.js
|
addCascadeDeleteNode
|
function addCascadeDeleteNode(neode, builder, from_alias, relationship, aliases, to_depth) {
if ( aliases.length > to_depth ) return;
const rel_alias = from_alias + relationship.name() + '_rel';
const node_alias = from_alias + relationship.name() + '_node';
const target = neode.model( relationship.target() );
// Optional Match
builder.optionalMatch(from_alias)
.relationship(relationship.relationship(), relationship.direction(), rel_alias)
.to(node_alias, relationship.target());
// Check for cascade deletions
target.relationships().forEach(relationship => {
switch ( relationship.cascade() ) {
case 'delete':
addCascadeDeleteNode(neode, builder, node_alias, relationship, aliases.concat(node_alias), to_depth);
break;
// case 'detach':
// addDetachNode(neode, builder, node_alias, relationship, aliases);
// break;
}
});
// Delete it
builder.detachDelete(node_alias);
}
|
javascript
|
function addCascadeDeleteNode(neode, builder, from_alias, relationship, aliases, to_depth) {
if ( aliases.length > to_depth ) return;
const rel_alias = from_alias + relationship.name() + '_rel';
const node_alias = from_alias + relationship.name() + '_node';
const target = neode.model( relationship.target() );
// Optional Match
builder.optionalMatch(from_alias)
.relationship(relationship.relationship(), relationship.direction(), rel_alias)
.to(node_alias, relationship.target());
// Check for cascade deletions
target.relationships().forEach(relationship => {
switch ( relationship.cascade() ) {
case 'delete':
addCascadeDeleteNode(neode, builder, node_alias, relationship, aliases.concat(node_alias), to_depth);
break;
// case 'detach':
// addDetachNode(neode, builder, node_alias, relationship, aliases);
// break;
}
});
// Delete it
builder.detachDelete(node_alias);
}
|
[
"function",
"addCascadeDeleteNode",
"(",
"neode",
",",
"builder",
",",
"from_alias",
",",
"relationship",
",",
"aliases",
",",
"to_depth",
")",
"{",
"if",
"(",
"aliases",
".",
"length",
">",
"to_depth",
")",
"return",
";",
"const",
"rel_alias",
"=",
"from_alias",
"+",
"relationship",
".",
"name",
"(",
")",
"+",
"'_rel'",
";",
"const",
"node_alias",
"=",
"from_alias",
"+",
"relationship",
".",
"name",
"(",
")",
"+",
"'_node'",
";",
"const",
"target",
"=",
"neode",
".",
"model",
"(",
"relationship",
".",
"target",
"(",
")",
")",
";",
"// Optional Match",
"builder",
".",
"optionalMatch",
"(",
"from_alias",
")",
".",
"relationship",
"(",
"relationship",
".",
"relationship",
"(",
")",
",",
"relationship",
".",
"direction",
"(",
")",
",",
"rel_alias",
")",
".",
"to",
"(",
"node_alias",
",",
"relationship",
".",
"target",
"(",
")",
")",
";",
"// Check for cascade deletions",
"target",
".",
"relationships",
"(",
")",
".",
"forEach",
"(",
"relationship",
"=>",
"{",
"switch",
"(",
"relationship",
".",
"cascade",
"(",
")",
")",
"{",
"case",
"'delete'",
":",
"addCascadeDeleteNode",
"(",
"neode",
",",
"builder",
",",
"node_alias",
",",
"relationship",
",",
"aliases",
".",
"concat",
"(",
"node_alias",
")",
",",
"to_depth",
")",
";",
"break",
";",
"// case 'detach':",
"// addDetachNode(neode, builder, node_alias, relationship, aliases); ",
"// break;",
"}",
"}",
")",
";",
"// Delete it",
"builder",
".",
"detachDelete",
"(",
"node_alias",
")",
";",
"}"
] |
Add a recursive cascade deletion
@param {Neode} neode Neode instance
@param {Builder} builder Query Builder
@param {String} alias Alias of node
@param {RelationshipType} relationship relationship type definition
@param {Array} aliases Current aliases
@param {Integer} to_depth Maximum depth to delete to
|
[
"Add",
"a",
"recursive",
"cascade",
"deletion"
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/src/Services/DeleteNode.js#L17-L44
|
12,642
|
adam-cowley/neode
|
build/Services/DeleteNode.js
|
DeleteNode
|
function DeleteNode(neode, identity, model) {
var to_depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MAX_EAGER_DEPTH;
var alias = 'this';
var to_delete = [];
var aliases = [alias];
var depth = 1;
var builder = new _Builder2.default(neode).match(alias, model).whereId(alias, identity);
// Cascade delete to relationships
model.relationships().forEach(function (relationship) {
switch (relationship.cascade()) {
case 'delete':
addCascadeDeleteNode(neode, builder, alias, relationship, aliases, to_depth);
break;
// case 'detach':
// addDetachNode(neode, builder, alias, relationship, aliases);
// break;
}
});
// Detach Delete target node
builder.detachDelete(alias);
return builder.execute(_Builder.mode.WRITE);
}
|
javascript
|
function DeleteNode(neode, identity, model) {
var to_depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MAX_EAGER_DEPTH;
var alias = 'this';
var to_delete = [];
var aliases = [alias];
var depth = 1;
var builder = new _Builder2.default(neode).match(alias, model).whereId(alias, identity);
// Cascade delete to relationships
model.relationships().forEach(function (relationship) {
switch (relationship.cascade()) {
case 'delete':
addCascadeDeleteNode(neode, builder, alias, relationship, aliases, to_depth);
break;
// case 'detach':
// addDetachNode(neode, builder, alias, relationship, aliases);
// break;
}
});
// Detach Delete target node
builder.detachDelete(alias);
return builder.execute(_Builder.mode.WRITE);
}
|
[
"function",
"DeleteNode",
"(",
"neode",
",",
"identity",
",",
"model",
")",
"{",
"var",
"to_depth",
"=",
"arguments",
".",
"length",
">",
"3",
"&&",
"arguments",
"[",
"3",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"3",
"]",
":",
"MAX_EAGER_DEPTH",
";",
"var",
"alias",
"=",
"'this'",
";",
"var",
"to_delete",
"=",
"[",
"]",
";",
"var",
"aliases",
"=",
"[",
"alias",
"]",
";",
"var",
"depth",
"=",
"1",
";",
"var",
"builder",
"=",
"new",
"_Builder2",
".",
"default",
"(",
"neode",
")",
".",
"match",
"(",
"alias",
",",
"model",
")",
".",
"whereId",
"(",
"alias",
",",
"identity",
")",
";",
"// Cascade delete to relationships",
"model",
".",
"relationships",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"relationship",
")",
"{",
"switch",
"(",
"relationship",
".",
"cascade",
"(",
")",
")",
"{",
"case",
"'delete'",
":",
"addCascadeDeleteNode",
"(",
"neode",
",",
"builder",
",",
"alias",
",",
"relationship",
",",
"aliases",
",",
"to_depth",
")",
";",
"break",
";",
"// case 'detach':",
"// addDetachNode(neode, builder, alias, relationship, aliases);",
"// break;",
"}",
"}",
")",
";",
"// Detach Delete target node",
"builder",
".",
"detachDelete",
"(",
"alias",
")",
";",
"return",
"builder",
".",
"execute",
"(",
"_Builder",
".",
"mode",
".",
"WRITE",
")",
";",
"}"
] |
Delete the relationship to the other node
@param {Neode} neode Neode instance
@param {Builder} builder Query Builder
@param {String} from_alias Alias of node at start of the match
@param {RelationshipType} relationship model definition
@param {Array} aliases Current aliases
/
function addDetachNode(neode, builder, from_alias, relationship, aliases) {
builder.withDistinct(aliases);
const rel_alias = from_alias + relationship.name() + '_rel';
builder.optionalMatch(from_alias)
.relationship(relationship.relationship(), relationship.direction(), rel_alias)
.toAnything()
.delete(rel_alias);
builder.withDistinct( aliases );
}
Cascade Delete a Node
@param {Neode} neode Neode instance
@param {Integer} identity Neo4j internal ID of node to delete
@param {Model} model Model definition
@param {Integer} to_depth Maximum deletion depth
|
[
"Delete",
"the",
"relationship",
"to",
"the",
"other",
"node"
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/build/Services/DeleteNode.js#L87-L114
|
12,643
|
adam-cowley/neode
|
build/Query/EagerUtils.js
|
eagerPattern
|
function eagerPattern(neode, depth, alias, rel) {
var builder = new _Builder2.default();
var name = rel.name();
var type = rel.type();
var relationship = rel.relationship();
var direction = rel.direction();
var target = rel.target();
var relationship_variable = alias + '_' + name + '_rel';
var node_variable = alias + '_' + name + '_node';
var target_model = neode.model(target);
// Build Pattern
builder.match(alias).relationship(relationship, direction, relationship_variable).to(node_variable, target_model);
var fields = node_variable;
switch (type) {
case 'node':
case 'nodes':
fields = eagerNode(neode, depth + 1, node_variable, target_model);
break;
case 'relationship':
case 'relationships':
fields = eagerRelationship(neode, depth + 1, relationship_variable, rel.nodeAlias(), node_variable, target_model);
}
var pattern = name + ': [ ' + builder.pattern().trim() + ' | ' + fields + ' ]';
// Get the first?
if (type === 'node' || type === 'relationship') {
return pattern + '[0]';
}
return pattern;
}
|
javascript
|
function eagerPattern(neode, depth, alias, rel) {
var builder = new _Builder2.default();
var name = rel.name();
var type = rel.type();
var relationship = rel.relationship();
var direction = rel.direction();
var target = rel.target();
var relationship_variable = alias + '_' + name + '_rel';
var node_variable = alias + '_' + name + '_node';
var target_model = neode.model(target);
// Build Pattern
builder.match(alias).relationship(relationship, direction, relationship_variable).to(node_variable, target_model);
var fields = node_variable;
switch (type) {
case 'node':
case 'nodes':
fields = eagerNode(neode, depth + 1, node_variable, target_model);
break;
case 'relationship':
case 'relationships':
fields = eagerRelationship(neode, depth + 1, relationship_variable, rel.nodeAlias(), node_variable, target_model);
}
var pattern = name + ': [ ' + builder.pattern().trim() + ' | ' + fields + ' ]';
// Get the first?
if (type === 'node' || type === 'relationship') {
return pattern + '[0]';
}
return pattern;
}
|
[
"function",
"eagerPattern",
"(",
"neode",
",",
"depth",
",",
"alias",
",",
"rel",
")",
"{",
"var",
"builder",
"=",
"new",
"_Builder2",
".",
"default",
"(",
")",
";",
"var",
"name",
"=",
"rel",
".",
"name",
"(",
")",
";",
"var",
"type",
"=",
"rel",
".",
"type",
"(",
")",
";",
"var",
"relationship",
"=",
"rel",
".",
"relationship",
"(",
")",
";",
"var",
"direction",
"=",
"rel",
".",
"direction",
"(",
")",
";",
"var",
"target",
"=",
"rel",
".",
"target",
"(",
")",
";",
"var",
"relationship_variable",
"=",
"alias",
"+",
"'_'",
"+",
"name",
"+",
"'_rel'",
";",
"var",
"node_variable",
"=",
"alias",
"+",
"'_'",
"+",
"name",
"+",
"'_node'",
";",
"var",
"target_model",
"=",
"neode",
".",
"model",
"(",
"target",
")",
";",
"// Build Pattern",
"builder",
".",
"match",
"(",
"alias",
")",
".",
"relationship",
"(",
"relationship",
",",
"direction",
",",
"relationship_variable",
")",
".",
"to",
"(",
"node_variable",
",",
"target_model",
")",
";",
"var",
"fields",
"=",
"node_variable",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"'node'",
":",
"case",
"'nodes'",
":",
"fields",
"=",
"eagerNode",
"(",
"neode",
",",
"depth",
"+",
"1",
",",
"node_variable",
",",
"target_model",
")",
";",
"break",
";",
"case",
"'relationship'",
":",
"case",
"'relationships'",
":",
"fields",
"=",
"eagerRelationship",
"(",
"neode",
",",
"depth",
"+",
"1",
",",
"relationship_variable",
",",
"rel",
".",
"nodeAlias",
"(",
")",
",",
"node_variable",
",",
"target_model",
")",
";",
"}",
"var",
"pattern",
"=",
"name",
"+",
"': [ '",
"+",
"builder",
".",
"pattern",
"(",
")",
".",
"trim",
"(",
")",
"+",
"' | '",
"+",
"fields",
"+",
"' ]'",
";",
"// Get the first?",
"if",
"(",
"type",
"===",
"'node'",
"||",
"type",
"===",
"'relationship'",
")",
"{",
"return",
"pattern",
"+",
"'[0]'",
";",
"}",
"return",
"pattern",
";",
"}"
] |
Build a pattern to use in an eager load statement
@param {Neode} neode Neode instance
@param {Integer} depth Maximum depth to stop at
@param {String} alias Alias for the starting node
@param {RelationshipType} rel Type of relationship
|
[
"Build",
"a",
"pattern",
"to",
"use",
"in",
"an",
"eager",
"load",
"statement"
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/build/Query/EagerUtils.js#L30-L67
|
12,644
|
adam-cowley/neode
|
build/Query/EagerUtils.js
|
eagerNode
|
function eagerNode(neode, depth, alias, model) {
var indent = ' '.repeat(depth * 2);
var pattern = '\n' + indent + ' ' + alias + ' { ';
// Properties
pattern += '\n' + indent + indent + '.*';
// ID
pattern += '\n' + indent + indent + ',' + EAGER_ID + ': id(' + alias + ')';
// Labels
pattern += '\n' + indent + indent + ',' + EAGER_LABELS + ': labels(' + alias + ')';
// Eager
if (model && depth <= MAX_EAGER_DEPTH) {
model.eager().forEach(function (rel) {
pattern += '\n' + indent + indent + ',' + eagerPattern(neode, depth, alias, rel);
});
}
pattern += '\n' + indent + '}';
return pattern;
}
|
javascript
|
function eagerNode(neode, depth, alias, model) {
var indent = ' '.repeat(depth * 2);
var pattern = '\n' + indent + ' ' + alias + ' { ';
// Properties
pattern += '\n' + indent + indent + '.*';
// ID
pattern += '\n' + indent + indent + ',' + EAGER_ID + ': id(' + alias + ')';
// Labels
pattern += '\n' + indent + indent + ',' + EAGER_LABELS + ': labels(' + alias + ')';
// Eager
if (model && depth <= MAX_EAGER_DEPTH) {
model.eager().forEach(function (rel) {
pattern += '\n' + indent + indent + ',' + eagerPattern(neode, depth, alias, rel);
});
}
pattern += '\n' + indent + '}';
return pattern;
}
|
[
"function",
"eagerNode",
"(",
"neode",
",",
"depth",
",",
"alias",
",",
"model",
")",
"{",
"var",
"indent",
"=",
"' '",
".",
"repeat",
"(",
"depth",
"*",
"2",
")",
";",
"var",
"pattern",
"=",
"'\\n'",
"+",
"indent",
"+",
"' '",
"+",
"alias",
"+",
"' { '",
";",
"// Properties",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"indent",
"+",
"'.*'",
";",
"// ID",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"indent",
"+",
"','",
"+",
"EAGER_ID",
"+",
"': id('",
"+",
"alias",
"+",
"')'",
";",
"// Labels",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"indent",
"+",
"','",
"+",
"EAGER_LABELS",
"+",
"': labels('",
"+",
"alias",
"+",
"')'",
";",
"// Eager",
"if",
"(",
"model",
"&&",
"depth",
"<=",
"MAX_EAGER_DEPTH",
")",
"{",
"model",
".",
"eager",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"rel",
")",
"{",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"indent",
"+",
"','",
"+",
"eagerPattern",
"(",
"neode",
",",
"depth",
",",
"alias",
",",
"rel",
")",
";",
"}",
")",
";",
"}",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"'}'",
";",
"return",
"pattern",
";",
"}"
] |
Produces a Cypher pattern for a consistant eager loading format for a
Node and any subsequent eagerly loaded models up to the maximum depth.
@param {Neode} neode Neode instance
@param {Integer} depth Maximum depth to traverse to
@param {String} alias Alias of the node
@param {Model} model Node model
|
[
"Produces",
"a",
"Cypher",
"pattern",
"for",
"a",
"consistant",
"eager",
"loading",
"format",
"for",
"a",
"Node",
"and",
"any",
"subsequent",
"eagerly",
"loaded",
"models",
"up",
"to",
"the",
"maximum",
"depth",
"."
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/build/Query/EagerUtils.js#L78-L101
|
12,645
|
adam-cowley/neode
|
build/Query/EagerUtils.js
|
eagerRelationship
|
function eagerRelationship(neode, depth, alias, node_alias, node_variable, node_model) {
var indent = ' '.repeat(depth * 2);
var pattern = '\n' + indent + ' ' + alias + ' { ';
// Properties
pattern += '\n' + indent + indent + '.*';
// ID
pattern += '\n' + indent + indent + ',' + EAGER_ID + ': id(' + alias + ')';
// Type
pattern += '\n' + indent + indent + ',' + EAGER_TYPE + ': type(' + alias + ')';
// Node Alias
// pattern += `\n,${indent}${indent},${node_alias}`
pattern += '\n' + indent + indent + ',' + node_alias + ': ';
pattern += eagerNode(neode, depth + 1, node_variable, node_model);
pattern += '\n' + indent + '}';
return pattern;
}
|
javascript
|
function eagerRelationship(neode, depth, alias, node_alias, node_variable, node_model) {
var indent = ' '.repeat(depth * 2);
var pattern = '\n' + indent + ' ' + alias + ' { ';
// Properties
pattern += '\n' + indent + indent + '.*';
// ID
pattern += '\n' + indent + indent + ',' + EAGER_ID + ': id(' + alias + ')';
// Type
pattern += '\n' + indent + indent + ',' + EAGER_TYPE + ': type(' + alias + ')';
// Node Alias
// pattern += `\n,${indent}${indent},${node_alias}`
pattern += '\n' + indent + indent + ',' + node_alias + ': ';
pattern += eagerNode(neode, depth + 1, node_variable, node_model);
pattern += '\n' + indent + '}';
return pattern;
}
|
[
"function",
"eagerRelationship",
"(",
"neode",
",",
"depth",
",",
"alias",
",",
"node_alias",
",",
"node_variable",
",",
"node_model",
")",
"{",
"var",
"indent",
"=",
"' '",
".",
"repeat",
"(",
"depth",
"*",
"2",
")",
";",
"var",
"pattern",
"=",
"'\\n'",
"+",
"indent",
"+",
"' '",
"+",
"alias",
"+",
"' { '",
";",
"// Properties",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"indent",
"+",
"'.*'",
";",
"// ID",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"indent",
"+",
"','",
"+",
"EAGER_ID",
"+",
"': id('",
"+",
"alias",
"+",
"')'",
";",
"// Type",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"indent",
"+",
"','",
"+",
"EAGER_TYPE",
"+",
"': type('",
"+",
"alias",
"+",
"')'",
";",
"// Node Alias",
"// pattern += `\\n,${indent}${indent},${node_alias}`",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"indent",
"+",
"','",
"+",
"node_alias",
"+",
"': '",
";",
"pattern",
"+=",
"eagerNode",
"(",
"neode",
",",
"depth",
"+",
"1",
",",
"node_variable",
",",
"node_model",
")",
";",
"pattern",
"+=",
"'\\n'",
"+",
"indent",
"+",
"'}'",
";",
"return",
"pattern",
";",
"}"
] |
Produces a Cypher pattern for a consistant eager loading format for a
Relationship and any subsequent eagerly loaded modules up to the maximum depth.
@param {Neode} neode Neode instance
@param {Integer} depth Maximum depth to traverse to
@param {String} alias Alias of the node
@param {Model} model Node model
|
[
"Produces",
"a",
"Cypher",
"pattern",
"for",
"a",
"consistant",
"eager",
"loading",
"format",
"for",
"a",
"Relationship",
"and",
"any",
"subsequent",
"eagerly",
"loaded",
"modules",
"up",
"to",
"the",
"maximum",
"depth",
"."
] |
f978655da08715602df32cc6b687dd3c9139a62f
|
https://github.com/adam-cowley/neode/blob/f978655da08715602df32cc6b687dd3c9139a62f/build/Query/EagerUtils.js#L112-L133
|
12,646
|
liriliri/licia
|
src/m/moment.js
|
normalizeUnit
|
function normalizeUnit(unit) {
unit = toStr(unit);
if (unitShorthandMap[unit]) return unitShorthandMap[unit];
return unit.toLowerCase().replace(regEndS, '');
}
|
javascript
|
function normalizeUnit(unit) {
unit = toStr(unit);
if (unitShorthandMap[unit]) return unitShorthandMap[unit];
return unit.toLowerCase().replace(regEndS, '');
}
|
[
"function",
"normalizeUnit",
"(",
"unit",
")",
"{",
"unit",
"=",
"toStr",
"(",
"unit",
")",
";",
"if",
"(",
"unitShorthandMap",
"[",
"unit",
"]",
")",
"return",
"unitShorthandMap",
"[",
"unit",
"]",
";",
"return",
"unit",
".",
"toLowerCase",
"(",
")",
".",
"replace",
"(",
"regEndS",
",",
"''",
")",
";",
"}"
] |
Turn 'y' or 'years' into 'year'
|
[
"Turn",
"y",
"or",
"years",
"into",
"year"
] |
76b023379f678a6e6e6b3060cd340527ffffb41f
|
https://github.com/liriliri/licia/blob/76b023379f678a6e6e6b3060cd340527ffffb41f/src/m/moment.js#L289-L295
|
12,647
|
liriliri/licia
|
src/g/getPort.js
|
isAvailable
|
function isAvailable(port) {
return new Promise((resolve, reject) => {
const server = net.createServer();
server.unref();
server.on('error', reject);
const options = {};
options.port = port;
server.listen(options, () => {
const { port } = server.address();
server.close(() => {
resolve(port);
});
});
});
}
|
javascript
|
function isAvailable(port) {
return new Promise((resolve, reject) => {
const server = net.createServer();
server.unref();
server.on('error', reject);
const options = {};
options.port = port;
server.listen(options, () => {
const { port } = server.address();
server.close(() => {
resolve(port);
});
});
});
}
|
[
"function",
"isAvailable",
"(",
"port",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"server",
"=",
"net",
".",
"createServer",
"(",
")",
";",
"server",
".",
"unref",
"(",
")",
";",
"server",
".",
"on",
"(",
"'error'",
",",
"reject",
")",
";",
"const",
"options",
"=",
"{",
"}",
";",
"options",
".",
"port",
"=",
"port",
";",
"server",
".",
"listen",
"(",
"options",
",",
"(",
")",
"=>",
"{",
"const",
"{",
"port",
"}",
"=",
"server",
".",
"address",
"(",
")",
";",
"server",
".",
"close",
"(",
"(",
")",
"=>",
"{",
"resolve",
"(",
"port",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Passing 0 will get an available random port.
|
[
"Passing",
"0",
"will",
"get",
"an",
"available",
"random",
"port",
"."
] |
76b023379f678a6e6e6b3060cd340527ffffb41f
|
https://github.com/liriliri/licia/blob/76b023379f678a6e6e6b3060cd340527ffffb41f/src/g/getPort.js#L40-L55
|
12,648
|
muicss/loadjs
|
src/loadjs.js
|
loadFiles
|
function loadFiles(paths, callbackFn, args) {
// listify paths
paths = paths.push ? paths : [paths];
var numWaiting = paths.length,
x = numWaiting,
pathsNotFound = [],
fn,
i;
// define callback function
fn = function(path, result, defaultPrevented) {
// handle error
if (result == 'e') pathsNotFound.push(path);
// handle beforeload event. If defaultPrevented then that means the load
// will be blocked (ex. Ghostery/ABP on Safari)
if (result == 'b') {
if (defaultPrevented) pathsNotFound.push(path);
else return;
}
numWaiting--;
if (!numWaiting) callbackFn(pathsNotFound);
};
// load scripts
for (i=0; i < x; i++) loadFile(paths[i], fn, args);
}
|
javascript
|
function loadFiles(paths, callbackFn, args) {
// listify paths
paths = paths.push ? paths : [paths];
var numWaiting = paths.length,
x = numWaiting,
pathsNotFound = [],
fn,
i;
// define callback function
fn = function(path, result, defaultPrevented) {
// handle error
if (result == 'e') pathsNotFound.push(path);
// handle beforeload event. If defaultPrevented then that means the load
// will be blocked (ex. Ghostery/ABP on Safari)
if (result == 'b') {
if (defaultPrevented) pathsNotFound.push(path);
else return;
}
numWaiting--;
if (!numWaiting) callbackFn(pathsNotFound);
};
// load scripts
for (i=0; i < x; i++) loadFile(paths[i], fn, args);
}
|
[
"function",
"loadFiles",
"(",
"paths",
",",
"callbackFn",
",",
"args",
")",
"{",
"// listify paths",
"paths",
"=",
"paths",
".",
"push",
"?",
"paths",
":",
"[",
"paths",
"]",
";",
"var",
"numWaiting",
"=",
"paths",
".",
"length",
",",
"x",
"=",
"numWaiting",
",",
"pathsNotFound",
"=",
"[",
"]",
",",
"fn",
",",
"i",
";",
"// define callback function",
"fn",
"=",
"function",
"(",
"path",
",",
"result",
",",
"defaultPrevented",
")",
"{",
"// handle error",
"if",
"(",
"result",
"==",
"'e'",
")",
"pathsNotFound",
".",
"push",
"(",
"path",
")",
";",
"// handle beforeload event. If defaultPrevented then that means the load",
"// will be blocked (ex. Ghostery/ABP on Safari)",
"if",
"(",
"result",
"==",
"'b'",
")",
"{",
"if",
"(",
"defaultPrevented",
")",
"pathsNotFound",
".",
"push",
"(",
"path",
")",
";",
"else",
"return",
";",
"}",
"numWaiting",
"--",
";",
"if",
"(",
"!",
"numWaiting",
")",
"callbackFn",
"(",
"pathsNotFound",
")",
";",
"}",
";",
"// load scripts",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"x",
";",
"i",
"++",
")",
"loadFile",
"(",
"paths",
"[",
"i",
"]",
",",
"fn",
",",
"args",
")",
";",
"}"
] |
Load multiple files.
@param {string[]} paths - The file paths
@param {Function} callbackFn - The callback function
|
[
"Load",
"multiple",
"files",
"."
] |
a20ea05b7cc6732e8754de16780fca84dd700c40
|
https://github.com/muicss/loadjs/blob/a20ea05b7cc6732e8754de16780fca84dd700c40/src/loadjs.js#L180-L208
|
12,649
|
muicss/loadjs
|
examples/assets/log.js
|
log
|
function log(msg) {
var d = new Date(), ts;
ts = d.toLocaleTimeString().split(' ');
ts = ts[0] + '.' + d.getMilliseconds() + ' ' + ts[1];
console.log('[' + ts + '] ' + msg);
}
|
javascript
|
function log(msg) {
var d = new Date(), ts;
ts = d.toLocaleTimeString().split(' ');
ts = ts[0] + '.' + d.getMilliseconds() + ' ' + ts[1];
console.log('[' + ts + '] ' + msg);
}
|
[
"function",
"log",
"(",
"msg",
")",
"{",
"var",
"d",
"=",
"new",
"Date",
"(",
")",
",",
"ts",
";",
"ts",
"=",
"d",
".",
"toLocaleTimeString",
"(",
")",
".",
"split",
"(",
"' '",
")",
";",
"ts",
"=",
"ts",
"[",
"0",
"]",
"+",
"'.'",
"+",
"d",
".",
"getMilliseconds",
"(",
")",
"+",
"' '",
"+",
"ts",
"[",
"1",
"]",
";",
"console",
".",
"log",
"(",
"'['",
"+",
"ts",
"+",
"'] '",
"+",
"msg",
")",
";",
"}"
] |
define global logging function
|
[
"define",
"global",
"logging",
"function"
] |
a20ea05b7cc6732e8754de16780fca84dd700c40
|
https://github.com/muicss/loadjs/blob/a20ea05b7cc6732e8754de16780fca84dd700c40/examples/assets/log.js#L2-L8
|
12,650
|
freearhey/vue2-filters
|
src/string/placeholder.js
|
placeholder
|
function placeholder (input, property) {
return ( input === undefined || input === '' || input === null ) ? property : input;
}
|
javascript
|
function placeholder (input, property) {
return ( input === undefined || input === '' || input === null ) ? property : input;
}
|
[
"function",
"placeholder",
"(",
"input",
",",
"property",
")",
"{",
"return",
"(",
"input",
"===",
"undefined",
"||",
"input",
"===",
"''",
"||",
"input",
"===",
"null",
")",
"?",
"property",
":",
"input",
";",
"}"
] |
If the value is missing outputs the placeholder text
'' => {placeholder}
'foo' => 'foo'
|
[
"If",
"the",
"value",
"is",
"missing",
"outputs",
"the",
"placeholder",
"text"
] |
d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c
|
https://github.com/freearhey/vue2-filters/blob/d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c/src/string/placeholder.js#L8-L10
|
12,651
|
freearhey/vue2-filters
|
src/string/capitalize.js
|
capitalize
|
function capitalize (value, options) {
options = options || {}
var onlyFirstLetter = options.onlyFirstLetter != null ? options.onlyFirstLetter : false
if (!value && value !== 0) return ''
if(onlyFirstLetter === true) {
return value.charAt(0).toUpperCase() + value.slice(1)
} else {
value = value.toString().toLowerCase().split(' ')
return value.map(function(item) {
return item.charAt(0).toUpperCase() + item.slice(1)
}).join(' ')
}
}
|
javascript
|
function capitalize (value, options) {
options = options || {}
var onlyFirstLetter = options.onlyFirstLetter != null ? options.onlyFirstLetter : false
if (!value && value !== 0) return ''
if(onlyFirstLetter === true) {
return value.charAt(0).toUpperCase() + value.slice(1)
} else {
value = value.toString().toLowerCase().split(' ')
return value.map(function(item) {
return item.charAt(0).toUpperCase() + item.slice(1)
}).join(' ')
}
}
|
[
"function",
"capitalize",
"(",
"value",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"var",
"onlyFirstLetter",
"=",
"options",
".",
"onlyFirstLetter",
"!=",
"null",
"?",
"options",
".",
"onlyFirstLetter",
":",
"false",
"if",
"(",
"!",
"value",
"&&",
"value",
"!==",
"0",
")",
"return",
"''",
"if",
"(",
"onlyFirstLetter",
"===",
"true",
")",
"{",
"return",
"value",
".",
"charAt",
"(",
"0",
")",
".",
"toUpperCase",
"(",
")",
"+",
"value",
".",
"slice",
"(",
"1",
")",
"}",
"else",
"{",
"value",
"=",
"value",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"split",
"(",
"' '",
")",
"return",
"value",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"item",
".",
"charAt",
"(",
"0",
")",
".",
"toUpperCase",
"(",
")",
"+",
"item",
".",
"slice",
"(",
"1",
")",
"}",
")",
".",
"join",
"(",
"' '",
")",
"}",
"}"
] |
Converts a string into Capitalize
'abc' => 'Abc'
@param {Object} options
|
[
"Converts",
"a",
"string",
"into",
"Capitalize"
] |
d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c
|
https://github.com/freearhey/vue2-filters/blob/d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c/src/string/capitalize.js#L9-L21
|
12,652
|
freearhey/vue2-filters
|
src/array/limitBy.js
|
limitBy
|
function limitBy (arr, n, offset) {
offset = offset ? parseInt(offset, 10) : 0
n = util.toNumber(n)
return typeof n === 'number'
? arr.slice(offset, offset + n)
: arr
}
|
javascript
|
function limitBy (arr, n, offset) {
offset = offset ? parseInt(offset, 10) : 0
n = util.toNumber(n)
return typeof n === 'number'
? arr.slice(offset, offset + n)
: arr
}
|
[
"function",
"limitBy",
"(",
"arr",
",",
"n",
",",
"offset",
")",
"{",
"offset",
"=",
"offset",
"?",
"parseInt",
"(",
"offset",
",",
"10",
")",
":",
"0",
"n",
"=",
"util",
".",
"toNumber",
"(",
"n",
")",
"return",
"typeof",
"n",
"===",
"'number'",
"?",
"arr",
".",
"slice",
"(",
"offset",
",",
"offset",
"+",
"n",
")",
":",
"arr",
"}"
] |
Limit filter for arrays
@param {Number} n
@param {Number} offset (Decimal expected)
|
[
"Limit",
"filter",
"for",
"arrays"
] |
d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c
|
https://github.com/freearhey/vue2-filters/blob/d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c/src/array/limitBy.js#L10-L16
|
12,653
|
freearhey/vue2-filters
|
src/other/ordinal.js
|
ordinal
|
function ordinal (value, options) {
options = options || {}
var output = ''
var includeNumber = options.includeNumber != null ? options.includeNumber : false
if(includeNumber === true) output += value
var j = value % 10,
k = value % 100
if (j == 1 && k != 11) output += 'st'
else if (j == 2 && k != 12) output += 'nd'
else if (j == 3 && k != 13) output += 'rd'
else output += 'th'
return output
}
|
javascript
|
function ordinal (value, options) {
options = options || {}
var output = ''
var includeNumber = options.includeNumber != null ? options.includeNumber : false
if(includeNumber === true) output += value
var j = value % 10,
k = value % 100
if (j == 1 && k != 11) output += 'st'
else if (j == 2 && k != 12) output += 'nd'
else if (j == 3 && k != 13) output += 'rd'
else output += 'th'
return output
}
|
[
"function",
"ordinal",
"(",
"value",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"var",
"output",
"=",
"''",
"var",
"includeNumber",
"=",
"options",
".",
"includeNumber",
"!=",
"null",
"?",
"options",
".",
"includeNumber",
":",
"false",
"if",
"(",
"includeNumber",
"===",
"true",
")",
"output",
"+=",
"value",
"var",
"j",
"=",
"value",
"%",
"10",
",",
"k",
"=",
"value",
"%",
"100",
"if",
"(",
"j",
"==",
"1",
"&&",
"k",
"!=",
"11",
")",
"output",
"+=",
"'st'",
"else",
"if",
"(",
"j",
"==",
"2",
"&&",
"k",
"!=",
"12",
")",
"output",
"+=",
"'nd'",
"else",
"if",
"(",
"j",
"==",
"3",
"&&",
"k",
"!=",
"13",
")",
"output",
"+=",
"'rd'",
"else",
"output",
"+=",
"'th'",
"return",
"output",
"}"
] |
42 => 'nd'
@params {Object} options
|
[
"42",
"=",
">",
"nd"
] |
d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c
|
https://github.com/freearhey/vue2-filters/blob/d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c/src/other/ordinal.js#L10-L24
|
12,654
|
freearhey/vue2-filters
|
src/string/truncate.js
|
truncate
|
function truncate (value, length) {
length = length || 15
if( !value || typeof value !== 'string' ) return ''
if( value.length <= length) return value
return value.substring(0, length) + '...'
}
|
javascript
|
function truncate (value, length) {
length = length || 15
if( !value || typeof value !== 'string' ) return ''
if( value.length <= length) return value
return value.substring(0, length) + '...'
}
|
[
"function",
"truncate",
"(",
"value",
",",
"length",
")",
"{",
"length",
"=",
"length",
"||",
"15",
"if",
"(",
"!",
"value",
"||",
"typeof",
"value",
"!==",
"'string'",
")",
"return",
"''",
"if",
"(",
"value",
".",
"length",
"<=",
"length",
")",
"return",
"value",
"return",
"value",
".",
"substring",
"(",
"0",
",",
"length",
")",
"+",
"'...'",
"}"
] |
Truncate at the given || default length
'lorem ipsum dolor' => 'lorem ipsum dol...'
|
[
"Truncate",
"at",
"the",
"given",
"||",
"default",
"length"
] |
d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c
|
https://github.com/freearhey/vue2-filters/blob/d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c/src/string/truncate.js#L7-L12
|
12,655
|
freearhey/vue2-filters
|
src/array/find.js
|
find
|
function find(arr, search)
{
var array = filterBy.apply(this, arguments);
array.splice(1);
return array;
}
|
javascript
|
function find(arr, search)
{
var array = filterBy.apply(this, arguments);
array.splice(1);
return array;
}
|
[
"function",
"find",
"(",
"arr",
",",
"search",
")",
"{",
"var",
"array",
"=",
"filterBy",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"array",
".",
"splice",
"(",
"1",
")",
";",
"return",
"array",
";",
"}"
] |
Get first matching element from a filtered array
@param {Array} arr
@param {String|Number} search
@returns {mixed}
|
[
"Get",
"first",
"matching",
"element",
"from",
"a",
"filtered",
"array"
] |
d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c
|
https://github.com/freearhey/vue2-filters/blob/d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c/src/array/find.js#L10-L15
|
12,656
|
freearhey/vue2-filters
|
src/other/pluralize.js
|
pluralize
|
function pluralize (value, word, options) {
options = options || {}
var output = ''
var includeNumber = options.includeNumber != null ? options.includeNumber : false
if(includeNumber === true) output += value + ' '
if(!value && value !== 0 || !word) return output
if(Array.isArray(word)) {
output += word[value - 1] || word[word.length - 1]
} else {
output += word + (value === 1 ? '' : 's')
}
return output
}
|
javascript
|
function pluralize (value, word, options) {
options = options || {}
var output = ''
var includeNumber = options.includeNumber != null ? options.includeNumber : false
if(includeNumber === true) output += value + ' '
if(!value && value !== 0 || !word) return output
if(Array.isArray(word)) {
output += word[value - 1] || word[word.length - 1]
} else {
output += word + (value === 1 ? '' : 's')
}
return output
}
|
[
"function",
"pluralize",
"(",
"value",
",",
"word",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"var",
"output",
"=",
"''",
"var",
"includeNumber",
"=",
"options",
".",
"includeNumber",
"!=",
"null",
"?",
"options",
".",
"includeNumber",
":",
"false",
"if",
"(",
"includeNumber",
"===",
"true",
")",
"output",
"+=",
"value",
"+",
"' '",
"if",
"(",
"!",
"value",
"&&",
"value",
"!==",
"0",
"||",
"!",
"word",
")",
"return",
"output",
"if",
"(",
"Array",
".",
"isArray",
"(",
"word",
")",
")",
"{",
"output",
"+=",
"word",
"[",
"value",
"-",
"1",
"]",
"||",
"word",
"[",
"word",
".",
"length",
"-",
"1",
"]",
"}",
"else",
"{",
"output",
"+=",
"word",
"+",
"(",
"value",
"===",
"1",
"?",
"''",
":",
"'s'",
")",
"}",
"return",
"output",
"}"
] |
'item' => 'items'
@param {String|Array} word
@param {Object} options
|
[
"item",
"=",
">",
"items"
] |
d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c
|
https://github.com/freearhey/vue2-filters/blob/d9ac0e2d3b7807e01f8aed86d6699e9f9954b67c/src/other/pluralize.js#L11-L24
|
12,657
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(name, source) {
var s = source;
var newEvents = s.events;
if (newEvents) {
newEvents.forEach(function(e) {
if (s[e]) {
this.eventMap[e] = s[e].bind(s);
}
}, this);
this.eventSources[name] = s;
this.eventSourceList.push(s);
}
}
|
javascript
|
function(name, source) {
var s = source;
var newEvents = s.events;
if (newEvents) {
newEvents.forEach(function(e) {
if (s[e]) {
this.eventMap[e] = s[e].bind(s);
}
}, this);
this.eventSources[name] = s;
this.eventSourceList.push(s);
}
}
|
[
"function",
"(",
"name",
",",
"source",
")",
"{",
"var",
"s",
"=",
"source",
";",
"var",
"newEvents",
"=",
"s",
".",
"events",
";",
"if",
"(",
"newEvents",
")",
"{",
"newEvents",
".",
"forEach",
"(",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"s",
"[",
"e",
"]",
")",
"{",
"this",
".",
"eventMap",
"[",
"e",
"]",
"=",
"s",
"[",
"e",
"]",
".",
"bind",
"(",
"s",
")",
";",
"}",
"}",
",",
"this",
")",
";",
"this",
".",
"eventSources",
"[",
"name",
"]",
"=",
"s",
";",
"this",
".",
"eventSourceList",
".",
"push",
"(",
"s",
")",
";",
"}",
"}"
] |
Add a new event source that will generate pointer events.
`inSource` must contain an array of event names named `events`, and
functions with the names specified in the `events` array.
@param {string} name A name for the event source
@param {Object} source A new source of platform events.
|
[
"Add",
"a",
"new",
"event",
"source",
"that",
"will",
"generate",
"pointer",
"events",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L605-L617
|
|
12,658
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(target, events) {
for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) {
this.addEvent(target, e);
}
}
|
javascript
|
function(target, events) {
for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) {
this.addEvent(target, e);
}
}
|
[
"function",
"(",
"target",
",",
"events",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"events",
".",
"length",
",",
"e",
";",
"(",
"i",
"<",
"l",
")",
"&&",
"(",
"e",
"=",
"events",
"[",
"i",
"]",
")",
";",
"i",
"++",
")",
"{",
"this",
".",
"addEvent",
"(",
"target",
",",
"e",
")",
";",
"}",
"}"
] |
set up event listeners
|
[
"set",
"up",
"event",
"listeners"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L721-L725
|
|
12,659
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(target, events) {
for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) {
this.removeEvent(target, e);
}
}
|
javascript
|
function(target, events) {
for (var i = 0, l = events.length, e; (i < l) && (e = events[i]); i++) {
this.removeEvent(target, e);
}
}
|
[
"function",
"(",
"target",
",",
"events",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"events",
".",
"length",
",",
"e",
";",
"(",
"i",
"<",
"l",
")",
"&&",
"(",
"e",
"=",
"events",
"[",
"i",
"]",
")",
";",
"i",
"++",
")",
"{",
"this",
".",
"removeEvent",
"(",
"target",
",",
"e",
")",
";",
"}",
"}"
] |
remove event listeners
|
[
"remove",
"event",
"listeners"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L727-L731
|
|
12,660
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(inEvent) {
var t = inEvent._target;
if (t) {
t.dispatchEvent(inEvent);
// clone the event for the gesture system to process
// clone after dispatch to pick up gesture prevention code
var clone = this.cloneEvent(inEvent);
clone.target = t;
this.fillGestureQueue(clone);
}
}
|
javascript
|
function(inEvent) {
var t = inEvent._target;
if (t) {
t.dispatchEvent(inEvent);
// clone the event for the gesture system to process
// clone after dispatch to pick up gesture prevention code
var clone = this.cloneEvent(inEvent);
clone.target = t;
this.fillGestureQueue(clone);
}
}
|
[
"function",
"(",
"inEvent",
")",
"{",
"var",
"t",
"=",
"inEvent",
".",
"_target",
";",
"if",
"(",
"t",
")",
"{",
"t",
".",
"dispatchEvent",
"(",
"inEvent",
")",
";",
"// clone the event for the gesture system to process",
"// clone after dispatch to pick up gesture prevention code",
"var",
"clone",
"=",
"this",
".",
"cloneEvent",
"(",
"inEvent",
")",
";",
"clone",
".",
"target",
"=",
"t",
";",
"this",
".",
"fillGestureQueue",
"(",
"clone",
")",
";",
"}",
"}"
] |
Dispatches the event to its target.
@param {Event} inEvent The event to be dispatched.
@return {Boolean} True if an event handler returns true, false otherwise.
|
[
"Dispatches",
"the",
"event",
"to",
"its",
"target",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L792-L802
|
|
12,661
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(inEvent) {
var lts = this.lastTouches;
var x = inEvent.clientX, y = inEvent.clientY;
for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {
// simulated mouse events will be swallowed near a primary touchend
var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);
if (dx <= DEDUP_DIST && dy <= DEDUP_DIST) {
return true;
}
}
}
|
javascript
|
function(inEvent) {
var lts = this.lastTouches;
var x = inEvent.clientX, y = inEvent.clientY;
for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {
// simulated mouse events will be swallowed near a primary touchend
var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);
if (dx <= DEDUP_DIST && dy <= DEDUP_DIST) {
return true;
}
}
}
|
[
"function",
"(",
"inEvent",
")",
"{",
"var",
"lts",
"=",
"this",
".",
"lastTouches",
";",
"var",
"x",
"=",
"inEvent",
".",
"clientX",
",",
"y",
"=",
"inEvent",
".",
"clientY",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"lts",
".",
"length",
",",
"t",
";",
"i",
"<",
"l",
"&&",
"(",
"t",
"=",
"lts",
"[",
"i",
"]",
")",
";",
"i",
"++",
")",
"{",
"// simulated mouse events will be swallowed near a primary touchend",
"var",
"dx",
"=",
"Math",
".",
"abs",
"(",
"x",
"-",
"t",
".",
"x",
")",
",",
"dy",
"=",
"Math",
".",
"abs",
"(",
"y",
"-",
"t",
".",
"y",
")",
";",
"if",
"(",
"dx",
"<=",
"DEDUP_DIST",
"&&",
"dy",
"<=",
"DEDUP_DIST",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}"
] |
collide with the global mouse listener
|
[
"collide",
"with",
"the",
"global",
"mouse",
"listener"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L995-L1005
|
|
12,662
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(touch) {
var dx = Math.abs(x - touch.x), dy = Math.abs(y - touch.y);
return (dx <= DEDUP_DIST && dy <= DEDUP_DIST);
}
|
javascript
|
function(touch) {
var dx = Math.abs(x - touch.x), dy = Math.abs(y - touch.y);
return (dx <= DEDUP_DIST && dy <= DEDUP_DIST);
}
|
[
"function",
"(",
"touch",
")",
"{",
"var",
"dx",
"=",
"Math",
".",
"abs",
"(",
"x",
"-",
"touch",
".",
"x",
")",
",",
"dy",
"=",
"Math",
".",
"abs",
"(",
"y",
"-",
"touch",
".",
"y",
")",
";",
"return",
"(",
"dx",
"<=",
"DEDUP_DIST",
"&&",
"dy",
"<=",
"DEDUP_DIST",
")",
";",
"}"
] |
check if a click is within DEDUP_DIST px radius of the touchstart
|
[
"check",
"if",
"a",
"click",
"is",
"within",
"DEDUP_DIST",
"px",
"radius",
"of",
"the",
"touchstart"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L1381-L1384
|
|
12,663
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
findScope
|
function findScope(model, prop) {
while (model[parentScopeName] &&
!Object.prototype.hasOwnProperty.call(model, prop)) {
model = model[parentScopeName];
}
return model;
}
|
javascript
|
function findScope(model, prop) {
while (model[parentScopeName] &&
!Object.prototype.hasOwnProperty.call(model, prop)) {
model = model[parentScopeName];
}
return model;
}
|
[
"function",
"findScope",
"(",
"model",
",",
"prop",
")",
"{",
"while",
"(",
"model",
"[",
"parentScopeName",
"]",
"&&",
"!",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"model",
",",
"prop",
")",
")",
"{",
"model",
"=",
"model",
"[",
"parentScopeName",
"]",
";",
"}",
"return",
"model",
";",
"}"
] |
Single ident paths must bind directly to the appropriate scope object. I.e. Pushed values in two-bindings need to be assigned to the actual model object.
|
[
"Single",
"ident",
"paths",
"must",
"bind",
"directly",
"to",
"the",
"appropriate",
"scope",
"object",
".",
"I",
".",
"e",
".",
"Pushed",
"values",
"in",
"two",
"-",
"bindings",
"need",
"to",
"be",
"assigned",
"to",
"the",
"actual",
"model",
"object",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L3698-L3705
|
12,664
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(value) {
var parts = [];
for (var key in value) {
parts.push(convertStylePropertyName(key) + ': ' + value[key]);
}
return parts.join('; ');
}
|
javascript
|
function(value) {
var parts = [];
for (var key in value) {
parts.push(convertStylePropertyName(key) + ': ' + value[key]);
}
return parts.join('; ');
}
|
[
"function",
"(",
"value",
")",
"{",
"var",
"parts",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"value",
")",
"{",
"parts",
".",
"push",
"(",
"convertStylePropertyName",
"(",
"key",
")",
"+",
"': '",
"+",
"value",
"[",
"key",
"]",
")",
";",
"}",
"return",
"parts",
".",
"join",
"(",
"'; '",
")",
";",
"}"
] |
"built-in" filters
|
[
"built",
"-",
"in",
"filters"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L3728-L3734
|
|
12,665
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(template) {
var indexIdent = template.polymerExpressionIndexIdent_;
if (!indexIdent)
return;
return function(templateInstance, index) {
templateInstance.model[indexIdent] = index;
};
}
|
javascript
|
function(template) {
var indexIdent = template.polymerExpressionIndexIdent_;
if (!indexIdent)
return;
return function(templateInstance, index) {
templateInstance.model[indexIdent] = index;
};
}
|
[
"function",
"(",
"template",
")",
"{",
"var",
"indexIdent",
"=",
"template",
".",
"polymerExpressionIndexIdent_",
";",
"if",
"(",
"!",
"indexIdent",
")",
"return",
";",
"return",
"function",
"(",
"templateInstance",
",",
"index",
")",
"{",
"templateInstance",
".",
"model",
"[",
"indexIdent",
"]",
"=",
"index",
";",
"}",
";",
"}"
] |
binding delegate API
|
[
"binding",
"delegate",
"API"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L3746-L3754
|
|
12,666
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
jURL
|
function jURL(url, base /* , encoding */) {
if (base !== undefined && !(base instanceof jURL))
base = new jURL(String(base));
this._url = url;
clear.call(this);
var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
// encoding = encoding || 'utf-8'
parse.call(this, input, null, base);
}
|
javascript
|
function jURL(url, base /* , encoding */) {
if (base !== undefined && !(base instanceof jURL))
base = new jURL(String(base));
this._url = url;
clear.call(this);
var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
// encoding = encoding || 'utf-8'
parse.call(this, input, null, base);
}
|
[
"function",
"jURL",
"(",
"url",
",",
"base",
"/* , encoding */",
")",
"{",
"if",
"(",
"base",
"!==",
"undefined",
"&&",
"!",
"(",
"base",
"instanceof",
"jURL",
")",
")",
"base",
"=",
"new",
"jURL",
"(",
"String",
"(",
"base",
")",
")",
";",
"this",
".",
"_url",
"=",
"url",
";",
"clear",
".",
"call",
"(",
"this",
")",
";",
"var",
"input",
"=",
"url",
".",
"replace",
"(",
"/",
"^[ \\t\\r\\n\\f]+|[ \\t\\r\\n\\f]+$",
"/",
"g",
",",
"''",
")",
";",
"// encoding = encoding || 'utf-8'",
"parse",
".",
"call",
"(",
"this",
",",
"input",
",",
"null",
",",
"base",
")",
";",
"}"
] |
Does not process domain names or IP addresses. Does not handle encoding for the query parameter.
|
[
"Does",
"not",
"process",
"domain",
"names",
"or",
"IP",
"addresses",
".",
"Does",
"not",
"handle",
"encoding",
"for",
"the",
"query",
"parameter",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L7961-L7972
|
12,667
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function() {
// only flush if the page is visibile
if (document.visibilityState === 'hidden') {
if (scope.flushPoll) {
clearInterval(scope.flushPoll);
}
} else {
scope.flushPoll = setInterval(flush, FLUSH_POLL_INTERVAL);
}
}
|
javascript
|
function() {
// only flush if the page is visibile
if (document.visibilityState === 'hidden') {
if (scope.flushPoll) {
clearInterval(scope.flushPoll);
}
} else {
scope.flushPoll = setInterval(flush, FLUSH_POLL_INTERVAL);
}
}
|
[
"function",
"(",
")",
"{",
"// only flush if the page is visibile",
"if",
"(",
"document",
".",
"visibilityState",
"===",
"'hidden'",
")",
"{",
"if",
"(",
"scope",
".",
"flushPoll",
")",
"{",
"clearInterval",
"(",
"scope",
".",
"flushPoll",
")",
";",
"}",
"}",
"else",
"{",
"scope",
".",
"flushPoll",
"=",
"setInterval",
"(",
"flush",
",",
"FLUSH_POLL_INTERVAL",
")",
";",
"}",
"}"
] |
watch document visiblity to toggle dirty-checking
|
[
"watch",
"document",
"visiblity",
"to",
"toggle",
"dirty",
"-",
"checking"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8191-L8200
|
|
12,668
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
Loader
|
function Loader(regex) {
this.cache = Object.create(null);
this.map = Object.create(null);
this.requests = 0;
this.regex = regex;
}
|
javascript
|
function Loader(regex) {
this.cache = Object.create(null);
this.map = Object.create(null);
this.requests = 0;
this.regex = regex;
}
|
[
"function",
"Loader",
"(",
"regex",
")",
"{",
"this",
".",
"cache",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"this",
".",
"map",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"this",
".",
"requests",
"=",
"0",
";",
"this",
".",
"regex",
"=",
"regex",
";",
"}"
] |
Generic url loader
|
[
"Generic",
"url",
"loader"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8367-L8372
|
12,669
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(text, root, callback) {
var matches = this.extractUrls(text, root);
// every call to process returns all the text this loader has ever received
var done = callback.bind(null, this.map);
this.fetch(matches, done);
}
|
javascript
|
function(text, root, callback) {
var matches = this.extractUrls(text, root);
// every call to process returns all the text this loader has ever received
var done = callback.bind(null, this.map);
this.fetch(matches, done);
}
|
[
"function",
"(",
"text",
",",
"root",
",",
"callback",
")",
"{",
"var",
"matches",
"=",
"this",
".",
"extractUrls",
"(",
"text",
",",
"root",
")",
";",
"// every call to process returns all the text this loader has ever received",
"var",
"done",
"=",
"callback",
".",
"bind",
"(",
"null",
",",
"this",
".",
"map",
")",
";",
"this",
".",
"fetch",
"(",
"matches",
",",
"done",
")",
";",
"}"
] |
take a text blob, a root url, and a callback and load all the urls found within the text returns a map of absolute url to text
|
[
"take",
"a",
"text",
"blob",
"a",
"root",
"url",
"and",
"a",
"callback",
"and",
"load",
"all",
"the",
"urls",
"found",
"within",
"the",
"text",
"returns",
"a",
"map",
"of",
"absolute",
"url",
"to",
"text"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8388-L8394
|
|
12,670
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(matches, callback) {
var inflight = matches.length;
// return early if there is no fetching to be done
if (!inflight) {
return callback();
}
// wait for all subrequests to return
var done = function() {
if (--inflight === 0) {
callback();
}
};
// start fetching all subrequests
var m, req, url;
for (var i = 0; i < inflight; i++) {
m = matches[i];
url = m.url;
req = this.cache[url];
// if this url has already been requested, skip requesting it again
if (!req) {
req = this.xhr(url);
req.match = m;
this.cache[url] = req;
}
// wait for the request to process its subrequests
req.wait(done);
}
}
|
javascript
|
function(matches, callback) {
var inflight = matches.length;
// return early if there is no fetching to be done
if (!inflight) {
return callback();
}
// wait for all subrequests to return
var done = function() {
if (--inflight === 0) {
callback();
}
};
// start fetching all subrequests
var m, req, url;
for (var i = 0; i < inflight; i++) {
m = matches[i];
url = m.url;
req = this.cache[url];
// if this url has already been requested, skip requesting it again
if (!req) {
req = this.xhr(url);
req.match = m;
this.cache[url] = req;
}
// wait for the request to process its subrequests
req.wait(done);
}
}
|
[
"function",
"(",
"matches",
",",
"callback",
")",
"{",
"var",
"inflight",
"=",
"matches",
".",
"length",
";",
"// return early if there is no fetching to be done",
"if",
"(",
"!",
"inflight",
")",
"{",
"return",
"callback",
"(",
")",
";",
"}",
"// wait for all subrequests to return",
"var",
"done",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"--",
"inflight",
"===",
"0",
")",
"{",
"callback",
"(",
")",
";",
"}",
"}",
";",
"// start fetching all subrequests",
"var",
"m",
",",
"req",
",",
"url",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"inflight",
";",
"i",
"++",
")",
"{",
"m",
"=",
"matches",
"[",
"i",
"]",
";",
"url",
"=",
"m",
".",
"url",
";",
"req",
"=",
"this",
".",
"cache",
"[",
"url",
"]",
";",
"// if this url has already been requested, skip requesting it again",
"if",
"(",
"!",
"req",
")",
"{",
"req",
"=",
"this",
".",
"xhr",
"(",
"url",
")",
";",
"req",
".",
"match",
"=",
"m",
";",
"this",
".",
"cache",
"[",
"url",
"]",
"=",
"req",
";",
"}",
"// wait for the request to process its subrequests",
"req",
".",
"wait",
"(",
"done",
")",
";",
"}",
"}"
] |
build a mapping of url -> text from matches
|
[
"build",
"a",
"mapping",
"of",
"url",
"-",
">",
"text",
"from",
"matches"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8396-L8426
|
|
12,671
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(style, url, callback) {
var text = style.textContent;
var done = function(text) {
style.textContent = text;
callback(style);
};
this.resolve(text, url, done);
}
|
javascript
|
function(style, url, callback) {
var text = style.textContent;
var done = function(text) {
style.textContent = text;
callback(style);
};
this.resolve(text, url, done);
}
|
[
"function",
"(",
"style",
",",
"url",
",",
"callback",
")",
"{",
"var",
"text",
"=",
"style",
".",
"textContent",
";",
"var",
"done",
"=",
"function",
"(",
"text",
")",
"{",
"style",
".",
"textContent",
"=",
"text",
";",
"callback",
"(",
"style",
")",
";",
"}",
";",
"this",
".",
"resolve",
"(",
"text",
",",
"url",
",",
"done",
")",
";",
"}"
] |
resolve the textContent of a style node
|
[
"resolve",
"the",
"textContent",
"of",
"a",
"style",
"node"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8487-L8494
|
|
12,672
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(text, base, map) {
var matches = this.loader.extractUrls(text, base);
var match, url, intermediate;
for (var i = 0; i < matches.length; i++) {
match = matches[i];
url = match.url;
// resolve any css text to be relative to the importer, keep absolute url
intermediate = urlResolver.resolveCssText(map[url], url, true);
// flatten intermediate @imports
intermediate = this.flatten(intermediate, base, map);
text = text.replace(match.matched, intermediate);
}
return text;
}
|
javascript
|
function(text, base, map) {
var matches = this.loader.extractUrls(text, base);
var match, url, intermediate;
for (var i = 0; i < matches.length; i++) {
match = matches[i];
url = match.url;
// resolve any css text to be relative to the importer, keep absolute url
intermediate = urlResolver.resolveCssText(map[url], url, true);
// flatten intermediate @imports
intermediate = this.flatten(intermediate, base, map);
text = text.replace(match.matched, intermediate);
}
return text;
}
|
[
"function",
"(",
"text",
",",
"base",
",",
"map",
")",
"{",
"var",
"matches",
"=",
"this",
".",
"loader",
".",
"extractUrls",
"(",
"text",
",",
"base",
")",
";",
"var",
"match",
",",
"url",
",",
"intermediate",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"matches",
".",
"length",
";",
"i",
"++",
")",
"{",
"match",
"=",
"matches",
"[",
"i",
"]",
";",
"url",
"=",
"match",
".",
"url",
";",
"// resolve any css text to be relative to the importer, keep absolute url",
"intermediate",
"=",
"urlResolver",
".",
"resolveCssText",
"(",
"map",
"[",
"url",
"]",
",",
"url",
",",
"true",
")",
";",
"// flatten intermediate @imports",
"intermediate",
"=",
"this",
".",
"flatten",
"(",
"intermediate",
",",
"base",
",",
"map",
")",
";",
"text",
"=",
"text",
".",
"replace",
"(",
"match",
".",
"matched",
",",
"intermediate",
")",
";",
"}",
"return",
"text",
";",
"}"
] |
flatten all the @imports to text
|
[
"flatten",
"all",
"the"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8496-L8509
|
|
12,673
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
extend
|
function extend(prototype, api) {
if (prototype && api) {
// use only own properties of 'api'
Object.getOwnPropertyNames(api).forEach(function(n) {
// acquire property descriptor
var pd = Object.getOwnPropertyDescriptor(api, n);
if (pd) {
// clone property via descriptor
Object.defineProperty(prototype, n, pd);
// cache name-of-method for 'super' engine
if (typeof pd.value == 'function') {
// hint the 'super' engine
pd.value.nom = n;
}
}
});
}
return prototype;
}
|
javascript
|
function extend(prototype, api) {
if (prototype && api) {
// use only own properties of 'api'
Object.getOwnPropertyNames(api).forEach(function(n) {
// acquire property descriptor
var pd = Object.getOwnPropertyDescriptor(api, n);
if (pd) {
// clone property via descriptor
Object.defineProperty(prototype, n, pd);
// cache name-of-method for 'super' engine
if (typeof pd.value == 'function') {
// hint the 'super' engine
pd.value.nom = n;
}
}
});
}
return prototype;
}
|
[
"function",
"extend",
"(",
"prototype",
",",
"api",
")",
"{",
"if",
"(",
"prototype",
"&&",
"api",
")",
"{",
"// use only own properties of 'api'",
"Object",
".",
"getOwnPropertyNames",
"(",
"api",
")",
".",
"forEach",
"(",
"function",
"(",
"n",
")",
"{",
"// acquire property descriptor",
"var",
"pd",
"=",
"Object",
".",
"getOwnPropertyDescriptor",
"(",
"api",
",",
"n",
")",
";",
"if",
"(",
"pd",
")",
"{",
"// clone property via descriptor",
"Object",
".",
"defineProperty",
"(",
"prototype",
",",
"n",
",",
"pd",
")",
";",
"// cache name-of-method for 'super' engine",
"if",
"(",
"typeof",
"pd",
".",
"value",
"==",
"'function'",
")",
"{",
"// hint the 'super' engine",
"pd",
".",
"value",
".",
"nom",
"=",
"n",
";",
"}",
"}",
"}",
")",
";",
"}",
"return",
"prototype",
";",
"}"
] |
copy own properties from 'api' to 'prototype, with name hinting for 'super'
|
[
"copy",
"own",
"properties",
"from",
"api",
"to",
"prototype",
"with",
"name",
"hinting",
"for",
"super"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8535-L8553
|
12,674
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
copyProperty
|
function copyProperty(inName, inSource, inTarget) {
var pd = getPropertyDescriptor(inSource, inName);
Object.defineProperty(inTarget, inName, pd);
}
|
javascript
|
function copyProperty(inName, inSource, inTarget) {
var pd = getPropertyDescriptor(inSource, inName);
Object.defineProperty(inTarget, inName, pd);
}
|
[
"function",
"copyProperty",
"(",
"inName",
",",
"inSource",
",",
"inTarget",
")",
"{",
"var",
"pd",
"=",
"getPropertyDescriptor",
"(",
"inSource",
",",
"inName",
")",
";",
"Object",
".",
"defineProperty",
"(",
"inTarget",
",",
"inName",
",",
"pd",
")",
";",
"}"
] |
copy property inName from inSource object to inTarget object
|
[
"copy",
"property",
"inName",
"from",
"inSource",
"object",
"to",
"inTarget",
"object"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8574-L8577
|
12,675
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
getPropertyDescriptor
|
function getPropertyDescriptor(inObject, inName) {
if (inObject) {
var pd = Object.getOwnPropertyDescriptor(inObject, inName);
return pd || getPropertyDescriptor(Object.getPrototypeOf(inObject), inName);
}
}
|
javascript
|
function getPropertyDescriptor(inObject, inName) {
if (inObject) {
var pd = Object.getOwnPropertyDescriptor(inObject, inName);
return pd || getPropertyDescriptor(Object.getPrototypeOf(inObject), inName);
}
}
|
[
"function",
"getPropertyDescriptor",
"(",
"inObject",
",",
"inName",
")",
"{",
"if",
"(",
"inObject",
")",
"{",
"var",
"pd",
"=",
"Object",
".",
"getOwnPropertyDescriptor",
"(",
"inObject",
",",
"inName",
")",
";",
"return",
"pd",
"||",
"getPropertyDescriptor",
"(",
"Object",
".",
"getPrototypeOf",
"(",
"inObject",
")",
",",
"inName",
")",
";",
"}",
"}"
] |
get property descriptor for inName on inObject, even if inName exists on some link in inObject's prototype chain
|
[
"get",
"property",
"descriptor",
"for",
"inName",
"on",
"inObject",
"even",
"if",
"inName",
"exists",
"on",
"some",
"link",
"in",
"inObject",
"s",
"prototype",
"chain"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8581-L8586
|
12,676
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
$super
|
function $super(arrayOfArgs) {
// since we are thunking a method call, performance is important here:
// memoize all lookups, once memoized the fast path calls no other
// functions
//
// find the caller (cannot be `strict` because of 'caller')
var caller = $super.caller;
// memoized 'name of method'
var nom = caller.nom;
// memoized next implementation prototype
var _super = caller._super;
if (!_super) {
if (!nom) {
nom = caller.nom = nameInThis.call(this, caller);
}
if (!nom) {
console.warn('called super() on a method not installed declaratively (has no .nom property)');
}
// super prototype is either cached or we have to find it
// by searching __proto__ (at the 'top')
// invariant: because we cache _super on fn below, we never reach
// here from inside a series of calls to super(), so it's ok to
// start searching from the prototype of 'this' (at the 'top')
// we must never memoize a null super for this reason
_super = memoizeSuper(caller, nom, getPrototypeOf(this));
}
// our super function
var fn = _super[nom];
if (fn) {
// memoize information so 'fn' can call 'super'
if (!fn._super) {
// must not memoize null, or we lose our invariant above
memoizeSuper(fn, nom, _super);
}
// invoke the inherited method
// if 'fn' is not function valued, this will throw
return fn.apply(this, arrayOfArgs || []);
}
}
|
javascript
|
function $super(arrayOfArgs) {
// since we are thunking a method call, performance is important here:
// memoize all lookups, once memoized the fast path calls no other
// functions
//
// find the caller (cannot be `strict` because of 'caller')
var caller = $super.caller;
// memoized 'name of method'
var nom = caller.nom;
// memoized next implementation prototype
var _super = caller._super;
if (!_super) {
if (!nom) {
nom = caller.nom = nameInThis.call(this, caller);
}
if (!nom) {
console.warn('called super() on a method not installed declaratively (has no .nom property)');
}
// super prototype is either cached or we have to find it
// by searching __proto__ (at the 'top')
// invariant: because we cache _super on fn below, we never reach
// here from inside a series of calls to super(), so it's ok to
// start searching from the prototype of 'this' (at the 'top')
// we must never memoize a null super for this reason
_super = memoizeSuper(caller, nom, getPrototypeOf(this));
}
// our super function
var fn = _super[nom];
if (fn) {
// memoize information so 'fn' can call 'super'
if (!fn._super) {
// must not memoize null, or we lose our invariant above
memoizeSuper(fn, nom, _super);
}
// invoke the inherited method
// if 'fn' is not function valued, this will throw
return fn.apply(this, arrayOfArgs || []);
}
}
|
[
"function",
"$super",
"(",
"arrayOfArgs",
")",
"{",
"// since we are thunking a method call, performance is important here: \r",
"// memoize all lookups, once memoized the fast path calls no other \r",
"// functions\r",
"//\r",
"// find the caller (cannot be `strict` because of 'caller')\r",
"var",
"caller",
"=",
"$super",
".",
"caller",
";",
"// memoized 'name of method' \r",
"var",
"nom",
"=",
"caller",
".",
"nom",
";",
"// memoized next implementation prototype\r",
"var",
"_super",
"=",
"caller",
".",
"_super",
";",
"if",
"(",
"!",
"_super",
")",
"{",
"if",
"(",
"!",
"nom",
")",
"{",
"nom",
"=",
"caller",
".",
"nom",
"=",
"nameInThis",
".",
"call",
"(",
"this",
",",
"caller",
")",
";",
"}",
"if",
"(",
"!",
"nom",
")",
"{",
"console",
".",
"warn",
"(",
"'called super() on a method not installed declaratively (has no .nom property)'",
")",
";",
"}",
"// super prototype is either cached or we have to find it\r",
"// by searching __proto__ (at the 'top')\r",
"// invariant: because we cache _super on fn below, we never reach \r",
"// here from inside a series of calls to super(), so it's ok to \r",
"// start searching from the prototype of 'this' (at the 'top')\r",
"// we must never memoize a null super for this reason\r",
"_super",
"=",
"memoizeSuper",
"(",
"caller",
",",
"nom",
",",
"getPrototypeOf",
"(",
"this",
")",
")",
";",
"}",
"// our super function\r",
"var",
"fn",
"=",
"_super",
"[",
"nom",
"]",
";",
"if",
"(",
"fn",
")",
"{",
"// memoize information so 'fn' can call 'super'\r",
"if",
"(",
"!",
"fn",
".",
"_super",
")",
"{",
"// must not memoize null, or we lose our invariant above\r",
"memoizeSuper",
"(",
"fn",
",",
"nom",
",",
"_super",
")",
";",
"}",
"// invoke the inherited method\r",
"// if 'fn' is not function valued, this will throw\r",
"return",
"fn",
".",
"apply",
"(",
"this",
",",
"arrayOfArgs",
"||",
"[",
"]",
")",
";",
"}",
"}"
] |
will not work if function objects are not unique, for example, when using mixins. The memoization strategy assumes each function exists on only one prototype chain i.e. we use the function object for memoizing) perhaps we can bookkeep on the prototype itself instead
|
[
"will",
"not",
"work",
"if",
"function",
"objects",
"are",
"not",
"unique",
"for",
"example",
"when",
"using",
"mixins",
".",
"The",
"memoization",
"strategy",
"assumes",
"each",
"function",
"exists",
"on",
"only",
"one",
"prototype",
"chain",
"i",
".",
"e",
".",
"we",
"use",
"the",
"function",
"object",
"for",
"memoizing",
")",
"perhaps",
"we",
"can",
"bookkeep",
"on",
"the",
"prototype",
"itself",
"instead"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L8760-L8798
|
12,677
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(anew, old, className) {
if (old) {
old.classList.remove(className);
}
if (anew) {
anew.classList.add(className);
}
}
|
javascript
|
function(anew, old, className) {
if (old) {
old.classList.remove(className);
}
if (anew) {
anew.classList.add(className);
}
}
|
[
"function",
"(",
"anew",
",",
"old",
",",
"className",
")",
"{",
"if",
"(",
"old",
")",
"{",
"old",
".",
"classList",
".",
"remove",
"(",
"className",
")",
";",
"}",
"if",
"(",
"anew",
")",
"{",
"anew",
".",
"classList",
".",
"add",
"(",
"className",
")",
";",
"}",
"}"
] |
Remove class from old, add class to anew, if they exist.
@param classFollows
@param anew A node.
@param old A node
@param className
|
[
"Remove",
"class",
"from",
"old",
"add",
"class",
"to",
"anew",
"if",
"they",
"exist",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9055-L9062
|
|
12,678
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function() {
var events = this.eventDelegates;
log.events && (Object.keys(events).length > 0) && console.log('[%s] addHostListeners:', this.localName, events);
// NOTE: host events look like bindings but really are not;
// (1) we don't want the attribute to be set and (2) we want to support
// multiple event listeners ('host' and 'instance') and Node.bind
// by default supports 1 thing being bound.
for (var type in events) {
var methodName = events[type];
PolymerGestures.addEventListener(this, type, this.element.getEventHandler(this, this, methodName));
}
}
|
javascript
|
function() {
var events = this.eventDelegates;
log.events && (Object.keys(events).length > 0) && console.log('[%s] addHostListeners:', this.localName, events);
// NOTE: host events look like bindings but really are not;
// (1) we don't want the attribute to be set and (2) we want to support
// multiple event listeners ('host' and 'instance') and Node.bind
// by default supports 1 thing being bound.
for (var type in events) {
var methodName = events[type];
PolymerGestures.addEventListener(this, type, this.element.getEventHandler(this, this, methodName));
}
}
|
[
"function",
"(",
")",
"{",
"var",
"events",
"=",
"this",
".",
"eventDelegates",
";",
"log",
".",
"events",
"&&",
"(",
"Object",
".",
"keys",
"(",
"events",
")",
".",
"length",
">",
"0",
")",
"&&",
"console",
".",
"log",
"(",
"'[%s] addHostListeners:'",
",",
"this",
".",
"localName",
",",
"events",
")",
";",
"// NOTE: host events look like bindings but really are not;",
"// (1) we don't want the attribute to be set and (2) we want to support",
"// multiple event listeners ('host' and 'instance') and Node.bind",
"// by default supports 1 thing being bound.",
"for",
"(",
"var",
"type",
"in",
"events",
")",
"{",
"var",
"methodName",
"=",
"events",
"[",
"type",
"]",
";",
"PolymerGestures",
".",
"addEventListener",
"(",
"this",
",",
"type",
",",
"this",
".",
"element",
".",
"getEventHandler",
"(",
"this",
",",
"this",
",",
"methodName",
")",
")",
";",
"}",
"}"
] |
event listeners on host
|
[
"event",
"listeners",
"on",
"host"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9113-L9124
|
|
12,679
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(obj, method, args) {
if (obj) {
log.events && console.group('[%s] dispatch [%s]', obj.localName, method);
var fn = typeof method === 'function' ? method : obj[method];
if (fn) {
fn[args ? 'apply' : 'call'](obj, args);
}
log.events && console.groupEnd();
// NOTE: dirty check right after calling method to ensure
// changes apply quickly; in a very complicated app using high
// frequency events, this can be a perf concern; in this case,
// imperative handlers can be used to avoid flushing.
Polymer.flush();
}
}
|
javascript
|
function(obj, method, args) {
if (obj) {
log.events && console.group('[%s] dispatch [%s]', obj.localName, method);
var fn = typeof method === 'function' ? method : obj[method];
if (fn) {
fn[args ? 'apply' : 'call'](obj, args);
}
log.events && console.groupEnd();
// NOTE: dirty check right after calling method to ensure
// changes apply quickly; in a very complicated app using high
// frequency events, this can be a perf concern; in this case,
// imperative handlers can be used to avoid flushing.
Polymer.flush();
}
}
|
[
"function",
"(",
"obj",
",",
"method",
",",
"args",
")",
"{",
"if",
"(",
"obj",
")",
"{",
"log",
".",
"events",
"&&",
"console",
".",
"group",
"(",
"'[%s] dispatch [%s]'",
",",
"obj",
".",
"localName",
",",
"method",
")",
";",
"var",
"fn",
"=",
"typeof",
"method",
"===",
"'function'",
"?",
"method",
":",
"obj",
"[",
"method",
"]",
";",
"if",
"(",
"fn",
")",
"{",
"fn",
"[",
"args",
"?",
"'apply'",
":",
"'call'",
"]",
"(",
"obj",
",",
"args",
")",
";",
"}",
"log",
".",
"events",
"&&",
"console",
".",
"groupEnd",
"(",
")",
";",
"// NOTE: dirty check right after calling method to ensure ",
"// changes apply quickly; in a very complicated app using high ",
"// frequency events, this can be a perf concern; in this case,",
"// imperative handlers can be used to avoid flushing.",
"Polymer",
".",
"flush",
"(",
")",
";",
"}",
"}"
] |
call 'method' or function method on 'obj' with 'args', if the method exists
|
[
"call",
"method",
"or",
"function",
"method",
"on",
"obj",
"with",
"args",
"if",
"the",
"method",
"exists"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9126-L9140
|
|
12,680
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function() {
// if we have no publish lookup table, we have no attributes to take
// TODO(sjmiles): ad hoc
if (this._publishLC) {
for (var i=0, a$=this.attributes, l=a$.length, a; (a=a$[i]) && i<l; i++) {
this.attributeToProperty(a.name, a.value);
}
}
}
|
javascript
|
function() {
// if we have no publish lookup table, we have no attributes to take
// TODO(sjmiles): ad hoc
if (this._publishLC) {
for (var i=0, a$=this.attributes, l=a$.length, a; (a=a$[i]) && i<l; i++) {
this.attributeToProperty(a.name, a.value);
}
}
}
|
[
"function",
"(",
")",
"{",
"// if we have no publish lookup table, we have no attributes to take\r",
"// TODO(sjmiles): ad hoc\r",
"if",
"(",
"this",
".",
"_publishLC",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"a$",
"=",
"this",
".",
"attributes",
",",
"l",
"=",
"a$",
".",
"length",
",",
"a",
";",
"(",
"a",
"=",
"a$",
"[",
"i",
"]",
")",
"&&",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"this",
".",
"attributeToProperty",
"(",
"a",
".",
"name",
",",
"a",
".",
"value",
")",
";",
"}",
"}",
"}"
] |
for each attribute on this, deserialize value to property as needed
|
[
"for",
"each",
"attribute",
"on",
"this",
"deserialize",
"value",
"to",
"property",
"as",
"needed"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9204-L9212
|
|
12,681
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(name, value) {
// try to match this attribute to a property (attributes are
// all lower-case, so this is case-insensitive search)
var name = this.propertyForAttribute(name);
if (name) {
// filter out 'mustached' values, these are to be
// replaced with bound-data and are not yet values
// themselves
if (value && value.search(scope.bindPattern) >= 0) {
return;
}
// get original value
var currentValue = this[name];
// deserialize Boolean or Number values from attribute
var value = this.deserializeValue(value, currentValue);
// only act if the value has changed
if (value !== currentValue) {
// install new value (has side-effects)
this[name] = value;
}
}
}
|
javascript
|
function(name, value) {
// try to match this attribute to a property (attributes are
// all lower-case, so this is case-insensitive search)
var name = this.propertyForAttribute(name);
if (name) {
// filter out 'mustached' values, these are to be
// replaced with bound-data and are not yet values
// themselves
if (value && value.search(scope.bindPattern) >= 0) {
return;
}
// get original value
var currentValue = this[name];
// deserialize Boolean or Number values from attribute
var value = this.deserializeValue(value, currentValue);
// only act if the value has changed
if (value !== currentValue) {
// install new value (has side-effects)
this[name] = value;
}
}
}
|
[
"function",
"(",
"name",
",",
"value",
")",
"{",
"// try to match this attribute to a property (attributes are\r",
"// all lower-case, so this is case-insensitive search)\r",
"var",
"name",
"=",
"this",
".",
"propertyForAttribute",
"(",
"name",
")",
";",
"if",
"(",
"name",
")",
"{",
"// filter out 'mustached' values, these are to be\r",
"// replaced with bound-data and are not yet values\r",
"// themselves\r",
"if",
"(",
"value",
"&&",
"value",
".",
"search",
"(",
"scope",
".",
"bindPattern",
")",
">=",
"0",
")",
"{",
"return",
";",
"}",
"// get original value\r",
"var",
"currentValue",
"=",
"this",
"[",
"name",
"]",
";",
"// deserialize Boolean or Number values from attribute\r",
"var",
"value",
"=",
"this",
".",
"deserializeValue",
"(",
"value",
",",
"currentValue",
")",
";",
"// only act if the value has changed\r",
"if",
"(",
"value",
"!==",
"currentValue",
")",
"{",
"// install new value (has side-effects)\r",
"this",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"}",
"}"
] |
if attribute 'name' is mapped to a property, deserialize 'value' into that property
|
[
"if",
"attribute",
"name",
"is",
"mapped",
"to",
"a",
"property",
"deserialize",
"value",
"into",
"that",
"property"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9215-L9236
|
|
12,682
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(value, inferredType) {
if (inferredType === 'boolean') {
return value ? '' : undefined;
} else if (inferredType !== 'object' && inferredType !== 'function'
&& value !== undefined) {
return value;
}
}
|
javascript
|
function(value, inferredType) {
if (inferredType === 'boolean') {
return value ? '' : undefined;
} else if (inferredType !== 'object' && inferredType !== 'function'
&& value !== undefined) {
return value;
}
}
|
[
"function",
"(",
"value",
",",
"inferredType",
")",
"{",
"if",
"(",
"inferredType",
"===",
"'boolean'",
")",
"{",
"return",
"value",
"?",
"''",
":",
"undefined",
";",
"}",
"else",
"if",
"(",
"inferredType",
"!==",
"'object'",
"&&",
"inferredType",
"!==",
"'function'",
"&&",
"value",
"!==",
"undefined",
")",
"{",
"return",
"value",
";",
"}",
"}"
] |
convert to a string value based on the type of `inferredType`
|
[
"convert",
"to",
"a",
"string",
"value",
"based",
"on",
"the",
"type",
"of",
"inferredType"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9247-L9254
|
|
12,683
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(name) {
var inferredType = typeof this[name];
// try to intelligently serialize property value
var serializedValue = this.serializeValue(this[name], inferredType);
// boolean properties must reflect as boolean attributes
if (serializedValue !== undefined) {
this.setAttribute(name, serializedValue);
// TODO(sorvell): we should remove attr for all properties
// that have undefined serialization; however, we will need to
// refine the attr reflection system to achieve this; pica, for example,
// relies on having inferredType object properties not removed as
// attrs.
} else if (inferredType === 'boolean') {
this.removeAttribute(name);
}
}
|
javascript
|
function(name) {
var inferredType = typeof this[name];
// try to intelligently serialize property value
var serializedValue = this.serializeValue(this[name], inferredType);
// boolean properties must reflect as boolean attributes
if (serializedValue !== undefined) {
this.setAttribute(name, serializedValue);
// TODO(sorvell): we should remove attr for all properties
// that have undefined serialization; however, we will need to
// refine the attr reflection system to achieve this; pica, for example,
// relies on having inferredType object properties not removed as
// attrs.
} else if (inferredType === 'boolean') {
this.removeAttribute(name);
}
}
|
[
"function",
"(",
"name",
")",
"{",
"var",
"inferredType",
"=",
"typeof",
"this",
"[",
"name",
"]",
";",
"// try to intelligently serialize property value\r",
"var",
"serializedValue",
"=",
"this",
".",
"serializeValue",
"(",
"this",
"[",
"name",
"]",
",",
"inferredType",
")",
";",
"// boolean properties must reflect as boolean attributes\r",
"if",
"(",
"serializedValue",
"!==",
"undefined",
")",
"{",
"this",
".",
"setAttribute",
"(",
"name",
",",
"serializedValue",
")",
";",
"// TODO(sorvell): we should remove attr for all properties\r",
"// that have undefined serialization; however, we will need to\r",
"// refine the attr reflection system to achieve this; pica, for example,\r",
"// relies on having inferredType object properties not removed as\r",
"// attrs.\r",
"}",
"else",
"if",
"(",
"inferredType",
"===",
"'boolean'",
")",
"{",
"this",
".",
"removeAttribute",
"(",
"name",
")",
";",
"}",
"}"
] |
serializes `name` property value and updates the corresponding attribute note that reflection is opt-in.
|
[
"serializes",
"name",
"property",
"value",
"and",
"updates",
"the",
"corresponding",
"attribute",
"note",
"that",
"reflection",
"is",
"opt",
"-",
"in",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9257-L9272
|
|
12,684
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
resolveBindingValue
|
function resolveBindingValue(oldValue, value) {
if (value === undefined && oldValue === null) {
return value;
}
return (value === null || value === undefined) ? oldValue : value;
}
|
javascript
|
function resolveBindingValue(oldValue, value) {
if (value === undefined && oldValue === null) {
return value;
}
return (value === null || value === undefined) ? oldValue : value;
}
|
[
"function",
"resolveBindingValue",
"(",
"oldValue",
",",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"undefined",
"&&",
"oldValue",
"===",
"null",
")",
"{",
"return",
"value",
";",
"}",
"return",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
")",
"?",
"oldValue",
":",
"value",
";",
"}"
] |
capture A's value if B's value is null or undefined, otherwise use B's value
|
[
"capture",
"A",
"s",
"value",
"if",
"B",
"s",
"value",
"is",
"null",
"or",
"undefined",
"otherwise",
"use",
"B",
"s",
"value"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9320-L9325
|
12,685
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function() {
var n$ = this._observeNames;
if (n$ && n$.length) {
var o = this._propertyObserver = new CompoundObserver(true);
this.registerObserver(o);
// TODO(sorvell): may not be kosher to access the value here (this[n]);
// previously we looked at the descriptor on the prototype
// this doesn't work for inheritance and not for accessors without
// a value property
for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) {
o.addPath(this, n);
this.observeArrayValue(n, this[n], null);
}
}
}
|
javascript
|
function() {
var n$ = this._observeNames;
if (n$ && n$.length) {
var o = this._propertyObserver = new CompoundObserver(true);
this.registerObserver(o);
// TODO(sorvell): may not be kosher to access the value here (this[n]);
// previously we looked at the descriptor on the prototype
// this doesn't work for inheritance and not for accessors without
// a value property
for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) {
o.addPath(this, n);
this.observeArrayValue(n, this[n], null);
}
}
}
|
[
"function",
"(",
")",
"{",
"var",
"n$",
"=",
"this",
".",
"_observeNames",
";",
"if",
"(",
"n$",
"&&",
"n$",
".",
"length",
")",
"{",
"var",
"o",
"=",
"this",
".",
"_propertyObserver",
"=",
"new",
"CompoundObserver",
"(",
"true",
")",
";",
"this",
".",
"registerObserver",
"(",
"o",
")",
";",
"// TODO(sorvell): may not be kosher to access the value here (this[n]);",
"// previously we looked at the descriptor on the prototype",
"// this doesn't work for inheritance and not for accessors without",
"// a value property",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"n$",
".",
"length",
",",
"n",
";",
"(",
"i",
"<",
"l",
")",
"&&",
"(",
"n",
"=",
"n$",
"[",
"i",
"]",
")",
";",
"i",
"++",
")",
"{",
"o",
".",
"addPath",
"(",
"this",
",",
"n",
")",
";",
"this",
".",
"observeArrayValue",
"(",
"n",
",",
"this",
"[",
"n",
"]",
",",
"null",
")",
";",
"}",
"}",
"}"
] |
creates a CompoundObserver to observe property changes NOTE, this is only done there are any properties in the `observe` object
|
[
"creates",
"a",
"CompoundObserver",
"to",
"observe",
"property",
"changes",
"NOTE",
"this",
"is",
"only",
"done",
"there",
"are",
"any",
"properties",
"in",
"the",
"observe",
"object"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9331-L9345
|
|
12,686
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(name, observable, resolveFn) {
var privateName = name + '_';
var privateObservable = name + 'Observable_';
// Present for properties which are computed and published and have a
// bound value.
var privateComputedBoundValue = name + 'ComputedBoundObservable_';
this[privateObservable] = observable;
var oldValue = this[privateName];
// observable callback
var self = this;
function updateValue(value, oldValue) {
self[privateName] = value;
var setObserveable = self[privateComputedBoundValue];
if (setObserveable && typeof setObserveable.setValue == 'function') {
setObserveable.setValue(value);
}
self.emitPropertyChangeRecord(name, value, oldValue);
}
// resolve initial value
var value = observable.open(updateValue);
if (resolveFn && !areSameValue(oldValue, value)) {
var resolvedValue = resolveFn(oldValue, value);
if (!areSameValue(value, resolvedValue)) {
value = resolvedValue;
if (observable.setValue) {
observable.setValue(value);
}
}
}
updateValue(value, oldValue);
// register and return observable
var observer = {
close: function() {
observable.close();
self[privateObservable] = undefined;
self[privateComputedBoundValue] = undefined;
}
};
this.registerObserver(observer);
return observer;
}
|
javascript
|
function(name, observable, resolveFn) {
var privateName = name + '_';
var privateObservable = name + 'Observable_';
// Present for properties which are computed and published and have a
// bound value.
var privateComputedBoundValue = name + 'ComputedBoundObservable_';
this[privateObservable] = observable;
var oldValue = this[privateName];
// observable callback
var self = this;
function updateValue(value, oldValue) {
self[privateName] = value;
var setObserveable = self[privateComputedBoundValue];
if (setObserveable && typeof setObserveable.setValue == 'function') {
setObserveable.setValue(value);
}
self.emitPropertyChangeRecord(name, value, oldValue);
}
// resolve initial value
var value = observable.open(updateValue);
if (resolveFn && !areSameValue(oldValue, value)) {
var resolvedValue = resolveFn(oldValue, value);
if (!areSameValue(value, resolvedValue)) {
value = resolvedValue;
if (observable.setValue) {
observable.setValue(value);
}
}
}
updateValue(value, oldValue);
// register and return observable
var observer = {
close: function() {
observable.close();
self[privateObservable] = undefined;
self[privateComputedBoundValue] = undefined;
}
};
this.registerObserver(observer);
return observer;
}
|
[
"function",
"(",
"name",
",",
"observable",
",",
"resolveFn",
")",
"{",
"var",
"privateName",
"=",
"name",
"+",
"'_'",
";",
"var",
"privateObservable",
"=",
"name",
"+",
"'Observable_'",
";",
"// Present for properties which are computed and published and have a",
"// bound value.",
"var",
"privateComputedBoundValue",
"=",
"name",
"+",
"'ComputedBoundObservable_'",
";",
"this",
"[",
"privateObservable",
"]",
"=",
"observable",
";",
"var",
"oldValue",
"=",
"this",
"[",
"privateName",
"]",
";",
"// observable callback",
"var",
"self",
"=",
"this",
";",
"function",
"updateValue",
"(",
"value",
",",
"oldValue",
")",
"{",
"self",
"[",
"privateName",
"]",
"=",
"value",
";",
"var",
"setObserveable",
"=",
"self",
"[",
"privateComputedBoundValue",
"]",
";",
"if",
"(",
"setObserveable",
"&&",
"typeof",
"setObserveable",
".",
"setValue",
"==",
"'function'",
")",
"{",
"setObserveable",
".",
"setValue",
"(",
"value",
")",
";",
"}",
"self",
".",
"emitPropertyChangeRecord",
"(",
"name",
",",
"value",
",",
"oldValue",
")",
";",
"}",
"// resolve initial value",
"var",
"value",
"=",
"observable",
".",
"open",
"(",
"updateValue",
")",
";",
"if",
"(",
"resolveFn",
"&&",
"!",
"areSameValue",
"(",
"oldValue",
",",
"value",
")",
")",
"{",
"var",
"resolvedValue",
"=",
"resolveFn",
"(",
"oldValue",
",",
"value",
")",
";",
"if",
"(",
"!",
"areSameValue",
"(",
"value",
",",
"resolvedValue",
")",
")",
"{",
"value",
"=",
"resolvedValue",
";",
"if",
"(",
"observable",
".",
"setValue",
")",
"{",
"observable",
".",
"setValue",
"(",
"value",
")",
";",
"}",
"}",
"}",
"updateValue",
"(",
"value",
",",
"oldValue",
")",
";",
"// register and return observable",
"var",
"observer",
"=",
"{",
"close",
":",
"function",
"(",
")",
"{",
"observable",
".",
"close",
"(",
")",
";",
"self",
"[",
"privateObservable",
"]",
"=",
"undefined",
";",
"self",
"[",
"privateComputedBoundValue",
"]",
"=",
"undefined",
";",
"}",
"}",
";",
"this",
".",
"registerObserver",
"(",
"observer",
")",
";",
"return",
"observer",
";",
"}"
] |
NOTE property `name` must be published. This makes it an accessor.
|
[
"NOTE",
"property",
"name",
"must",
"be",
"published",
".",
"This",
"makes",
"it",
"an",
"accessor",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9469-L9509
|
|
12,687
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(template) {
// ensure template is decorated (lets' things like <tr template ...> work)
HTMLTemplateElement.decorate(template);
// ensure a default bindingDelegate
var syntax = this.syntax || (!template.bindingDelegate &&
this.element.syntax);
var dom = template.createInstance(this, syntax);
var observers = dom.bindings_;
for (var i = 0; i < observers.length; i++) {
this.registerObserver(observers[i]);
}
return dom;
}
|
javascript
|
function(template) {
// ensure template is decorated (lets' things like <tr template ...> work)
HTMLTemplateElement.decorate(template);
// ensure a default bindingDelegate
var syntax = this.syntax || (!template.bindingDelegate &&
this.element.syntax);
var dom = template.createInstance(this, syntax);
var observers = dom.bindings_;
for (var i = 0; i < observers.length; i++) {
this.registerObserver(observers[i]);
}
return dom;
}
|
[
"function",
"(",
"template",
")",
"{",
"// ensure template is decorated (lets' things like <tr template ...> work)",
"HTMLTemplateElement",
".",
"decorate",
"(",
"template",
")",
";",
"// ensure a default bindingDelegate",
"var",
"syntax",
"=",
"this",
".",
"syntax",
"||",
"(",
"!",
"template",
".",
"bindingDelegate",
"&&",
"this",
".",
"element",
".",
"syntax",
")",
";",
"var",
"dom",
"=",
"template",
".",
"createInstance",
"(",
"this",
",",
"syntax",
")",
";",
"var",
"observers",
"=",
"dom",
".",
"bindings_",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"observers",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"registerObserver",
"(",
"observers",
"[",
"i",
"]",
")",
";",
"}",
"return",
"dom",
";",
"}"
] |
Creates dom cloned from the given template, instantiating bindings
with this element as the template model and `PolymerExpressions` as the
binding delegate.
@method instanceTemplate
@param {Template} template source template from which to create dom.
|
[
"Creates",
"dom",
"cloned",
"from",
"the",
"given",
"template",
"instantiating",
"bindings",
"with",
"this",
"element",
"as",
"the",
"template",
"model",
"and",
"PolymerExpressions",
"as",
"the",
"binding",
"delegate",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9610-L9622
|
|
12,688
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function() {
if (!this._unbound) {
log.unbind && console.log('[%s] asyncUnbindAll', this.localName);
this._unbindAllJob = this.job(this._unbindAllJob, this.unbindAll, 0);
}
}
|
javascript
|
function() {
if (!this._unbound) {
log.unbind && console.log('[%s] asyncUnbindAll', this.localName);
this._unbindAllJob = this.job(this._unbindAllJob, this.unbindAll, 0);
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_unbound",
")",
"{",
"log",
".",
"unbind",
"&&",
"console",
".",
"log",
"(",
"'[%s] asyncUnbindAll'",
",",
"this",
".",
"localName",
")",
";",
"this",
".",
"_unbindAllJob",
"=",
"this",
".",
"job",
"(",
"this",
".",
"_unbindAllJob",
",",
"this",
".",
"unbindAll",
",",
"0",
")",
";",
"}",
"}"
] |
called at detached time to signal that an element's bindings should be cleaned up. This is done asynchronously so that users have the chance to call `cancelUnbindAll` to prevent unbinding.
|
[
"called",
"at",
"detached",
"time",
"to",
"signal",
"that",
"an",
"element",
"s",
"bindings",
"should",
"be",
"cleaned",
"up",
".",
"This",
"is",
"done",
"asynchronously",
"so",
"that",
"users",
"have",
"the",
"chance",
"to",
"call",
"cancelUnbindAll",
"to",
"prevent",
"unbinding",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9665-L9670
|
|
12,689
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(job, callback, wait) {
if (typeof job === 'string') {
var n = '___' + job;
this[n] = Polymer.job.call(this, this[n], callback, wait);
} else {
// TODO(sjmiles): suggest we deprecate this call signature
return Polymer.job.call(this, job, callback, wait);
}
}
|
javascript
|
function(job, callback, wait) {
if (typeof job === 'string') {
var n = '___' + job;
this[n] = Polymer.job.call(this, this[n], callback, wait);
} else {
// TODO(sjmiles): suggest we deprecate this call signature
return Polymer.job.call(this, job, callback, wait);
}
}
|
[
"function",
"(",
"job",
",",
"callback",
",",
"wait",
")",
"{",
"if",
"(",
"typeof",
"job",
"===",
"'string'",
")",
"{",
"var",
"n",
"=",
"'___'",
"+",
"job",
";",
"this",
"[",
"n",
"]",
"=",
"Polymer",
".",
"job",
".",
"call",
"(",
"this",
",",
"this",
"[",
"n",
"]",
",",
"callback",
",",
"wait",
")",
";",
"}",
"else",
"{",
"// TODO(sjmiles): suggest we deprecate this call signature",
"return",
"Polymer",
".",
"job",
".",
"call",
"(",
"this",
",",
"job",
",",
"callback",
",",
"wait",
")",
";",
"}",
"}"
] |
Debounce signals.
Call `job` to defer a named signal, and all subsequent matching signals,
until a wait time has elapsed with no new signal.
debouncedClickAction: function(e) {
// processClick only when it's been 100ms since the last click
this.job('click', function() {
this.processClick;
}, 100);
}
@method job
@param String {String} job A string identifier for the job to debounce.
@param Function {Function} callback A function that is called (with `this` context) when the wait time elapses.
@param Number {Number} wait Time in milliseconds (ms) after the last signal that must elapse before invoking `callback`
@type Handle
|
[
"Debounce",
"signals",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9778-L9786
|
|
12,690
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function() {
if (this.templateInstance && this.templateInstance.model) {
console.warn('Attributes on ' + this.localName + ' were data bound ' +
'prior to Polymer upgrading the element. This may result in ' +
'incorrect binding types.');
}
this.created();
this.prepareElement();
if (!this.ownerDocument.isStagingDocument) {
this.makeElementReady();
}
}
|
javascript
|
function() {
if (this.templateInstance && this.templateInstance.model) {
console.warn('Attributes on ' + this.localName + ' were data bound ' +
'prior to Polymer upgrading the element. This may result in ' +
'incorrect binding types.');
}
this.created();
this.prepareElement();
if (!this.ownerDocument.isStagingDocument) {
this.makeElementReady();
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"templateInstance",
"&&",
"this",
".",
"templateInstance",
".",
"model",
")",
"{",
"console",
".",
"warn",
"(",
"'Attributes on '",
"+",
"this",
".",
"localName",
"+",
"' were data bound '",
"+",
"'prior to Polymer upgrading the element. This may result in '",
"+",
"'incorrect binding types.'",
")",
";",
"}",
"this",
".",
"created",
"(",
")",
";",
"this",
".",
"prepareElement",
"(",
")",
";",
"if",
"(",
"!",
"this",
".",
"ownerDocument",
".",
"isStagingDocument",
")",
"{",
"this",
".",
"makeElementReady",
"(",
")",
";",
"}",
"}"
] |
Low-level lifecycle method called as part of standard Custom Elements
operation. Polymer implements this method to provide basic default
functionality. For custom create-time tasks, implement `created`
instead, which is called immediately after `createdCallback`.
@method createdCallback
|
[
"Low",
"-",
"level",
"lifecycle",
"method",
"called",
"as",
"part",
"of",
"standard",
"Custom",
"Elements",
"operation",
".",
"Polymer",
"implements",
"this",
"method",
"to",
"provide",
"basic",
"default",
"functionality",
".",
"For",
"custom",
"create",
"-",
"time",
"tasks",
"implement",
"created",
"instead",
"which",
"is",
"called",
"immediately",
"after",
"createdCallback",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9848-L9859
|
|
12,691
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function() {
if (this._elementPrepared) {
console.warn('Element already prepared', this.localName);
return;
}
this._elementPrepared = true;
// storage for shadowRoots info
this.shadowRoots = {};
// install property observers
this.createPropertyObserver();
this.openPropertyObserver();
// install boilerplate attributes
this.copyInstanceAttributes();
// process input attributes
this.takeAttributes();
// add event listeners
this.addHostListeners();
}
|
javascript
|
function() {
if (this._elementPrepared) {
console.warn('Element already prepared', this.localName);
return;
}
this._elementPrepared = true;
// storage for shadowRoots info
this.shadowRoots = {};
// install property observers
this.createPropertyObserver();
this.openPropertyObserver();
// install boilerplate attributes
this.copyInstanceAttributes();
// process input attributes
this.takeAttributes();
// add event listeners
this.addHostListeners();
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_elementPrepared",
")",
"{",
"console",
".",
"warn",
"(",
"'Element already prepared'",
",",
"this",
".",
"localName",
")",
";",
"return",
";",
"}",
"this",
".",
"_elementPrepared",
"=",
"true",
";",
"// storage for shadowRoots info",
"this",
".",
"shadowRoots",
"=",
"{",
"}",
";",
"// install property observers",
"this",
".",
"createPropertyObserver",
"(",
")",
";",
"this",
".",
"openPropertyObserver",
"(",
")",
";",
"// install boilerplate attributes",
"this",
".",
"copyInstanceAttributes",
"(",
")",
";",
"// process input attributes",
"this",
".",
"takeAttributes",
"(",
")",
";",
"// add event listeners",
"this",
".",
"addHostListeners",
"(",
")",
";",
"}"
] |
system entry point, do not override
|
[
"system",
"entry",
"point",
"do",
"not",
"override"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9862-L9879
|
|
12,692
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(name, oldValue) {
// TODO(sjmiles): adhoc filter
if (name !== 'class' && name !== 'style') {
this.attributeToProperty(name, this.getAttribute(name));
}
if (this.attributeChanged) {
this.attributeChanged.apply(this, arguments);
}
}
|
javascript
|
function(name, oldValue) {
// TODO(sjmiles): adhoc filter
if (name !== 'class' && name !== 'style') {
this.attributeToProperty(name, this.getAttribute(name));
}
if (this.attributeChanged) {
this.attributeChanged.apply(this, arguments);
}
}
|
[
"function",
"(",
"name",
",",
"oldValue",
")",
"{",
"// TODO(sjmiles): adhoc filter",
"if",
"(",
"name",
"!==",
"'class'",
"&&",
"name",
"!==",
"'style'",
")",
"{",
"this",
".",
"attributeToProperty",
"(",
"name",
",",
"this",
".",
"getAttribute",
"(",
"name",
")",
")",
";",
"}",
"if",
"(",
"this",
".",
"attributeChanged",
")",
"{",
"this",
".",
"attributeChanged",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"}"
] |
Low-level lifecycle method called as part of standard Custom Elements
operation. Polymer implements this method to provide basic default
functionality. For custom tasks in your element, implement `attributeChanged`
instead, which is called immediately after `attributeChangedCallback`.
@method attributeChangedCallback
|
[
"Low",
"-",
"level",
"lifecycle",
"method",
"called",
"as",
"part",
"of",
"standard",
"Custom",
"Elements",
"operation",
".",
"Polymer",
"implements",
"this",
"method",
"to",
"provide",
"basic",
"default",
"functionality",
".",
"For",
"custom",
"tasks",
"in",
"your",
"element",
"implement",
"attributeChanged",
"instead",
"which",
"is",
"called",
"immediately",
"after",
"attributeChangedCallback",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9904-L9912
|
|
12,693
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(p) {
if (p && p.element) {
this.parseDeclarations(p.__proto__);
p.parseDeclaration.call(this, p.element);
}
}
|
javascript
|
function(p) {
if (p && p.element) {
this.parseDeclarations(p.__proto__);
p.parseDeclaration.call(this, p.element);
}
}
|
[
"function",
"(",
"p",
")",
"{",
"if",
"(",
"p",
"&&",
"p",
".",
"element",
")",
"{",
"this",
".",
"parseDeclarations",
"(",
"p",
".",
"__proto__",
")",
";",
"p",
".",
"parseDeclaration",
".",
"call",
"(",
"this",
",",
"p",
".",
"element",
")",
";",
"}",
"}"
] |
Walks the prototype-chain of this element and allows specific
classes a chance to process static declarations.
In particular, each polymer-element has it's own `template`.
`parseDeclarations` is used to accumulate all element `template`s
from an inheritance chain.
`parseDeclaration` static methods implemented in the chain are called
recursively, oldest first, with the `<polymer-element>` associated
with the current prototype passed as an argument.
An element may override this method to customize shadow-root generation.
@method parseDeclarations
|
[
"Walks",
"the",
"prototype",
"-",
"chain",
"of",
"this",
"element",
"and",
"allows",
"specific",
"classes",
"a",
"chance",
"to",
"process",
"static",
"declarations",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L9985-L9990
|
|
12,694
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(template) {
if (template) {
// make a shadow root
var root = this.createShadowRoot();
// stamp template
// which includes parsing and applying MDV bindings before being
// inserted (to avoid {{}} in attribute values)
// e.g. to prevent <img src="images/{{icon}}"> from generating a 404.
var dom = this.instanceTemplate(template);
// append to shadow dom
root.appendChild(dom);
// perform post-construction initialization tasks on shadow root
this.shadowRootReady(root, template);
// return the created shadow root
return root;
}
}
|
javascript
|
function(template) {
if (template) {
// make a shadow root
var root = this.createShadowRoot();
// stamp template
// which includes parsing and applying MDV bindings before being
// inserted (to avoid {{}} in attribute values)
// e.g. to prevent <img src="images/{{icon}}"> from generating a 404.
var dom = this.instanceTemplate(template);
// append to shadow dom
root.appendChild(dom);
// perform post-construction initialization tasks on shadow root
this.shadowRootReady(root, template);
// return the created shadow root
return root;
}
}
|
[
"function",
"(",
"template",
")",
"{",
"if",
"(",
"template",
")",
"{",
"// make a shadow root",
"var",
"root",
"=",
"this",
".",
"createShadowRoot",
"(",
")",
";",
"// stamp template",
"// which includes parsing and applying MDV bindings before being",
"// inserted (to avoid {{}} in attribute values)",
"// e.g. to prevent <img src=\"images/{{icon}}\"> from generating a 404.",
"var",
"dom",
"=",
"this",
".",
"instanceTemplate",
"(",
"template",
")",
";",
"// append to shadow dom",
"root",
".",
"appendChild",
"(",
"dom",
")",
";",
"// perform post-construction initialization tasks on shadow root",
"this",
".",
"shadowRootReady",
"(",
"root",
",",
"template",
")",
";",
"// return the created shadow root",
"return",
"root",
";",
"}",
"}"
] |
Create a shadow-root in this host and stamp `template` as it's
content.
An element may override this method for custom behavior.
@method shadowFromTemplate
|
[
"Create",
"a",
"shadow",
"-",
"root",
"in",
"this",
"host",
"and",
"stamp",
"template",
"as",
"it",
"s",
"content",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L10032-L10048
|
|
12,695
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(node, listener) {
var observer = new MutationObserver(function(mutations) {
listener.call(this, observer, mutations);
observer.disconnect();
}.bind(this));
observer.observe(node, {childList: true, subtree: true});
}
|
javascript
|
function(node, listener) {
var observer = new MutationObserver(function(mutations) {
listener.call(this, observer, mutations);
observer.disconnect();
}.bind(this));
observer.observe(node, {childList: true, subtree: true});
}
|
[
"function",
"(",
"node",
",",
"listener",
")",
"{",
"var",
"observer",
"=",
"new",
"MutationObserver",
"(",
"function",
"(",
"mutations",
")",
"{",
"listener",
".",
"call",
"(",
"this",
",",
"observer",
",",
"mutations",
")",
";",
"observer",
".",
"disconnect",
"(",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"observer",
".",
"observe",
"(",
"node",
",",
"{",
"childList",
":",
"true",
",",
"subtree",
":",
"true",
"}",
")",
";",
"}"
] |
Register a one-time callback when a child-list or sub-tree mutation
occurs on node.
For persistent callbacks, call onMutation from your listener.
@method onMutation
@param Node {Node} node Node to watch for mutations.
@param Function {Function} listener Function to call on mutation. The function is invoked as `listener.call(this, observer, mutations);` where `observer` is the MutationObserver that triggered the notification, and `mutations` is the native mutation list.
|
[
"Register",
"a",
"one",
"-",
"time",
"callback",
"when",
"a",
"child",
"-",
"list",
"or",
"sub",
"-",
"tree",
"mutation",
"occurs",
"on",
"node",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L10104-L10110
|
|
12,696
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(callback) {
var template = this.fetchTemplate();
var content = template && this.templateContent();
if (content) {
this.convertSheetsToStyles(content);
var styles = this.findLoadableStyles(content);
if (styles.length) {
var templateUrl = template.ownerDocument.baseURI;
return Polymer.styleResolver.loadStyles(styles, templateUrl, callback);
}
}
if (callback) {
callback();
}
}
|
javascript
|
function(callback) {
var template = this.fetchTemplate();
var content = template && this.templateContent();
if (content) {
this.convertSheetsToStyles(content);
var styles = this.findLoadableStyles(content);
if (styles.length) {
var templateUrl = template.ownerDocument.baseURI;
return Polymer.styleResolver.loadStyles(styles, templateUrl, callback);
}
}
if (callback) {
callback();
}
}
|
[
"function",
"(",
"callback",
")",
"{",
"var",
"template",
"=",
"this",
".",
"fetchTemplate",
"(",
")",
";",
"var",
"content",
"=",
"template",
"&&",
"this",
".",
"templateContent",
"(",
")",
";",
"if",
"(",
"content",
")",
"{",
"this",
".",
"convertSheetsToStyles",
"(",
"content",
")",
";",
"var",
"styles",
"=",
"this",
".",
"findLoadableStyles",
"(",
"content",
")",
";",
"if",
"(",
"styles",
".",
"length",
")",
"{",
"var",
"templateUrl",
"=",
"template",
".",
"ownerDocument",
".",
"baseURI",
";",
"return",
"Polymer",
".",
"styleResolver",
".",
"loadStyles",
"(",
"styles",
",",
"templateUrl",
",",
"callback",
")",
";",
"}",
"}",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
")",
";",
"}",
"}"
] |
returns true if resources are loading
|
[
"returns",
"true",
"if",
"resources",
"are",
"loading"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L10435-L10449
|
|
12,697
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function() {
this.sheets = this.findNodes(SHEET_SELECTOR);
this.sheets.forEach(function(s) {
if (s.parentNode) {
s.parentNode.removeChild(s);
}
});
}
|
javascript
|
function() {
this.sheets = this.findNodes(SHEET_SELECTOR);
this.sheets.forEach(function(s) {
if (s.parentNode) {
s.parentNode.removeChild(s);
}
});
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"sheets",
"=",
"this",
".",
"findNodes",
"(",
"SHEET_SELECTOR",
")",
";",
"this",
".",
"sheets",
".",
"forEach",
"(",
"function",
"(",
"s",
")",
"{",
"if",
"(",
"s",
".",
"parentNode",
")",
"{",
"s",
".",
"parentNode",
".",
"removeChild",
"(",
"s",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Remove all sheets from element and store for later use.
|
[
"Remove",
"all",
"sheets",
"from",
"element",
"and",
"store",
"for",
"later",
"use",
"."
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L10492-L10499
|
|
12,698
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(name, extendee) {
// build side-chained lists to optimize iterations
this.optimizePropertyMaps(this.prototype);
this.createPropertyAccessors(this.prototype);
// install mdv delegate on template
this.installBindingDelegate(this.fetchTemplate());
// install external stylesheets as if they are inline
this.installSheets();
// adjust any paths in dom from imports
this.resolveElementPaths(this);
// compile list of attributes to copy to instances
this.accumulateInstanceAttributes();
// parse on-* delegates declared on `this` element
this.parseHostEvents();
//
// install a helper method this.resolvePath to aid in
// setting resource urls. e.g.
// this.$.image.src = this.resolvePath('images/foo.png')
this.addResolvePathApi();
// under ShadowDOMPolyfill, transforms to approximate missing CSS features
if (hasShadowDOMPolyfill) {
WebComponents.ShadowCSS.shimStyling(this.templateContent(), name,
extendee);
}
// allow custom element access to the declarative context
if (this.prototype.registerCallback) {
this.prototype.registerCallback(this);
}
}
|
javascript
|
function(name, extendee) {
// build side-chained lists to optimize iterations
this.optimizePropertyMaps(this.prototype);
this.createPropertyAccessors(this.prototype);
// install mdv delegate on template
this.installBindingDelegate(this.fetchTemplate());
// install external stylesheets as if they are inline
this.installSheets();
// adjust any paths in dom from imports
this.resolveElementPaths(this);
// compile list of attributes to copy to instances
this.accumulateInstanceAttributes();
// parse on-* delegates declared on `this` element
this.parseHostEvents();
//
// install a helper method this.resolvePath to aid in
// setting resource urls. e.g.
// this.$.image.src = this.resolvePath('images/foo.png')
this.addResolvePathApi();
// under ShadowDOMPolyfill, transforms to approximate missing CSS features
if (hasShadowDOMPolyfill) {
WebComponents.ShadowCSS.shimStyling(this.templateContent(), name,
extendee);
}
// allow custom element access to the declarative context
if (this.prototype.registerCallback) {
this.prototype.registerCallback(this);
}
}
|
[
"function",
"(",
"name",
",",
"extendee",
")",
"{",
"// build side-chained lists to optimize iterations",
"this",
".",
"optimizePropertyMaps",
"(",
"this",
".",
"prototype",
")",
";",
"this",
".",
"createPropertyAccessors",
"(",
"this",
".",
"prototype",
")",
";",
"// install mdv delegate on template",
"this",
".",
"installBindingDelegate",
"(",
"this",
".",
"fetchTemplate",
"(",
")",
")",
";",
"// install external stylesheets as if they are inline",
"this",
".",
"installSheets",
"(",
")",
";",
"// adjust any paths in dom from imports",
"this",
".",
"resolveElementPaths",
"(",
"this",
")",
";",
"// compile list of attributes to copy to instances",
"this",
".",
"accumulateInstanceAttributes",
"(",
")",
";",
"// parse on-* delegates declared on `this` element",
"this",
".",
"parseHostEvents",
"(",
")",
";",
"//",
"// install a helper method this.resolvePath to aid in ",
"// setting resource urls. e.g.",
"// this.$.image.src = this.resolvePath('images/foo.png')",
"this",
".",
"addResolvePathApi",
"(",
")",
";",
"// under ShadowDOMPolyfill, transforms to approximate missing CSS features",
"if",
"(",
"hasShadowDOMPolyfill",
")",
"{",
"WebComponents",
".",
"ShadowCSS",
".",
"shimStyling",
"(",
"this",
".",
"templateContent",
"(",
")",
",",
"name",
",",
"extendee",
")",
";",
"}",
"// allow custom element access to the declarative context",
"if",
"(",
"this",
".",
"prototype",
".",
"registerCallback",
")",
"{",
"this",
".",
"prototype",
".",
"registerCallback",
"(",
"this",
")",
";",
"}",
"}"
] |
implement various declarative features
|
[
"implement",
"various",
"declarative",
"features"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L11187-L11215
|
|
12,699
|
WebReflection/document-register-element
|
examples/bower_components/polymer/polymer.js
|
function(extnds) {
var prototype = this.findBasePrototype(extnds);
if (!prototype) {
// create a prototype based on tag-name extension
var prototype = HTMLElement.getPrototypeForTag(extnds);
// insert base api in inheritance chain (if needed)
prototype = this.ensureBaseApi(prototype);
// memoize this base
memoizedBases[extnds] = prototype;
}
return prototype;
}
|
javascript
|
function(extnds) {
var prototype = this.findBasePrototype(extnds);
if (!prototype) {
// create a prototype based on tag-name extension
var prototype = HTMLElement.getPrototypeForTag(extnds);
// insert base api in inheritance chain (if needed)
prototype = this.ensureBaseApi(prototype);
// memoize this base
memoizedBases[extnds] = prototype;
}
return prototype;
}
|
[
"function",
"(",
"extnds",
")",
"{",
"var",
"prototype",
"=",
"this",
".",
"findBasePrototype",
"(",
"extnds",
")",
";",
"if",
"(",
"!",
"prototype",
")",
"{",
"// create a prototype based on tag-name extension",
"var",
"prototype",
"=",
"HTMLElement",
".",
"getPrototypeForTag",
"(",
"extnds",
")",
";",
"// insert base api in inheritance chain (if needed)",
"prototype",
"=",
"this",
".",
"ensureBaseApi",
"(",
"prototype",
")",
";",
"// memoize this base",
"memoizedBases",
"[",
"extnds",
"]",
"=",
"prototype",
";",
"}",
"return",
"prototype",
";",
"}"
] |
build prototype combining extendee, Polymer base, and named api
|
[
"build",
"prototype",
"combining",
"extendee",
"Polymer",
"base",
"and",
"named",
"api"
] |
f50fb6d3a712745e9f317db241f4c3c523eecb25
|
https://github.com/WebReflection/document-register-element/blob/f50fb6d3a712745e9f317db241f4c3c523eecb25/examples/bower_components/polymer/polymer.js#L11227-L11238
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.