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,500 | laverdet/node-fibers | build.js | afterBuild | function afterBuild() {
var targetPath = path.join(__dirname, 'build', debug ? 'Debug' : 'Release', 'fibers.node');
var installPath = path.join(__dirname, 'bin', modPath, 'fibers.node');
try {
fs.mkdirSync(path.join(__dirname, 'bin', modPath));
} catch (ex) {}
try {
fs.statSync(targetPath);
} catch (ex) {
console.error('Build succeeded but target not found');
process.exit(1);
}
fs.renameSync(targetPath, installPath);
console.log('Installed in `'+ installPath+ '`');
if (process.versions.electron) {
process.nextTick(function() {
require('electron').app.quit();
});
}
} | javascript | function afterBuild() {
var targetPath = path.join(__dirname, 'build', debug ? 'Debug' : 'Release', 'fibers.node');
var installPath = path.join(__dirname, 'bin', modPath, 'fibers.node');
try {
fs.mkdirSync(path.join(__dirname, 'bin', modPath));
} catch (ex) {}
try {
fs.statSync(targetPath);
} catch (ex) {
console.error('Build succeeded but target not found');
process.exit(1);
}
fs.renameSync(targetPath, installPath);
console.log('Installed in `'+ installPath+ '`');
if (process.versions.electron) {
process.nextTick(function() {
require('electron').app.quit();
});
}
} | [
"function",
"afterBuild",
"(",
")",
"{",
"var",
"targetPath",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'build'",
",",
"debug",
"?",
"'Debug'",
":",
"'Release'",
",",
"'fibers.node'",
")",
";",
"var",
"installPath",
"=",
"path",
".",
"join",
"(",... | Move it to expected location | [
"Move",
"it",
"to",
"expected",
"location"
] | 5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f | https://github.com/laverdet/node-fibers/blob/5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f/build.js#L89-L110 |
12,501 | zhanziyang/vue-croppa | docs/static/kute-page_files/common.d313593452690288a963.js | isArray | function isArray (arr) {
return Array.isArray
? Array.isArray(arr)
: Object.prototype.toString.call(arr) === '[object Array]'
} | javascript | function isArray (arr) {
return Array.isArray
? Array.isArray(arr)
: Object.prototype.toString.call(arr) === '[object Array]'
} | [
"function",
"isArray",
"(",
"arr",
")",
"{",
"return",
"Array",
".",
"isArray",
"?",
"Array",
".",
"isArray",
"(",
"arr",
")",
":",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"arr",
")",
"===",
"'[object Array]'",
"}"
] | checks if passed argument is an array
@param {any} arr - the object to check
@return {Boolean} - true if `arr` is an array | [
"checks",
"if",
"passed",
"argument",
"is",
"an",
"array"
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/common.d313593452690288a963.js#L338-L342 |
12,502 | zhanziyang/vue-croppa | docs/static/kute-page_files/common.d313593452690288a963.js | function (info) { return Object.keys(info).reduce(function (escaped, key) {
var ref = info.__dangerouslyDisableSanitizers;
var isDisabled = ref && ref.indexOf(key) > -1;
var val = info[key];
escaped[key] = val;
if (key === '__dangerouslyDisableSanitizers') {
return escaped
}
if (!isDisabled) {
if (typeof val === 'string') {
escaped[key] = escapeHTML(val);
} else if (index$2$1(val)) {
escaped[key] = escape(val);
} else if (isArray(val)) {
escaped[key] = val.map(escape);
} else {
escaped[key] = val;
}
} else {
escaped[key] = val;
}
return escaped
}, {}); } | javascript | function (info) { return Object.keys(info).reduce(function (escaped, key) {
var ref = info.__dangerouslyDisableSanitizers;
var isDisabled = ref && ref.indexOf(key) > -1;
var val = info[key];
escaped[key] = val;
if (key === '__dangerouslyDisableSanitizers') {
return escaped
}
if (!isDisabled) {
if (typeof val === 'string') {
escaped[key] = escapeHTML(val);
} else if (index$2$1(val)) {
escaped[key] = escape(val);
} else if (isArray(val)) {
escaped[key] = val.map(escape);
} else {
escaped[key] = val;
}
} else {
escaped[key] = val;
}
return escaped
}, {}); } | [
"function",
"(",
"info",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"info",
")",
".",
"reduce",
"(",
"function",
"(",
"escaped",
",",
"key",
")",
"{",
"var",
"ref",
"=",
"info",
".",
"__dangerouslyDisableSanitizers",
";",
"var",
"isDisabled",
"=",
... | sanitizes potentially dangerous characters | [
"sanitizes",
"potentially",
"dangerous",
"characters"
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/common.d313593452690288a963.js#L498-L521 | |
12,503 | zhanziyang/vue-croppa | docs/static/kute-page_files/common.d313593452690288a963.js | VueMeta | function VueMeta (Vue, options) {
if ( options === void 0 ) options = {};
// set some default options
var defaultOptions = {
keyName: VUE_META_KEY_NAME,
attribute: VUE_META_ATTRIBUTE,
ssrAttribute: VUE_META_SERVER_RENDERED_ATTRIBUTE,
tagIDKeyName: VUE_META_TAG_LIST_ID_KEY_NAME
};
// combine options
options = index(defaultOptions, options);
// bind the $meta method to this component instance
Vue.prototype.$meta = _$meta(options);
// store an id to keep track of DOM updates
var batchID = null;
// watch for client side component updates
Vue.mixin({
beforeCreate: function beforeCreate () {
// Add a marker to know if it uses metaInfo
if (typeof this.$options[options.keyName] !== 'undefined') {
this._hasMetaInfo = true;
}
// coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (typeof this.$options[options.keyName] === 'function') {
if (typeof this.$options.computed === 'undefined') {
this.$options.computed = {};
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
}
},
created: function created () {
var this$1 = this;
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
if (this.$metaInfo) {
this.$watch('$metaInfo', function () {
// batch potential DOM updates to prevent extraneous re-rendering
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
});
}
},
activated: function activated () {
var this$1 = this;
if (this._hasMetaInfo) {
// batch potential DOM updates to prevent extraneous re-rendering
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
}
},
deactivated: function deactivated () {
var this$1 = this;
if (this._hasMetaInfo) {
// batch potential DOM updates to prevent extraneous re-rendering
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
}
},
beforeMount: function beforeMount () {
var this$1 = this;
// batch potential DOM updates to prevent extraneous re-rendering
if (this._hasMetaInfo) {
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
}
},
destroyed: function destroyed () {
var this$1 = this;
// do not trigger refresh on the server side
if (this.$isServer) { return }
// re-render meta data when returning from a child component to parent
if (this._hasMetaInfo) {
// Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (this$1.$el.offsetParent !== null) { return }
clearInterval(interval);
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
}, 50);
}
}
});
} | javascript | function VueMeta (Vue, options) {
if ( options === void 0 ) options = {};
// set some default options
var defaultOptions = {
keyName: VUE_META_KEY_NAME,
attribute: VUE_META_ATTRIBUTE,
ssrAttribute: VUE_META_SERVER_RENDERED_ATTRIBUTE,
tagIDKeyName: VUE_META_TAG_LIST_ID_KEY_NAME
};
// combine options
options = index(defaultOptions, options);
// bind the $meta method to this component instance
Vue.prototype.$meta = _$meta(options);
// store an id to keep track of DOM updates
var batchID = null;
// watch for client side component updates
Vue.mixin({
beforeCreate: function beforeCreate () {
// Add a marker to know if it uses metaInfo
if (typeof this.$options[options.keyName] !== 'undefined') {
this._hasMetaInfo = true;
}
// coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (typeof this.$options[options.keyName] === 'function') {
if (typeof this.$options.computed === 'undefined') {
this.$options.computed = {};
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
}
},
created: function created () {
var this$1 = this;
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
if (this.$metaInfo) {
this.$watch('$metaInfo', function () {
// batch potential DOM updates to prevent extraneous re-rendering
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
});
}
},
activated: function activated () {
var this$1 = this;
if (this._hasMetaInfo) {
// batch potential DOM updates to prevent extraneous re-rendering
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
}
},
deactivated: function deactivated () {
var this$1 = this;
if (this._hasMetaInfo) {
// batch potential DOM updates to prevent extraneous re-rendering
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
}
},
beforeMount: function beforeMount () {
var this$1 = this;
// batch potential DOM updates to prevent extraneous re-rendering
if (this._hasMetaInfo) {
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
}
},
destroyed: function destroyed () {
var this$1 = this;
// do not trigger refresh on the server side
if (this.$isServer) { return }
// re-render meta data when returning from a child component to parent
if (this._hasMetaInfo) {
// Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (this$1.$el.offsetParent !== null) { return }
clearInterval(interval);
batchID = batchUpdate(batchID, function () { return this$1.$meta().refresh(); });
}, 50);
}
}
});
} | [
"function",
"VueMeta",
"(",
"Vue",
",",
"options",
")",
"{",
"if",
"(",
"options",
"===",
"void",
"0",
")",
"options",
"=",
"{",
"}",
";",
"// set some default options",
"var",
"defaultOptions",
"=",
"{",
"keyName",
":",
"VUE_META_KEY_NAME",
",",
"attribute"... | Plugin install function.
@param {Function} Vue - the Vue constructor. | [
"Plugin",
"install",
"function",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/common.d313593452690288a963.js#L979-L1067 |
12,504 | zhanziyang/vue-croppa | docs/static/kute-page_files/common.d313593452690288a963.js | encodeURIComponentPretty | function encodeURIComponentPretty (str) {
return encodeURI(str).replace(/[\/?#]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
})
} | javascript | function encodeURIComponentPretty (str) {
return encodeURI(str).replace(/[\/?#]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
})
} | [
"function",
"encodeURIComponentPretty",
"(",
"str",
")",
"{",
"return",
"encodeURI",
"(",
"str",
")",
".",
"replace",
"(",
"/",
"[\\/?#]",
"/",
"g",
",",
"function",
"(",
"c",
")",
"{",
"return",
"'%'",
"+",
"c",
".",
"charCodeAt",
"(",
"0",
")",
"."... | Prettier encoding of URI path segments.
@param {string}
@return {string} | [
"Prettier",
"encoding",
"of",
"URI",
"path",
"segments",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/common.d313593452690288a963.js#L1808-L1812 |
12,505 | zhanziyang/vue-croppa | docs/static/kute-page_files/app.e653d17f57bebeb097ee.js | ansiHTML | function ansiHTML (text) {
// Returns the text if the string has no ANSI escape code.
if (!_regANSI.test(text)) {
return text
}
// Cache opened sequence.
var ansiCodes = []
// Replace with markup.
var ret = text.replace(/\033\[(\d+)*m/g, function (match, seq) {
var ot = _openTags[seq]
if (ot) {
// If current sequence has been opened, close it.
if (!!~ansiCodes.indexOf(seq)) { // eslint-disable-line no-extra-boolean-cast
ansiCodes.pop()
return '</span>'
}
// Open tag.
ansiCodes.push(seq)
return ot[0] === '<' ? ot : '<span style="' + ot + ';">'
}
var ct = _closeTags[seq]
if (ct) {
// Pop sequence
ansiCodes.pop()
return ct
}
return ''
})
// Make sure tags are closed.
var l = ansiCodes.length
;(l > 0) && (ret += Array(l + 1).join('</span>'))
return ret
} | javascript | function ansiHTML (text) {
// Returns the text if the string has no ANSI escape code.
if (!_regANSI.test(text)) {
return text
}
// Cache opened sequence.
var ansiCodes = []
// Replace with markup.
var ret = text.replace(/\033\[(\d+)*m/g, function (match, seq) {
var ot = _openTags[seq]
if (ot) {
// If current sequence has been opened, close it.
if (!!~ansiCodes.indexOf(seq)) { // eslint-disable-line no-extra-boolean-cast
ansiCodes.pop()
return '</span>'
}
// Open tag.
ansiCodes.push(seq)
return ot[0] === '<' ? ot : '<span style="' + ot + ';">'
}
var ct = _closeTags[seq]
if (ct) {
// Pop sequence
ansiCodes.pop()
return ct
}
return ''
})
// Make sure tags are closed.
var l = ansiCodes.length
;(l > 0) && (ret += Array(l + 1).join('</span>'))
return ret
} | [
"function",
"ansiHTML",
"(",
"text",
")",
"{",
"// Returns the text if the string has no ANSI escape code.",
"if",
"(",
"!",
"_regANSI",
".",
"test",
"(",
"text",
")",
")",
"{",
"return",
"text",
"}",
"// Cache opened sequence.",
"var",
"ansiCodes",
"=",
"[",
"]",... | Converts text with ANSI color codes to HTML markup.
@param {String} text
@returns {*} | [
"Converts",
"text",
"with",
"ANSI",
"color",
"codes",
"to",
"HTML",
"markup",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/app.e653d17f57bebeb097ee.js#L2808-L2844 |
12,506 | zhanziyang/vue-croppa | docs/static/kute-page_files/app.e653d17f57bebeb097ee.js | race$1 | function race$1(entries) {
/*jshint validthis:true */
var Constructor = this;
if (!isArray(entries)) {
return new Constructor(function (_, reject) {
return reject(new TypeError('You must pass an array to race.'));
});
} else {
return new Constructor(function (resolve, reject) {
var length = entries.length;
for (var i = 0; i < length; i++) {
Constructor.resolve(entries[i]).then(resolve, reject);
}
});
}
} | javascript | function race$1(entries) {
/*jshint validthis:true */
var Constructor = this;
if (!isArray(entries)) {
return new Constructor(function (_, reject) {
return reject(new TypeError('You must pass an array to race.'));
});
} else {
return new Constructor(function (resolve, reject) {
var length = entries.length;
for (var i = 0; i < length; i++) {
Constructor.resolve(entries[i]).then(resolve, reject);
}
});
}
} | [
"function",
"race$1",
"(",
"entries",
")",
"{",
"/*jshint validthis:true */",
"var",
"Constructor",
"=",
"this",
";",
"if",
"(",
"!",
"isArray",
"(",
"entries",
")",
")",
"{",
"return",
"new",
"Constructor",
"(",
"function",
"(",
"_",
",",
"reject",
")",
... | `Promise.race` returns a new promise which is settled in the same way as the
first passed promise to settle.
Example:
```javascript
let promise1 = new Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 1');
}, 200);
});
let promise2 = new Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 2');
}, 100);
});
Promise.race([promise1, promise2]).then(function(result){
result === 'promise 2' because it was resolved before promise1
was resolved.
});
```
`Promise.race` is deterministic in that only the state of the first
settled promise matters. For example, even if other promises given to the
`promises` array argument are resolved, but the first settled promise has
become rejected before the other promises became fulfilled, the returned
promise will become rejected:
```javascript
let promise1 = new Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 1');
}, 200);
});
let promise2 = new Promise(function(resolve, reject){
setTimeout(function(){
reject(new Error('promise 2'));
}, 100);
});
Promise.race([promise1, promise2]).then(function(result){
Code here never runs
}, function(reason){
reason.message === 'promise 2' because promise 2 became rejected before
promise 1 became fulfilled
});
```
An example real-world use case is implementing timeouts:
```javascript
Promise.race([ajax('foo.json'), timeout(5000)])
```
@method race
@static
@param {Array} promises array of promises to observe
Useful for tooling.
@return {Promise} a promise which settles in the same way as the first passed
promise to settle. | [
"Promise",
".",
"race",
"returns",
"a",
"new",
"promise",
"which",
"is",
"settled",
"in",
"the",
"same",
"way",
"as",
"the",
"first",
"passed",
"promise",
"to",
"settle",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/app.e653d17f57bebeb097ee.js#L7301-L7317 |
12,507 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | arrayEachRight | function arrayEachRight(array, iteratee) {
var length = array == null ? 0 : array.length;
while (length--) {
if (iteratee(array[length], length, array) === false) {
break;
}
}
return array;
} | javascript | function arrayEachRight(array, iteratee) {
var length = array == null ? 0 : array.length;
while (length--) {
if (iteratee(array[length], length, array) === false) {
break;
}
}
return array;
} | [
"function",
"arrayEachRight",
"(",
"array",
",",
"iteratee",
")",
"{",
"var",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
";",
"while",
"(",
"length",
"--",
")",
"{",
"if",
"(",
"iteratee",
"(",
"array",
"[",
"length"... | A specialized version of `_.forEachRight` for arrays without support for
iteratee shorthands.
@private
@param {Array} [array] The array to iterate over.
@param {Function} iteratee The function invoked per iteration.
@returns {Array} Returns `array`. | [
"A",
"specialized",
"version",
"of",
"_",
".",
"forEachRight",
"for",
"arrays",
"without",
"support",
"for",
"iteratee",
"shorthands",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L660-L669 |
12,508 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | arrayEvery | function arrayEvery(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (!predicate(array[index], index, array)) {
return false;
}
}
return true;
} | javascript | function arrayEvery(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (!predicate(array[index], index, array)) {
return false;
}
}
return true;
} | [
"function",
"arrayEvery",
"(",
"array",
",",
"predicate",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"if",
... | A specialized version of `_.every` for arrays without support for
iteratee shorthands.
@private
@param {Array} [array] The array to iterate over.
@param {Function} predicate The function invoked per iteration.
@returns {boolean} Returns `true` if all elements pass the predicate check,
else `false`. | [
"A",
"specialized",
"version",
"of",
"_",
".",
"every",
"for",
"arrays",
"without",
"support",
"for",
"iteratee",
"shorthands",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L681-L691 |
12,509 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseFindKey | function baseFindKey(collection, predicate, eachFunc) {
var result;
eachFunc(collection, function(value, key, collection) {
if (predicate(value, key, collection)) {
result = key;
return false;
}
});
return result;
} | javascript | function baseFindKey(collection, predicate, eachFunc) {
var result;
eachFunc(collection, function(value, key, collection) {
if (predicate(value, key, collection)) {
result = key;
return false;
}
});
return result;
} | [
"function",
"baseFindKey",
"(",
"collection",
",",
"predicate",
",",
"eachFunc",
")",
"{",
"var",
"result",
";",
"eachFunc",
"(",
"collection",
",",
"function",
"(",
"value",
",",
"key",
",",
"collection",
")",
"{",
"if",
"(",
"predicate",
"(",
"value",
... | The base implementation of methods like `_.findKey` and `_.findLastKey`,
without support for iteratee shorthands, which iterates over `collection`
using `eachFunc`.
@private
@param {Array|Object} collection The collection to inspect.
@param {Function} predicate The function invoked per iteration.
@param {Function} eachFunc The function to iterate over `collection`.
@returns {*} Returns the found element or its key, else `undefined`. | [
"The",
"base",
"implementation",
"of",
"methods",
"like",
"_",
".",
"findKey",
"and",
"_",
".",
"findLastKey",
"without",
"support",
"for",
"iteratee",
"shorthands",
"which",
"iterates",
"over",
"collection",
"using",
"eachFunc",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L903-L912 |
12,510 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseIndexOfWith | function baseIndexOfWith(array, value, fromIndex, comparator) {
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (comparator(array[index], value)) {
return index;
}
}
return -1;
} | javascript | function baseIndexOfWith(array, value, fromIndex, comparator) {
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (comparator(array[index], value)) {
return index;
}
}
return -1;
} | [
"function",
"baseIndexOfWith",
"(",
"array",
",",
"value",
",",
"fromIndex",
",",
"comparator",
")",
"{",
"var",
"index",
"=",
"fromIndex",
"-",
"1",
",",
"length",
"=",
"array",
".",
"length",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",... | This function is like `baseIndexOf` except that it accepts a comparator.
@private
@param {Array} array The array to inspect.
@param {*} value The value to search for.
@param {number} fromIndex The index to search from.
@param {Function} comparator The comparator invoked per element.
@returns {number} Returns the index of the matched value, else `-1`. | [
"This",
"function",
"is",
"like",
"baseIndexOf",
"except",
"that",
"it",
"accepts",
"a",
"comparator",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L962-L972 |
12,511 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | charsStartIndex | function charsStartIndex(strSymbols, chrSymbols) {
var index = -1,
length = strSymbols.length;
while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
} | javascript | function charsStartIndex(strSymbols, chrSymbols) {
var index = -1,
length = strSymbols.length;
while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
} | [
"function",
"charsStartIndex",
"(",
"strSymbols",
",",
"chrSymbols",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"strSymbols",
".",
"length",
";",
"while",
"(",
"++",
"index",
"<",
"length",
"&&",
"baseIndexOf",
"(",
"chrSymbols",
",",
"... | Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
that is not found in the character symbols.
@private
@param {Array} strSymbols The string symbols to inspect.
@param {Array} chrSymbols The character symbols to find.
@returns {number} Returns the index of the first unmatched string symbol. | [
"Used",
"by",
"_",
".",
"trim",
"and",
"_",
".",
"trimStart",
"to",
"get",
"the",
"index",
"of",
"the",
"first",
"string",
"symbol",
"that",
"is",
"not",
"found",
"in",
"the",
"character",
"symbols",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L1174-L1180 |
12,512 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | charsEndIndex | function charsEndIndex(strSymbols, chrSymbols) {
var index = strSymbols.length;
while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
} | javascript | function charsEndIndex(strSymbols, chrSymbols) {
var index = strSymbols.length;
while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
} | [
"function",
"charsEndIndex",
"(",
"strSymbols",
",",
"chrSymbols",
")",
"{",
"var",
"index",
"=",
"strSymbols",
".",
"length",
";",
"while",
"(",
"index",
"--",
"&&",
"baseIndexOf",
"(",
"chrSymbols",
",",
"strSymbols",
"[",
"index",
"]",
",",
"0",
")",
... | Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
that is not found in the character symbols.
@private
@param {Array} strSymbols The string symbols to inspect.
@param {Array} chrSymbols The character symbols to find.
@returns {number} Returns the index of the last unmatched string symbol. | [
"Used",
"by",
"_",
".",
"trim",
"and",
"_",
".",
"trimEnd",
"to",
"get",
"the",
"index",
"of",
"the",
"last",
"string",
"symbol",
"that",
"is",
"not",
"found",
"in",
"the",
"character",
"symbols",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L1191-L1196 |
12,513 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | setToPairs | function setToPairs(set) {
var index = -1,
result = Array(set.size);
set.forEach(function(value) {
result[++index] = [value, value];
});
return result;
} | javascript | function setToPairs(set) {
var index = -1,
result = Array(set.size);
set.forEach(function(value) {
result[++index] = [value, value];
});
return result;
} | [
"function",
"setToPairs",
"(",
"set",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"result",
"=",
"Array",
"(",
"set",
".",
"size",
")",
";",
"set",
".",
"forEach",
"(",
"function",
"(",
"value",
")",
"{",
"result",
"[",
"++",
"index",
"]",
"=",... | Converts `set` to its value-value pairs.
@private
@param {Object} set The set to convert.
@returns {Array} Returns the value-value pairs. | [
"Converts",
"set",
"to",
"its",
"value",
"-",
"value",
"pairs",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L1379-L1387 |
12,514 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | lazyClone | function lazyClone() {
var result = new LazyWrapper(this.__wrapped__);
result.__actions__ = copyArray(this.__actions__);
result.__dir__ = this.__dir__;
result.__filtered__ = this.__filtered__;
result.__iteratees__ = copyArray(this.__iteratees__);
result.__takeCount__ = this.__takeCount__;
result.__views__ = copyArray(this.__views__);
return result;
} | javascript | function lazyClone() {
var result = new LazyWrapper(this.__wrapped__);
result.__actions__ = copyArray(this.__actions__);
result.__dir__ = this.__dir__;
result.__filtered__ = this.__filtered__;
result.__iteratees__ = copyArray(this.__iteratees__);
result.__takeCount__ = this.__takeCount__;
result.__views__ = copyArray(this.__views__);
return result;
} | [
"function",
"lazyClone",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"LazyWrapper",
"(",
"this",
".",
"__wrapped__",
")",
";",
"result",
".",
"__actions__",
"=",
"copyArray",
"(",
"this",
".",
"__actions__",
")",
";",
"result",
".",
"__dir__",
"=",
"this... | Creates a clone of the lazy wrapper object.
@private
@name clone
@memberOf LazyWrapper
@returns {Object} Returns the cloned `LazyWrapper` object. | [
"Creates",
"a",
"clone",
"of",
"the",
"lazy",
"wrapper",
"object",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L1931-L1940 |
12,515 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | arraySampleSize | function arraySampleSize(array, n) {
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
} | javascript | function arraySampleSize(array, n) {
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
} | [
"function",
"arraySampleSize",
"(",
"array",
",",
"n",
")",
"{",
"return",
"shuffleSelf",
"(",
"copyArray",
"(",
"array",
")",
",",
"baseClamp",
"(",
"n",
",",
"0",
",",
"array",
".",
"length",
")",
")",
";",
"}"
] | A specialized version of `_.sampleSize` for arrays.
@private
@param {Array} array The array to sample.
@param {number} n The number of elements to sample.
@returns {Array} Returns the random elements. | [
"A",
"specialized",
"version",
"of",
"_",
".",
"sampleSize",
"for",
"arrays",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L2558-L2560 |
12,516 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseConforms | function baseConforms(source) {
var props = keys(source);
return function(object) {
return baseConformsTo(object, source, props);
};
} | javascript | function baseConforms(source) {
var props = keys(source);
return function(object) {
return baseConformsTo(object, source, props);
};
} | [
"function",
"baseConforms",
"(",
"source",
")",
"{",
"var",
"props",
"=",
"keys",
"(",
"source",
")",
";",
"return",
"function",
"(",
"object",
")",
"{",
"return",
"baseConformsTo",
"(",
"object",
",",
"source",
",",
"props",
")",
";",
"}",
";",
"}"
] | The base implementation of `_.conforms` which doesn't clone `source`.
@private
@param {Object} source The object of property predicates to conform to.
@returns {Function} Returns the new spec function. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"conforms",
"which",
"doesn",
"t",
"clone",
"source",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L2821-L2826 |
12,517 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseConformsTo | function baseConformsTo(object, source, props) {
var length = props.length;
if (object == null) {
return !length;
}
object = Object(object);
while (length--) {
var key = props[length],
predicate = source[key],
value = object[key];
if ((value === undefined && !(key in object)) || !predicate(value)) {
return false;
}
}
return true;
} | javascript | function baseConformsTo(object, source, props) {
var length = props.length;
if (object == null) {
return !length;
}
object = Object(object);
while (length--) {
var key = props[length],
predicate = source[key],
value = object[key];
if ((value === undefined && !(key in object)) || !predicate(value)) {
return false;
}
}
return true;
} | [
"function",
"baseConformsTo",
"(",
"object",
",",
"source",
",",
"props",
")",
"{",
"var",
"length",
"=",
"props",
".",
"length",
";",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"!",
"length",
";",
"}",
"object",
"=",
"Object",
"(",
"obje... | The base implementation of `_.conformsTo` which accepts `props` to check.
@private
@param {Object} object The object to inspect.
@param {Object} source The object of property predicates to conform to.
@returns {boolean} Returns `true` if `object` conforms, else `false`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"conformsTo",
"which",
"accepts",
"props",
"to",
"check",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L2836-L2852 |
12,518 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseFill | function baseFill(array, value, start, end) {
var length = array.length;
start = toInteger(start);
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = (end === undefined || end > length) ? length : toInteger(end);
if (end < 0) {
end += length;
}
end = start > end ? 0 : toLength(end);
while (start < end) {
array[start++] = value;
}
return array;
} | javascript | function baseFill(array, value, start, end) {
var length = array.length;
start = toInteger(start);
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = (end === undefined || end > length) ? length : toInteger(end);
if (end < 0) {
end += length;
}
end = start > end ? 0 : toLength(end);
while (start < end) {
array[start++] = value;
}
return array;
} | [
"function",
"baseFill",
"(",
"array",
",",
"value",
",",
"start",
",",
"end",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
";",
"start",
"=",
"toInteger",
"(",
"start",
")",
";",
"if",
"(",
"start",
"<",
"0",
")",
"{",
"start",
"=",
"-... | The base implementation of `_.fill` without an iteratee call guard.
@private
@param {Array} array The array to fill.
@param {*} value The value to fill `array` with.
@param {number} [start=0] The start position.
@param {number} [end=array.length] The end position.
@returns {Array} Returns `array`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"fill",
"without",
"an",
"iteratee",
"call",
"guard",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L3004-L3020 |
12,519 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseInverter | function baseInverter(object, setter, iteratee, accumulator) {
baseForOwn(object, function(value, key, object) {
setter(accumulator, iteratee(value), key, object);
});
return accumulator;
} | javascript | function baseInverter(object, setter, iteratee, accumulator) {
baseForOwn(object, function(value, key, object) {
setter(accumulator, iteratee(value), key, object);
});
return accumulator;
} | [
"function",
"baseInverter",
"(",
"object",
",",
"setter",
",",
"iteratee",
",",
"accumulator",
")",
"{",
"baseForOwn",
"(",
"object",
",",
"function",
"(",
"value",
",",
"key",
",",
"object",
")",
"{",
"setter",
"(",
"accumulator",
",",
"iteratee",
"(",
... | The base implementation of `_.invert` and `_.invertBy` which inverts
`object` with values transformed by `iteratee` and set by `setter`.
@private
@param {Object} object The object to iterate over.
@param {Function} setter The function to set `accumulator` values.
@param {Function} iteratee The iteratee to transform values.
@param {Object} accumulator The initial inverted object.
@returns {Function} Returns `accumulator`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"invert",
"and",
"_",
".",
"invertBy",
"which",
"inverts",
"object",
"with",
"values",
"transformed",
"by",
"iteratee",
"and",
"set",
"by",
"setter",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L3314-L3319 |
12,520 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | basePullAt | function basePullAt(array, indexes) {
var length = array ? indexes.length : 0,
lastIndex = length - 1;
while (length--) {
var index = indexes[length];
if (length == lastIndex || index !== previous) {
var previous = index;
if (isIndex(index)) {
splice.call(array, index, 1);
} else {
baseUnset(array, index);
}
}
}
return array;
} | javascript | function basePullAt(array, indexes) {
var length = array ? indexes.length : 0,
lastIndex = length - 1;
while (length--) {
var index = indexes[length];
if (length == lastIndex || index !== previous) {
var previous = index;
if (isIndex(index)) {
splice.call(array, index, 1);
} else {
baseUnset(array, index);
}
}
}
return array;
} | [
"function",
"basePullAt",
"(",
"array",
",",
"indexes",
")",
"{",
"var",
"length",
"=",
"array",
"?",
"indexes",
".",
"length",
":",
"0",
",",
"lastIndex",
"=",
"length",
"-",
"1",
";",
"while",
"(",
"length",
"--",
")",
"{",
"var",
"index",
"=",
"... | The base implementation of `_.pullAt` without support for individual
indexes or capturing the removed elements.
@private
@param {Array} array The array to modify.
@param {number[]} indexes The indexes of elements to remove.
@returns {Array} Returns `array`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"pullAt",
"without",
"support",
"for",
"individual",
"indexes",
"or",
"capturing",
"the",
"removed",
"elements",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L3955-L3971 |
12,521 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseRepeat | function baseRepeat(string, n) {
var result = '';
if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
return result;
}
// Leverage the exponentiation by squaring algorithm for a faster repeat.
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
do {
if (n % 2) {
result += string;
}
n = nativeFloor(n / 2);
if (n) {
string += string;
}
} while (n);
return result;
} | javascript | function baseRepeat(string, n) {
var result = '';
if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
return result;
}
// Leverage the exponentiation by squaring algorithm for a faster repeat.
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
do {
if (n % 2) {
result += string;
}
n = nativeFloor(n / 2);
if (n) {
string += string;
}
} while (n);
return result;
} | [
"function",
"baseRepeat",
"(",
"string",
",",
"n",
")",
"{",
"var",
"result",
"=",
"''",
";",
"if",
"(",
"!",
"string",
"||",
"n",
"<",
"1",
"||",
"n",
">",
"MAX_SAFE_INTEGER",
")",
"{",
"return",
"result",
";",
"}",
"// Leverage the exponentiation by sq... | The base implementation of `_.repeat` which doesn't coerce arguments.
@private
@param {string} string The string to repeat.
@param {number} n The number of times to repeat the string.
@returns {string} Returns the repeated string. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"repeat",
"which",
"doesn",
"t",
"coerce",
"arguments",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L4017-L4035 |
12,522 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseSampleSize | function baseSampleSize(collection, n) {
var array = values(collection);
return shuffleSelf(array, baseClamp(n, 0, array.length));
} | javascript | function baseSampleSize(collection, n) {
var array = values(collection);
return shuffleSelf(array, baseClamp(n, 0, array.length));
} | [
"function",
"baseSampleSize",
"(",
"collection",
",",
"n",
")",
"{",
"var",
"array",
"=",
"values",
"(",
"collection",
")",
";",
"return",
"shuffleSelf",
"(",
"array",
",",
"baseClamp",
"(",
"n",
",",
"0",
",",
"array",
".",
"length",
")",
")",
";",
... | The base implementation of `_.sampleSize` without param guards.
@private
@param {Array|Object} collection The collection to sample.
@param {number} n The number of elements to sample.
@returns {Array} Returns the random elements. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"sampleSize",
"without",
"param",
"guards",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L4068-L4071 |
12,523 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseSortedIndex | function baseSortedIndex(array, value, retHighest) {
var low = 0,
high = array == null ? low : array.length;
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
while (low < high) {
var mid = (low + high) >>> 1,
computed = array[mid];
if (computed !== null && !isSymbol(computed) &&
(retHighest ? (computed <= value) : (computed < value))) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
return baseSortedIndexBy(array, value, identity, retHighest);
} | javascript | function baseSortedIndex(array, value, retHighest) {
var low = 0,
high = array == null ? low : array.length;
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
while (low < high) {
var mid = (low + high) >>> 1,
computed = array[mid];
if (computed !== null && !isSymbol(computed) &&
(retHighest ? (computed <= value) : (computed < value))) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
return baseSortedIndexBy(array, value, identity, retHighest);
} | [
"function",
"baseSortedIndex",
"(",
"array",
",",
"value",
",",
"retHighest",
")",
"{",
"var",
"low",
"=",
"0",
",",
"high",
"=",
"array",
"==",
"null",
"?",
"low",
":",
"array",
".",
"length",
";",
"if",
"(",
"typeof",
"value",
"==",
"'number'",
"&&... | The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
performs a binary search of `array` to determine the index at which `value`
should be inserted into `array` in order to maintain its sort order.
@private
@param {Array} array The sorted array to inspect.
@param {*} value The value to evaluate.
@param {boolean} [retHighest] Specify returning the highest qualified index.
@returns {number} Returns the index at which `value` should be inserted
into `array`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"sortedIndex",
"and",
"_",
".",
"sortedLastIndex",
"which",
"performs",
"a",
"binary",
"search",
"of",
"array",
"to",
"determine",
"the",
"index",
"at",
"which",
"value",
"should",
"be",
"inserted",
"into",
"a... | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L4215-L4234 |
12,524 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | baseUpdate | function baseUpdate(object, path, updater, customizer) {
return baseSet(object, path, updater(baseGet(object, path)), customizer);
} | javascript | function baseUpdate(object, path, updater, customizer) {
return baseSet(object, path, updater(baseGet(object, path)), customizer);
} | [
"function",
"baseUpdate",
"(",
"object",
",",
"path",
",",
"updater",
",",
"customizer",
")",
"{",
"return",
"baseSet",
"(",
"object",
",",
"path",
",",
"updater",
"(",
"baseGet",
"(",
"object",
",",
"path",
")",
")",
",",
"customizer",
")",
";",
"}"
] | The base implementation of `_.update`.
@private
@param {Object} object The object to modify.
@param {Array|string} path The path of the property to update.
@param {Function} updater The function to produce the updated value.
@param {Function} [customizer] The function to customize path creation.
@returns {Object} Returns `object`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"update",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L4443-L4445 |
12,525 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | createBind | function createBind(func, bitmask, thisArg) {
var isBind = bitmask & WRAP_BIND_FLAG,
Ctor = createCtor(func);
function wrapper() {
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return fn.apply(isBind ? thisArg : this, arguments);
}
return wrapper;
} | javascript | function createBind(func, bitmask, thisArg) {
var isBind = bitmask & WRAP_BIND_FLAG,
Ctor = createCtor(func);
function wrapper() {
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return fn.apply(isBind ? thisArg : this, arguments);
}
return wrapper;
} | [
"function",
"createBind",
"(",
"func",
",",
"bitmask",
",",
"thisArg",
")",
"{",
"var",
"isBind",
"=",
"bitmask",
"&",
"WRAP_BIND_FLAG",
",",
"Ctor",
"=",
"createCtor",
"(",
"func",
")",
";",
"function",
"wrapper",
"(",
")",
"{",
"var",
"fn",
"=",
"(",... | Creates a function that wraps `func` to invoke it with the optional `this`
binding of `thisArg`.
@private
@param {Function} func The function to wrap.
@param {number} bitmask The bitmask flags. See `createWrap` for more details.
@param {*} [thisArg] The `this` binding of `func`.
@returns {Function} Returns the new wrapped function. | [
"Creates",
"a",
"function",
"that",
"wraps",
"func",
"to",
"invoke",
"it",
"with",
"the",
"optional",
"this",
"binding",
"of",
"thisArg",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L5069-L5078 |
12,526 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | createRelationalOperation | function createRelationalOperation(operator) {
return function(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) {
value = toNumber(value);
other = toNumber(other);
}
return operator(value, other);
};
} | javascript | function createRelationalOperation(operator) {
return function(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) {
value = toNumber(value);
other = toNumber(other);
}
return operator(value, other);
};
} | [
"function",
"createRelationalOperation",
"(",
"operator",
")",
"{",
"return",
"function",
"(",
"value",
",",
"other",
")",
"{",
"if",
"(",
"!",
"(",
"typeof",
"value",
"==",
"'string'",
"&&",
"typeof",
"other",
"==",
"'string'",
")",
")",
"{",
"value",
"... | Creates a function that performs a relational operation on two values.
@private
@param {Function} operator The function to perform the operation.
@returns {Function} Returns the new relational operation function. | [
"Creates",
"a",
"function",
"that",
"performs",
"a",
"relational",
"operation",
"on",
"two",
"values",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L5500-L5508 |
12,527 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | customDefaultsAssignIn | function customDefaultsAssignIn(objValue, srcValue, key, object) {
if (objValue === undefined ||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
return srcValue;
}
return objValue;
} | javascript | function customDefaultsAssignIn(objValue, srcValue, key, object) {
if (objValue === undefined ||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
return srcValue;
}
return objValue;
} | [
"function",
"customDefaultsAssignIn",
"(",
"objValue",
",",
"srcValue",
",",
"key",
",",
"object",
")",
"{",
"if",
"(",
"objValue",
"===",
"undefined",
"||",
"(",
"eq",
"(",
"objValue",
",",
"objectProto",
"[",
"key",
"]",
")",
"&&",
"!",
"hasOwnProperty",... | Used by `_.defaults` to customize its `_.assignIn` use to assign properties
of source objects to the destination object for all destination properties
that resolve to `undefined`.
@private
@param {*} objValue The destination value.
@param {*} srcValue The source value.
@param {string} key The key of the property to assign.
@param {Object} object The parent object of `objValue`.
@returns {*} Returns the value to assign. | [
"Used",
"by",
"_",
".",
"defaults",
"to",
"customize",
"its",
"_",
".",
"assignIn",
"use",
"to",
"assign",
"properties",
"of",
"source",
"objects",
"to",
"the",
"destination",
"object",
"for",
"all",
"destination",
"properties",
"that",
"resolve",
"to",
"und... | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L5701-L5707 |
12,528 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | getFuncName | function getFuncName(func) {
var result = (func.name + ''),
array = realNames[result],
length = hasOwnProperty.call(realNames, result) ? array.length : 0;
while (length--) {
var data = array[length],
otherFunc = data.func;
if (otherFunc == null || otherFunc == func) {
return data.name;
}
}
return result;
} | javascript | function getFuncName(func) {
var result = (func.name + ''),
array = realNames[result],
length = hasOwnProperty.call(realNames, result) ? array.length : 0;
while (length--) {
var data = array[length],
otherFunc = data.func;
if (otherFunc == null || otherFunc == func) {
return data.name;
}
}
return result;
} | [
"function",
"getFuncName",
"(",
"func",
")",
"{",
"var",
"result",
"=",
"(",
"func",
".",
"name",
"+",
"''",
")",
",",
"array",
"=",
"realNames",
"[",
"result",
"]",
",",
"length",
"=",
"hasOwnProperty",
".",
"call",
"(",
"realNames",
",",
"result",
... | Gets the name of `func`.
@private
@param {Function} func The function to query.
@returns {string} Returns the function name. | [
"Gets",
"the",
"name",
"of",
"func",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L6031-L6044 |
12,529 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | getWrapDetails | function getWrapDetails(source) {
var match = source.match(reWrapDetails);
return match ? match[1].split(reSplitDetails) : [];
} | javascript | function getWrapDetails(source) {
var match = source.match(reWrapDetails);
return match ? match[1].split(reSplitDetails) : [];
} | [
"function",
"getWrapDetails",
"(",
"source",
")",
"{",
"var",
"match",
"=",
"source",
".",
"match",
"(",
"reWrapDetails",
")",
";",
"return",
"match",
"?",
"match",
"[",
"1",
"]",
".",
"split",
"(",
"reSplitDetails",
")",
":",
"[",
"]",
";",
"}"
] | Extracts wrapper details from the `source` body comment.
@private
@param {string} source The source to inspect.
@returns {Array} Returns the wrapper details. | [
"Extracts",
"wrapper",
"details",
"from",
"the",
"source",
"body",
"comment",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L6251-L6254 |
12,530 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | setWrapToString | function setWrapToString(wrapper, reference, bitmask) {
var source = (reference + '');
return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
} | javascript | function setWrapToString(wrapper, reference, bitmask) {
var source = (reference + '');
return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
} | [
"function",
"setWrapToString",
"(",
"wrapper",
",",
"reference",
",",
"bitmask",
")",
"{",
"var",
"source",
"=",
"(",
"reference",
"+",
"''",
")",
";",
"return",
"setToString",
"(",
"wrapper",
",",
"insertWrapDetails",
"(",
"source",
",",
"updateWrapDetails",
... | Sets the `toString` method of `wrapper` to mimic the source of `reference`
with wrapper details in a comment at the top of the source body.
@private
@param {Function} wrapper The function to modify.
@param {Function} reference The reference function.
@param {number} bitmask The bitmask flags. See `createWrap` for more details.
@returns {Function} Returns `wrapper`. | [
"Sets",
"the",
"toString",
"method",
"of",
"wrapper",
"to",
"mimic",
"the",
"source",
"of",
"reference",
"with",
"wrapper",
"details",
"in",
"a",
"comment",
"at",
"the",
"top",
"of",
"the",
"source",
"body",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L6793-L6796 |
12,531 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | wrapperClone | function wrapperClone(wrapper) {
if (wrapper instanceof LazyWrapper) {
return wrapper.clone();
}
var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
result.__actions__ = copyArray(wrapper.__actions__);
result.__index__ = wrapper.__index__;
result.__values__ = wrapper.__values__;
return result;
} | javascript | function wrapperClone(wrapper) {
if (wrapper instanceof LazyWrapper) {
return wrapper.clone();
}
var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
result.__actions__ = copyArray(wrapper.__actions__);
result.__index__ = wrapper.__index__;
result.__values__ = wrapper.__values__;
return result;
} | [
"function",
"wrapperClone",
"(",
"wrapper",
")",
"{",
"if",
"(",
"wrapper",
"instanceof",
"LazyWrapper",
")",
"{",
"return",
"wrapper",
".",
"clone",
"(",
")",
";",
"}",
"var",
"result",
"=",
"new",
"LodashWrapper",
"(",
"wrapper",
".",
"__wrapped__",
",",... | Creates a clone of `wrapper`.
@private
@param {Object} wrapper The wrapper to clone.
@returns {Object} Returns the cloned wrapper. | [
"Creates",
"a",
"clone",
"of",
"wrapper",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L6929-L6938 |
12,532 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | dropRight | function dropRight(array, n, guard) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
n = (guard || n === undefined) ? 1 : toInteger(n);
n = length - n;
return baseSlice(array, 0, n < 0 ? 0 : n);
} | javascript | function dropRight(array, n, guard) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
n = (guard || n === undefined) ? 1 : toInteger(n);
n = length - n;
return baseSlice(array, 0, n < 0 ? 0 : n);
} | [
"function",
"dropRight",
"(",
"array",
",",
"n",
",",
"guard",
")",
"{",
"var",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
";",
"if",
"(",
"!",
"length",
")",
"{",
"return",
"[",
"]",
";",
"}",
"n",
"=",
"(",
... | Creates a slice of `array` with `n` elements dropped from the end.
@static
@memberOf _
@since 3.0.0
@category Array
@param {Array} array The array to query.
@param {number} [n=1] The number of elements to drop.
@param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
@returns {Array} Returns the slice of `array`.
@example
_.dropRight([1, 2, 3]);
// => [1, 2]
_.dropRight([1, 2, 3], 2);
// => [1]
_.dropRight([1, 2, 3], 5);
// => []
_.dropRight([1, 2, 3], 0);
// => [1, 2, 3] | [
"Creates",
"a",
"slice",
"of",
"array",
"with",
"n",
"elements",
"dropped",
"from",
"the",
"end",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L7205-L7213 |
12,533 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | findIndex | function findIndex(array, predicate, fromIndex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = fromIndex == null ? 0 : toInteger(fromIndex);
if (index < 0) {
index = nativeMax(length + index, 0);
}
return baseFindIndex(array, getIteratee(predicate, 3), index);
} | javascript | function findIndex(array, predicate, fromIndex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = fromIndex == null ? 0 : toInteger(fromIndex);
if (index < 0) {
index = nativeMax(length + index, 0);
}
return baseFindIndex(array, getIteratee(predicate, 3), index);
} | [
"function",
"findIndex",
"(",
"array",
",",
"predicate",
",",
"fromIndex",
")",
"{",
"var",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
";",
"if",
"(",
"!",
"length",
")",
"{",
"return",
"-",
"1",
";",
"}",
"var",
... | This method is like `_.find` except that it returns the index of the first
element `predicate` returns truthy for instead of the element itself.
@static
@memberOf _
@since 1.1.0
@category Array
@param {Array} array The array to inspect.
@param {Function} [predicate=_.identity] The function invoked per iteration.
@param {number} [fromIndex=0] The index to search from.
@returns {number} Returns the index of the found element, else `-1`.
@example
var users = [
{ 'user': 'barney', 'active': false },
{ 'user': 'fred', 'active': false },
{ 'user': 'pebbles', 'active': true }
];
_.findIndex(users, function(o) { return o.user == 'barney'; });
// => 0
// The `_.matches` iteratee shorthand.
_.findIndex(users, { 'user': 'fred', 'active': false });
// => 1
// The `_.matchesProperty` iteratee shorthand.
_.findIndex(users, ['active', false]);
// => 0
// The `_.property` iteratee shorthand.
_.findIndex(users, 'active');
// => 2 | [
"This",
"method",
"is",
"like",
"_",
".",
"find",
"except",
"that",
"it",
"returns",
"the",
"index",
"of",
"the",
"first",
"element",
"predicate",
"returns",
"truthy",
"for",
"instead",
"of",
"the",
"element",
"itself",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L7373-L7383 |
12,534 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | flattenDeep | function flattenDeep(array) {
var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, INFINITY) : [];
} | javascript | function flattenDeep(array) {
var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, INFINITY) : [];
} | [
"function",
"flattenDeep",
"(",
"array",
")",
"{",
"var",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
";",
"return",
"length",
"?",
"baseFlatten",
"(",
"array",
",",
"INFINITY",
")",
":",
"[",
"]",
";",
"}"
] | Recursively flattens `array`.
@static
@memberOf _
@since 3.0.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flattenDeep([1, [2, [3, [4]], 5]]);
// => [1, 2, 3, 4, 5] | [
"Recursively",
"flattens",
"array",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L7468-L7471 |
12,535 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | fromPairs | function fromPairs(pairs) {
var index = -1,
length = pairs == null ? 0 : pairs.length,
result = {};
while (++index < length) {
var pair = pairs[index];
result[pair[0]] = pair[1];
}
return result;
} | javascript | function fromPairs(pairs) {
var index = -1,
length = pairs == null ? 0 : pairs.length,
result = {};
while (++index < length) {
var pair = pairs[index];
result[pair[0]] = pair[1];
}
return result;
} | [
"function",
"fromPairs",
"(",
"pairs",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"pairs",
"==",
"null",
"?",
"0",
":",
"pairs",
".",
"length",
",",
"result",
"=",
"{",
"}",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
... | The inverse of `_.toPairs`; this method returns an object composed
from key-value `pairs`.
@static
@memberOf _
@since 4.0.0
@category Array
@param {Array} pairs The key-value pairs.
@returns {Object} Returns the new object.
@example
_.fromPairs([['a', 1], ['b', 2]]);
// => { 'a': 1, 'b': 2 } | [
"The",
"inverse",
"of",
"_",
".",
"toPairs",
";",
"this",
"method",
"returns",
"an",
"object",
"composed",
"from",
"key",
"-",
"value",
"pairs",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L7517-L7527 |
12,536 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | initial | function initial(array) {
var length = array == null ? 0 : array.length;
return length ? baseSlice(array, 0, -1) : [];
} | javascript | function initial(array) {
var length = array == null ? 0 : array.length;
return length ? baseSlice(array, 0, -1) : [];
} | [
"function",
"initial",
"(",
"array",
")",
"{",
"var",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
";",
"return",
"length",
"?",
"baseSlice",
"(",
"array",
",",
"0",
",",
"-",
"1",
")",
":",
"[",
"]",
";",
"}"
] | Gets all but the last element of `array`.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to query.
@returns {Array} Returns the slice of `array`.
@example
_.initial([1, 2, 3]);
// => [1, 2] | [
"Gets",
"all",
"but",
"the",
"last",
"element",
"of",
"array",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L7600-L7603 |
12,537 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | sortedIndexOf | function sortedIndexOf(array, value) {
var length = array == null ? 0 : array.length;
if (length) {
var index = baseSortedIndex(array, value);
if (index < length && eq(array[index], value)) {
return index;
}
}
return -1;
} | javascript | function sortedIndexOf(array, value) {
var length = array == null ? 0 : array.length;
if (length) {
var index = baseSortedIndex(array, value);
if (index < length && eq(array[index], value)) {
return index;
}
}
return -1;
} | [
"function",
"sortedIndexOf",
"(",
"array",
",",
"value",
")",
"{",
"var",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
";",
"if",
"(",
"length",
")",
"{",
"var",
"index",
"=",
"baseSortedIndex",
"(",
"array",
",",
"val... | This method is like `_.indexOf` except that it performs a binary
search on a sorted `array`.
@static
@memberOf _
@since 4.0.0
@category Array
@param {Array} array The array to inspect.
@param {*} value The value to search for.
@returns {number} Returns the index of the matched value, else `-1`.
@example
_.sortedIndexOf([4, 5, 5, 5, 6], 5);
// => 1 | [
"This",
"method",
"is",
"like",
"_",
".",
"indexOf",
"except",
"that",
"it",
"performs",
"a",
"binary",
"search",
"on",
"a",
"sorted",
"array",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L8117-L8126 |
12,538 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | sortedUniqBy | function sortedUniqBy(array, iteratee) {
return (array && array.length)
? baseSortedUniq(array, getIteratee(iteratee, 2))
: [];
} | javascript | function sortedUniqBy(array, iteratee) {
return (array && array.length)
? baseSortedUniq(array, getIteratee(iteratee, 2))
: [];
} | [
"function",
"sortedUniqBy",
"(",
"array",
",",
"iteratee",
")",
"{",
"return",
"(",
"array",
"&&",
"array",
".",
"length",
")",
"?",
"baseSortedUniq",
"(",
"array",
",",
"getIteratee",
"(",
"iteratee",
",",
"2",
")",
")",
":",
"[",
"]",
";",
"}"
] | This method is like `_.uniqBy` except that it's designed and optimized
for sorted arrays.
@static
@memberOf _
@since 4.0.0
@category Array
@param {Array} array The array to inspect.
@param {Function} [iteratee] The iteratee invoked per element.
@returns {Array} Returns the new duplicate free array.
@example
_.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
// => [1.1, 2.3] | [
"This",
"method",
"is",
"like",
"_",
".",
"uniqBy",
"except",
"that",
"it",
"s",
"designed",
"and",
"optimized",
"for",
"sorted",
"arrays",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L8243-L8247 |
12,539 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | unzip | function unzip(array) {
if (!(array && array.length)) {
return [];
}
var length = 0;
array = arrayFilter(array, function(group) {
if (isArrayLikeObject(group)) {
length = nativeMax(group.length, length);
return true;
}
});
return baseTimes(length, function(index) {
return arrayMap(array, baseProperty(index));
});
} | javascript | function unzip(array) {
if (!(array && array.length)) {
return [];
}
var length = 0;
array = arrayFilter(array, function(group) {
if (isArrayLikeObject(group)) {
length = nativeMax(group.length, length);
return true;
}
});
return baseTimes(length, function(index) {
return arrayMap(array, baseProperty(index));
});
} | [
"function",
"unzip",
"(",
"array",
")",
"{",
"if",
"(",
"!",
"(",
"array",
"&&",
"array",
".",
"length",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"var",
"length",
"=",
"0",
";",
"array",
"=",
"arrayFilter",
"(",
"array",
",",
"function",
"(",... | This method is like `_.zip` except that it accepts an array of grouped
elements and creates an array regrouping the elements to their pre-zip
configuration.
@static
@memberOf _
@since 1.2.0
@category Array
@param {Array} array The array of grouped elements to process.
@returns {Array} Returns the new array of regrouped elements.
@example
var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
// => [['a', 1, true], ['b', 2, false]]
_.unzip(zipped);
// => [['a', 'b'], [1, 2], [true, false]] | [
"This",
"method",
"is",
"like",
"_",
".",
"zip",
"except",
"that",
"it",
"accepts",
"an",
"array",
"of",
"grouped",
"elements",
"and",
"creates",
"an",
"array",
"regrouping",
"the",
"elements",
"to",
"their",
"pre",
"-",
"zip",
"configuration",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L8589-L8603 |
12,540 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | forEachRight | function forEachRight(collection, iteratee) {
var func = isArray(collection) ? arrayEachRight : baseEachRight;
return func(collection, getIteratee(iteratee, 3));
} | javascript | function forEachRight(collection, iteratee) {
var func = isArray(collection) ? arrayEachRight : baseEachRight;
return func(collection, getIteratee(iteratee, 3));
} | [
"function",
"forEachRight",
"(",
"collection",
",",
"iteratee",
")",
"{",
"var",
"func",
"=",
"isArray",
"(",
"collection",
")",
"?",
"arrayEachRight",
":",
"baseEachRight",
";",
"return",
"func",
"(",
"collection",
",",
"getIteratee",
"(",
"iteratee",
",",
... | This method is like `_.forEach` except that it iterates over elements of
`collection` from right to left.
@static
@memberOf _
@since 2.0.0
@alias eachRight
@category Collection
@param {Array|Object} collection The collection to iterate over.
@param {Function} [iteratee=_.identity] The function invoked per iteration.
@returns {Array|Object} Returns `collection`.
@see _.forEach
@example
_.forEachRight([1, 2], function(value) {
console.log(value);
});
// => Logs `2` then `1`. | [
"This",
"method",
"is",
"like",
"_",
".",
"forEach",
"except",
"that",
"it",
"iterates",
"over",
"elements",
"of",
"collection",
"from",
"right",
"to",
"left",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L9489-L9492 |
12,541 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | negate | function negate(predicate) {
if (typeof predicate != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
var args = arguments;
switch (args.length) {
case 0: return !predicate.call(this);
case 1: return !predicate.call(this, args[0]);
case 2: return !predicate.call(this, args[0], args[1]);
case 3: return !predicate.call(this, args[0], args[1], args[2]);
}
return !predicate.apply(this, args);
};
} | javascript | function negate(predicate) {
if (typeof predicate != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
var args = arguments;
switch (args.length) {
case 0: return !predicate.call(this);
case 1: return !predicate.call(this, args[0]);
case 2: return !predicate.call(this, args[0], args[1]);
case 3: return !predicate.call(this, args[0], args[1], args[2]);
}
return !predicate.apply(this, args);
};
} | [
"function",
"negate",
"(",
"predicate",
")",
"{",
"if",
"(",
"typeof",
"predicate",
"!=",
"'function'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"FUNC_ERROR_TEXT",
")",
";",
"}",
"return",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
";... | Creates a function that negates the result of the predicate `func`. The
`func` predicate is invoked with the `this` binding and arguments of the
created function.
@static
@memberOf _
@since 3.0.0
@category Function
@param {Function} predicate The predicate to negate.
@returns {Function} Returns the new negated function.
@example
function isEven(n) {
return n % 2 == 0;
}
_.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
// => [1, 3, 5] | [
"Creates",
"a",
"function",
"that",
"negates",
"the",
"result",
"of",
"the",
"predicate",
"func",
".",
"The",
"func",
"predicate",
"is",
"invoked",
"with",
"the",
"this",
"binding",
"and",
"arguments",
"of",
"the",
"created",
"function",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L10704-L10718 |
12,542 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | conformsTo | function conformsTo(object, source) {
return source == null || baseConformsTo(object, source, keys(source));
} | javascript | function conformsTo(object, source) {
return source == null || baseConformsTo(object, source, keys(source));
} | [
"function",
"conformsTo",
"(",
"object",
",",
"source",
")",
"{",
"return",
"source",
"==",
"null",
"||",
"baseConformsTo",
"(",
"object",
",",
"source",
",",
"keys",
"(",
"source",
")",
")",
";",
"}"
] | Checks if `object` conforms to `source` by invoking the predicate
properties of `source` with the corresponding property values of `object`.
**Note:** This method is equivalent to `_.conforms` when `source` is
partially applied.
@static
@memberOf _
@since 4.14.0
@category Lang
@param {Object} object The object to inspect.
@param {Object} source The object of property predicates to conform to.
@returns {boolean} Returns `true` if `object` conforms, else `false`.
@example
var object = { 'a': 1, 'b': 2 };
_.conformsTo(object, { 'b': function(n) { return n > 1; } });
// => true
_.conformsTo(object, { 'b': function(n) { return n > 2; } });
// => false | [
"Checks",
"if",
"object",
"conforms",
"to",
"source",
"by",
"invoking",
"the",
"predicate",
"properties",
"of",
"source",
"with",
"the",
"corresponding",
"property",
"values",
"of",
"object",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L11269-L11271 |
12,543 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | create | function create(prototype, properties) {
var result = baseCreate(prototype);
return properties == null ? result : baseAssign(result, properties);
} | javascript | function create(prototype, properties) {
var result = baseCreate(prototype);
return properties == null ? result : baseAssign(result, properties);
} | [
"function",
"create",
"(",
"prototype",
",",
"properties",
")",
"{",
"var",
"result",
"=",
"baseCreate",
"(",
"prototype",
")",
";",
"return",
"properties",
"==",
"null",
"?",
"result",
":",
"baseAssign",
"(",
"result",
",",
"properties",
")",
";",
"}"
] | Creates an object that inherits from the `prototype` object. If a
`properties` object is given, its own enumerable string keyed properties
are assigned to the created object.
@static
@memberOf _
@since 2.3.0
@category Object
@param {Object} prototype The object to inherit from.
@param {Object} [properties] The properties to assign to the object.
@returns {Object} Returns the new object.
@example
function Shape() {
this.x = 0;
this.y = 0;
}
function Circle() {
Shape.call(this);
}
Circle.prototype = _.create(Shape.prototype, {
'constructor': Circle
});
var circle = new Circle;
circle instanceof Circle;
// => true
circle instanceof Shape;
// => true | [
"Creates",
"an",
"object",
"that",
"inherits",
"from",
"the",
"prototype",
"object",
".",
"If",
"a",
"properties",
"object",
"is",
"given",
"its",
"own",
"enumerable",
"string",
"keyed",
"properties",
"are",
"assigned",
"to",
"the",
"created",
"object",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L12881-L12884 |
12,544 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | replace | function replace() {
var args = arguments,
string = toString(args[0]);
return args.length < 3 ? string : string.replace(args[1], args[2]);
} | javascript | function replace() {
var args = arguments,
string = toString(args[0]);
return args.length < 3 ? string : string.replace(args[1], args[2]);
} | [
"function",
"replace",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
",",
"string",
"=",
"toString",
"(",
"args",
"[",
"0",
"]",
")",
";",
"return",
"args",
".",
"length",
"<",
"3",
"?",
"string",
":",
"string",
".",
"replace",
"(",
"args",
"[",
... | Replaces matches for `pattern` in `string` with `replacement`.
**Note:** This method is based on
[`String#replace`](https://mdn.io/String/replace).
@static
@memberOf _
@since 4.0.0
@category String
@param {string} [string=''] The string to modify.
@param {RegExp|string} pattern The pattern to replace.
@param {Function|string} replacement The match replacement.
@returns {string} Returns the modified string.
@example
_.replace('Hi Fred', 'Fred', 'Barney');
// => 'Hi Barney' | [
"Replaces",
"matches",
"for",
"pattern",
"in",
"string",
"with",
"replacement",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L14621-L14626 |
12,545 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | startsWith | function startsWith(string, target, position) {
string = toString(string);
position = position == null
? 0
: baseClamp(toInteger(position), 0, string.length);
target = baseToString(target);
return string.slice(position, position + target.length) == target;
} | javascript | function startsWith(string, target, position) {
string = toString(string);
position = position == null
? 0
: baseClamp(toInteger(position), 0, string.length);
target = baseToString(target);
return string.slice(position, position + target.length) == target;
} | [
"function",
"startsWith",
"(",
"string",
",",
"target",
",",
"position",
")",
"{",
"string",
"=",
"toString",
"(",
"string",
")",
";",
"position",
"=",
"position",
"==",
"null",
"?",
"0",
":",
"baseClamp",
"(",
"toInteger",
"(",
"position",
")",
",",
"... | Checks if `string` starts with the given target string.
@static
@memberOf _
@since 3.0.0
@category String
@param {string} [string=''] The string to inspect.
@param {string} [target] The string to search for.
@param {number} [position=0] The position to search from.
@returns {boolean} Returns `true` if `string` starts with `target`,
else `false`.
@example
_.startsWith('abc', 'a');
// => true
_.startsWith('abc', 'b');
// => false
_.startsWith('abc', 'b', 1);
// => true | [
"Checks",
"if",
"string",
"starts",
"with",
"the",
"given",
"target",
"string",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L14741-L14749 |
12,546 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | truncate | function truncate(string, options) {
var length = DEFAULT_TRUNC_LENGTH,
omission = DEFAULT_TRUNC_OMISSION;
if (isObject(options)) {
var separator = 'separator' in options ? options.separator : separator;
length = 'length' in options ? toInteger(options.length) : length;
omission = 'omission' in options ? baseToString(options.omission) : omission;
}
string = toString(string);
var strLength = string.length;
if (hasUnicode(string)) {
var strSymbols = stringToArray(string);
strLength = strSymbols.length;
}
if (length >= strLength) {
return string;
}
var end = length - stringSize(omission);
if (end < 1) {
return omission;
}
var result = strSymbols
? castSlice(strSymbols, 0, end).join('')
: string.slice(0, end);
if (separator === undefined) {
return result + omission;
}
if (strSymbols) {
end += (result.length - end);
}
if (isRegExp(separator)) {
if (string.slice(end).search(separator)) {
var match,
substring = result;
if (!separator.global) {
separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
}
separator.lastIndex = 0;
while ((match = separator.exec(substring))) {
var newEnd = match.index;
}
result = result.slice(0, newEnd === undefined ? end : newEnd);
}
} else if (string.indexOf(baseToString(separator), end) != end) {
var index = result.lastIndexOf(separator);
if (index > -1) {
result = result.slice(0, index);
}
}
return result + omission;
} | javascript | function truncate(string, options) {
var length = DEFAULT_TRUNC_LENGTH,
omission = DEFAULT_TRUNC_OMISSION;
if (isObject(options)) {
var separator = 'separator' in options ? options.separator : separator;
length = 'length' in options ? toInteger(options.length) : length;
omission = 'omission' in options ? baseToString(options.omission) : omission;
}
string = toString(string);
var strLength = string.length;
if (hasUnicode(string)) {
var strSymbols = stringToArray(string);
strLength = strSymbols.length;
}
if (length >= strLength) {
return string;
}
var end = length - stringSize(omission);
if (end < 1) {
return omission;
}
var result = strSymbols
? castSlice(strSymbols, 0, end).join('')
: string.slice(0, end);
if (separator === undefined) {
return result + omission;
}
if (strSymbols) {
end += (result.length - end);
}
if (isRegExp(separator)) {
if (string.slice(end).search(separator)) {
var match,
substring = result;
if (!separator.global) {
separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
}
separator.lastIndex = 0;
while ((match = separator.exec(substring))) {
var newEnd = match.index;
}
result = result.slice(0, newEnd === undefined ? end : newEnd);
}
} else if (string.indexOf(baseToString(separator), end) != end) {
var index = result.lastIndexOf(separator);
if (index > -1) {
result = result.slice(0, index);
}
}
return result + omission;
} | [
"function",
"truncate",
"(",
"string",
",",
"options",
")",
"{",
"var",
"length",
"=",
"DEFAULT_TRUNC_LENGTH",
",",
"omission",
"=",
"DEFAULT_TRUNC_OMISSION",
";",
"if",
"(",
"isObject",
"(",
"options",
")",
")",
"{",
"var",
"separator",
"=",
"'separator'",
... | Truncates `string` if it's longer than the given maximum string length.
The last characters of the truncated string are replaced with the omission
string which defaults to "...".
@static
@memberOf _
@since 4.0.0
@category String
@param {string} [string=''] The string to truncate.
@param {Object} [options={}] The options object.
@param {number} [options.length=30] The maximum string length.
@param {string} [options.omission='...'] The string to indicate text is omitted.
@param {RegExp|string} [options.separator] The separator pattern to truncate to.
@returns {string} Returns the truncated string.
@example
_.truncate('hi-diddly-ho there, neighborino');
// => 'hi-diddly-ho there, neighbo...'
_.truncate('hi-diddly-ho there, neighborino', {
'length': 24,
'separator': ' '
});
// => 'hi-diddly-ho there,...'
_.truncate('hi-diddly-ho there, neighborino', {
'length': 24,
'separator': /,? +/
});
// => 'hi-diddly-ho there...'
_.truncate('hi-diddly-ho there, neighborino', {
'omission': ' [...]'
});
// => 'hi-diddly-ho there, neig [...]' | [
"Truncates",
"string",
"if",
"it",
"s",
"longer",
"than",
"the",
"given",
"maximum",
"string",
"length",
".",
"The",
"last",
"characters",
"of",
"the",
"truncated",
"string",
"are",
"replaced",
"with",
"the",
"omission",
"string",
"which",
"defaults",
"to",
... | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L15154-L15208 |
12,547 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | cond | function cond(pairs) {
var length = pairs == null ? 0 : pairs.length,
toIteratee = getIteratee();
pairs = !length ? [] : arrayMap(pairs, function(pair) {
if (typeof pair[1] != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return [toIteratee(pair[0]), pair[1]];
});
return baseRest(function(args) {
var index = -1;
while (++index < length) {
var pair = pairs[index];
if (apply(pair[0], this, args)) {
return apply(pair[1], this, args);
}
}
});
} | javascript | function cond(pairs) {
var length = pairs == null ? 0 : pairs.length,
toIteratee = getIteratee();
pairs = !length ? [] : arrayMap(pairs, function(pair) {
if (typeof pair[1] != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return [toIteratee(pair[0]), pair[1]];
});
return baseRest(function(args) {
var index = -1;
while (++index < length) {
var pair = pairs[index];
if (apply(pair[0], this, args)) {
return apply(pair[1], this, args);
}
}
});
} | [
"function",
"cond",
"(",
"pairs",
")",
"{",
"var",
"length",
"=",
"pairs",
"==",
"null",
"?",
"0",
":",
"pairs",
".",
"length",
",",
"toIteratee",
"=",
"getIteratee",
"(",
")",
";",
"pairs",
"=",
"!",
"length",
"?",
"[",
"]",
":",
"arrayMap",
"(",
... | Creates a function that iterates over `pairs` and invokes the corresponding
function of the first predicate to return truthy. The predicate-function
pairs are invoked with the `this` binding and arguments of the created
function.
@static
@memberOf _
@since 4.0.0
@category Util
@param {Array} pairs The predicate-function pairs.
@returns {Function} Returns the new composite function.
@example
var func = _.cond([
[_.matches({ 'a': 1 }), _.constant('matches A')],
[_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
[_.stubTrue, _.constant('no match')]
]);
func({ 'a': 1, 'b': 2 });
// => 'matches A'
func({ 'a': 0, 'b': 1 });
// => 'matches B'
func({ 'a': '1', 'b': '2' });
// => 'no match' | [
"Creates",
"a",
"function",
"that",
"iterates",
"over",
"pairs",
"and",
"invokes",
"the",
"corresponding",
"function",
"of",
"the",
"first",
"predicate",
"to",
"return",
"truthy",
".",
"The",
"predicate",
"-",
"function",
"pairs",
"are",
"invoked",
"with",
"th... | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L15403-L15423 |
12,548 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | nthArg | function nthArg(n) {
n = toInteger(n);
return baseRest(function(args) {
return baseNth(args, n);
});
} | javascript | function nthArg(n) {
n = toInteger(n);
return baseRest(function(args) {
return baseNth(args, n);
});
} | [
"function",
"nthArg",
"(",
"n",
")",
"{",
"n",
"=",
"toInteger",
"(",
"n",
")",
";",
"return",
"baseRest",
"(",
"function",
"(",
"args",
")",
"{",
"return",
"baseNth",
"(",
"args",
",",
"n",
")",
";",
"}",
")",
";",
"}"
] | Creates a function that gets the argument at index `n`. If `n` is negative,
the nth argument from the end is returned.
@static
@memberOf _
@since 4.0.0
@category Util
@param {number} [n=0] The index of the argument to return.
@returns {Function} Returns the new pass-thru function.
@example
var func = _.nthArg(1);
func('a', 'b', 'c', 'd');
// => 'b'
var func = _.nthArg(-2);
func('a', 'b', 'c', 'd');
// => 'c' | [
"Creates",
"a",
"function",
"that",
"gets",
"the",
"argument",
"at",
"index",
"n",
".",
"If",
"n",
"is",
"negative",
"the",
"nth",
"argument",
"from",
"the",
"end",
"is",
"returned",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L15864-L15869 |
12,549 | zhanziyang/vue-croppa | docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js | toPath | function toPath(value) {
if (isArray(value)) {
return arrayMap(value, toKey);
}
return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
} | javascript | function toPath(value) {
if (isArray(value)) {
return arrayMap(value, toKey);
}
return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
} | [
"function",
"toPath",
"(",
"value",
")",
"{",
"if",
"(",
"isArray",
"(",
"value",
")",
")",
"{",
"return",
"arrayMap",
"(",
"value",
",",
"toKey",
")",
";",
"}",
"return",
"isSymbol",
"(",
"value",
")",
"?",
"[",
"value",
"]",
":",
"copyArray",
"("... | Converts `value` to a property path array.
@static
@memberOf _
@since 4.0.0
@category Util
@param {*} value The value to convert.
@returns {Array} Returns the new property path array.
@example
_.toPath('a.b.c');
// => ['a', 'b', 'c']
_.toPath('a[0].b.c');
// => ['a', '0', 'b', 'c'] | [
"Converts",
"value",
"to",
"a",
"property",
"path",
"array",
"."
] | 46632d9ce254b834150d7fab2febb666e1c7d2a4 | https://github.com/zhanziyang/vue-croppa/blob/46632d9ce254b834150d7fab2febb666e1c7d2a4/docs/static/kute-page_files/undefined.cd4343636fa2ca97594c.js#L16226-L16231 |
12,550 | tracespace/tracespace | packages/gerber-plotter/lib/_pad-shape.js | function(cx, cy, r, width) {
return {type: 'ring', cx: cx, cy: cy, r: r, width: width}
} | javascript | function(cx, cy, r, width) {
return {type: 'ring', cx: cx, cy: cy, r: r, width: width}
} | [
"function",
"(",
"cx",
",",
"cy",
",",
"r",
",",
"width",
")",
"{",
"return",
"{",
"type",
":",
"'ring'",
",",
"cx",
":",
"cx",
",",
"cy",
":",
"cy",
",",
"r",
":",
"r",
",",
"width",
":",
"width",
"}",
"}"
] | just returns a ring object, does not return a box | [
"just",
"returns",
"a",
"ring",
"object",
"does",
"not",
"return",
"a",
"box"
] | e1cd3af69766ae2f08491cb2309a62013ff1f815 | https://github.com/tracespace/tracespace/blob/e1cd3af69766ae2f08491cb2309a62013ff1f815/packages/gerber-plotter/lib/_pad-shape.js#L165-L167 | |
12,551 | tracespace/tracespace | packages/pcb-stackup/index.js | renderStackup | function renderStackup(stackupLayers, next) {
var stackup = createStackup(stackupLayers, options)
stackup.layers = stackupLayers
next(null, stackup)
} | javascript | function renderStackup(stackupLayers, next) {
var stackup = createStackup(stackupLayers, options)
stackup.layers = stackupLayers
next(null, stackup)
} | [
"function",
"renderStackup",
"(",
"stackupLayers",
",",
"next",
")",
"{",
"var",
"stackup",
"=",
"createStackup",
"(",
"stackupLayers",
",",
"options",
")",
"stackup",
".",
"layers",
"=",
"stackupLayers",
"next",
"(",
"null",
",",
"stackup",
")",
"}"
] | using the result of renderAllLayers, build the stackup | [
"using",
"the",
"result",
"of",
"renderAllLayers",
"build",
"the",
"stackup"
] | e1cd3af69766ae2f08491cb2309a62013ff1f815 | https://github.com/tracespace/tracespace/blob/e1cd3af69766ae2f08491cb2309a62013ff1f815/packages/pcb-stackup/index.js#L52-L56 |
12,552 | tracespace/tracespace | packages/pcb-stackup/index.js | makeRenderLayerTask | function makeRenderLayerTask(layer) {
return function renderLayer(next) {
var stackupLayer = makeBaseStackupLayer(layer)
if (stackupLayer.converter) return next(null, stackupLayer)
var converter = gerberToSvg(
stackupLayer.gerber,
stackupLayer.options,
function handleLayerDone(error) {
if (error) return next(error)
stackupLayer.converter = converter
next(null, stackupLayer)
}
)
}
} | javascript | function makeRenderLayerTask(layer) {
return function renderLayer(next) {
var stackupLayer = makeBaseStackupLayer(layer)
if (stackupLayer.converter) return next(null, stackupLayer)
var converter = gerberToSvg(
stackupLayer.gerber,
stackupLayer.options,
function handleLayerDone(error) {
if (error) return next(error)
stackupLayer.converter = converter
next(null, stackupLayer)
}
)
}
} | [
"function",
"makeRenderLayerTask",
"(",
"layer",
")",
"{",
"return",
"function",
"renderLayer",
"(",
"next",
")",
"{",
"var",
"stackupLayer",
"=",
"makeBaseStackupLayer",
"(",
"layer",
")",
"if",
"(",
"stackupLayer",
".",
"converter",
")",
"return",
"next",
"(... | map an pcb-stackup input layer into a function that will call a callback once a pcb-stackup-core input layer is ready | [
"map",
"an",
"pcb",
"-",
"stackup",
"input",
"layer",
"into",
"a",
"function",
"that",
"will",
"call",
"a",
"callback",
"once",
"a",
"pcb",
"-",
"stackup",
"-",
"core",
"input",
"layer",
"is",
"ready"
] | e1cd3af69766ae2f08491cb2309a62013ff1f815 | https://github.com/tracespace/tracespace/blob/e1cd3af69766ae2f08491cb2309a62013ff1f815/packages/pcb-stackup/index.js#L70-L86 |
12,553 | tracespace/tracespace | packages/pcb-stackup/index.js | makeBaseStackupLayer | function makeBaseStackupLayer(layer) {
var layerSide = layer.side
var layerType = layer.type
if (
layer.filename &&
typeof layerSide === 'undefined' &&
typeof layerType === 'undefined'
) {
var gerberId = layerTypes[layer.filename]
layerSide = gerberId.side
layerType = gerberId.type
}
var layerOptions = extend(layer.options)
if (layerOptions.plotAsOutline == null && layerType === wtg.TYPE_OUTLINE) {
layerOptions.plotAsOutline = true
}
if (
options &&
options.outlineGapFill != null &&
layerOptions.plotAsOutline
) {
layerOptions.plotAsOutline = options.outlineGapFill
}
return extend(layer, {
side: layerSide,
type: layerType,
options: layerOptions,
})
} | javascript | function makeBaseStackupLayer(layer) {
var layerSide = layer.side
var layerType = layer.type
if (
layer.filename &&
typeof layerSide === 'undefined' &&
typeof layerType === 'undefined'
) {
var gerberId = layerTypes[layer.filename]
layerSide = gerberId.side
layerType = gerberId.type
}
var layerOptions = extend(layer.options)
if (layerOptions.plotAsOutline == null && layerType === wtg.TYPE_OUTLINE) {
layerOptions.plotAsOutline = true
}
if (
options &&
options.outlineGapFill != null &&
layerOptions.plotAsOutline
) {
layerOptions.plotAsOutline = options.outlineGapFill
}
return extend(layer, {
side: layerSide,
type: layerType,
options: layerOptions,
})
} | [
"function",
"makeBaseStackupLayer",
"(",
"layer",
")",
"{",
"var",
"layerSide",
"=",
"layer",
".",
"side",
"var",
"layerType",
"=",
"layer",
".",
"type",
"if",
"(",
"layer",
".",
"filename",
"&&",
"typeof",
"layerSide",
"===",
"'undefined'",
"&&",
"typeof",
... | extend pcb-stackup input layer with necessary details for pcb-stackup-core | [
"extend",
"pcb",
"-",
"stackup",
"input",
"layer",
"with",
"necessary",
"details",
"for",
"pcb",
"-",
"stackup",
"-",
"core"
] | e1cd3af69766ae2f08491cb2309a62013ff1f815 | https://github.com/tracespace/tracespace/blob/e1cd3af69766ae2f08491cb2309a62013ff1f815/packages/pcb-stackup/index.js#L89-L122 |
12,554 | tracespace/tracespace | packages/gerber-parser/lib/_parse-macro-expression.js | function() {
var t = tokens.shift()
var exp
if (RE_NUMBER.test(t)) {
exp = {type: 'n', val: t}
} else {
exp = parseExpression()
tokens.shift()
}
return exp
} | javascript | function() {
var t = tokens.shift()
var exp
if (RE_NUMBER.test(t)) {
exp = {type: 'n', val: t}
} else {
exp = parseExpression()
tokens.shift()
}
return exp
} | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"tokens",
".",
"shift",
"(",
")",
"var",
"exp",
"if",
"(",
"RE_NUMBER",
".",
"test",
"(",
"t",
")",
")",
"{",
"exp",
"=",
"{",
"type",
":",
"'n'",
",",
"val",
":",
"t",
"}",
"}",
"else",
"{",
"exp... | primary tokens are numbers and parentheses | [
"primary",
"tokens",
"are",
"numbers",
"and",
"parentheses"
] | e1cd3af69766ae2f08491cb2309a62013ff1f815 | https://github.com/tracespace/tracespace/blob/e1cd3af69766ae2f08491cb2309a62013ff1f815/packages/gerber-parser/lib/_parse-macro-expression.js#L16-L27 | |
12,555 | tracespace/tracespace | packages/gerber-parser/lib/_parse-macro-expression.js | function() {
var exp = parsePrimary()
var t = tokens[0]
if (t === 'X') {
parser._warn("multiplication in macros should use 'x', not 'X'")
t = 'x'
}
while (t === 'x' || t === '/') {
tokens.shift()
var right = parsePrimary()
exp = {type: t, left: exp, right: right}
t = tokens[0]
}
return exp
} | javascript | function() {
var exp = parsePrimary()
var t = tokens[0]
if (t === 'X') {
parser._warn("multiplication in macros should use 'x', not 'X'")
t = 'x'
}
while (t === 'x' || t === '/') {
tokens.shift()
var right = parsePrimary()
exp = {type: t, left: exp, right: right}
t = tokens[0]
}
return exp
} | [
"function",
"(",
")",
"{",
"var",
"exp",
"=",
"parsePrimary",
"(",
")",
"var",
"t",
"=",
"tokens",
"[",
"0",
"]",
"if",
"(",
"t",
"===",
"'X'",
")",
"{",
"parser",
".",
"_warn",
"(",
"\"multiplication in macros should use 'x', not 'X'\"",
")",
"t",
"=",
... | parse multiplication and division tokens | [
"parse",
"multiplication",
"and",
"division",
"tokens"
] | e1cd3af69766ae2f08491cb2309a62013ff1f815 | https://github.com/tracespace/tracespace/blob/e1cd3af69766ae2f08491cb2309a62013ff1f815/packages/gerber-parser/lib/_parse-macro-expression.js#L30-L45 | |
12,556 | tracespace/tracespace | packages/gerber-parser/lib/_parse-macro-expression.js | function(op, mods) {
var getValue = function(t) {
if (t[0] === '$') {
return Number(mods[t])
}
return Number(t)
}
var type = op.type
if (type === 'n') {
return getValue(op.val)
}
if (type === '+') {
return evaluate(op.left, mods) + evaluate(op.right, mods)
}
if (type === '-') {
return evaluate(op.left, mods) - evaluate(op.right, mods)
}
if (type === 'x') {
return evaluate(op.left, mods) * evaluate(op.right, mods)
}
// else division
return evaluate(op.left, mods) / evaluate(op.right, mods)
} | javascript | function(op, mods) {
var getValue = function(t) {
if (t[0] === '$') {
return Number(mods[t])
}
return Number(t)
}
var type = op.type
if (type === 'n') {
return getValue(op.val)
}
if (type === '+') {
return evaluate(op.left, mods) + evaluate(op.right, mods)
}
if (type === '-') {
return evaluate(op.left, mods) - evaluate(op.right, mods)
}
if (type === 'x') {
return evaluate(op.left, mods) * evaluate(op.right, mods)
}
// else division
return evaluate(op.left, mods) / evaluate(op.right, mods)
} | [
"function",
"(",
"op",
",",
"mods",
")",
"{",
"var",
"getValue",
"=",
"function",
"(",
"t",
")",
"{",
"if",
"(",
"t",
"[",
"0",
"]",
"===",
"'$'",
")",
"{",
"return",
"Number",
"(",
"mods",
"[",
"t",
"]",
")",
"}",
"return",
"Number",
"(",
"t... | evalute by recursively traversing the tree | [
"evalute",
"by",
"recursively",
"traversing",
"the",
"tree"
] | e1cd3af69766ae2f08491cb2309a62013ff1f815 | https://github.com/tracespace/tracespace/blob/e1cd3af69766ae2f08491cb2309a62013ff1f815/packages/gerber-parser/lib/_parse-macro-expression.js#L64-L87 | |
12,557 | zerobias/telegram-mtproto | src/vendor/leemon.js | findPrimes | function findPrimes(n) {
var i, s, p, ans;
s=new Array(n);
for (i=0; i<n; i++)
s[i]=0;
s[0]=2;
p=0; //first p elements of s are primes, the rest are a sieve
for (;s[p]<n;) { //s[p] is the pth prime
for (i=s[p]*s[p]; i<n; i+=s[p]) //mark multiples of s[p]
s[i]=1;
p++;
s[p]=s[p-1]+1;
for (; s[p]<n && s[s[p]]; s[p]++); //find next prime (where s[p]==0)
}
ans=new Array(p);
for (i=0; i<p; i++)
ans[i]=s[i];
return ans;
} | javascript | function findPrimes(n) {
var i, s, p, ans;
s=new Array(n);
for (i=0; i<n; i++)
s[i]=0;
s[0]=2;
p=0; //first p elements of s are primes, the rest are a sieve
for (;s[p]<n;) { //s[p] is the pth prime
for (i=s[p]*s[p]; i<n; i+=s[p]) //mark multiples of s[p]
s[i]=1;
p++;
s[p]=s[p-1]+1;
for (; s[p]<n && s[s[p]]; s[p]++); //find next prime (where s[p]==0)
}
ans=new Array(p);
for (i=0; i<p; i++)
ans[i]=s[i];
return ans;
} | [
"function",
"findPrimes",
"(",
"n",
")",
"{",
"var",
"i",
",",
"s",
",",
"p",
",",
"ans",
";",
"s",
"=",
"new",
"Array",
"(",
"n",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"s",
"[",
"i",
"]",
"=",
... | return array of all primes less than integer n | [
"return",
"array",
"of",
"all",
"primes",
"less",
"than",
"integer",
"n"
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L224-L242 |
12,558 | zerobias/telegram-mtproto | src/vendor/leemon.js | millerRabinInt | function millerRabinInt(x, b) {
if (mr_x1.length!=x.length) {
mr_x1=dup(x);
mr_r=dup(x);
mr_a=dup(x);
}
copyInt_(mr_a, b);
return millerRabin(x, mr_a);
} | javascript | function millerRabinInt(x, b) {
if (mr_x1.length!=x.length) {
mr_x1=dup(x);
mr_r=dup(x);
mr_a=dup(x);
}
copyInt_(mr_a, b);
return millerRabin(x, mr_a);
} | [
"function",
"millerRabinInt",
"(",
"x",
",",
"b",
")",
"{",
"if",
"(",
"mr_x1",
".",
"length",
"!=",
"x",
".",
"length",
")",
"{",
"mr_x1",
"=",
"dup",
"(",
"x",
")",
";",
"mr_r",
"=",
"dup",
"(",
"x",
")",
";",
"mr_a",
"=",
"dup",
"(",
"x",
... | does a single round of Miller-Rabin base b consider x to be a possible prime? x is a bigInt, and b is an integer, with b<x | [
"does",
"a",
"single",
"round",
"of",
"Miller",
"-",
"Rabin",
"base",
"b",
"consider",
"x",
"to",
"be",
"a",
"possible",
"prime?",
"x",
"is",
"a",
"bigInt",
"and",
"b",
"is",
"an",
"integer",
"with",
"b<x"
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L247-L256 |
12,559 | zerobias/telegram-mtproto | src/vendor/leemon.js | bitSize | function bitSize(x) {
var j, z, w;
for (j=x.length-1; (x[j]==0) && (j>0); j--);
for (z=0, w=x[j]; w; (w>>=1), z++);
z+=bpe*j;
return z;
} | javascript | function bitSize(x) {
var j, z, w;
for (j=x.length-1; (x[j]==0) && (j>0); j--);
for (z=0, w=x[j]; w; (w>>=1), z++);
z+=bpe*j;
return z;
} | [
"function",
"bitSize",
"(",
"x",
")",
"{",
"var",
"j",
",",
"z",
",",
"w",
";",
"for",
"(",
"j",
"=",
"x",
".",
"length",
"-",
"1",
";",
"(",
"x",
"[",
"j",
"]",
"==",
"0",
")",
"&&",
"(",
"j",
">",
"0",
")",
";",
"j",
"--",
")",
";",... | returns how many bits long the bigInt is, not counting leading zeros. | [
"returns",
"how",
"many",
"bits",
"long",
"the",
"bigInt",
"is",
"not",
"counting",
"leading",
"zeros",
"."
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L309-L315 |
12,560 | zerobias/telegram-mtproto | src/vendor/leemon.js | expand | function expand(x, n) {
var ans=int2bigInt(0, (x.length>n ? x.length : n)*bpe, 0);
copy_(ans, x);
return ans;
} | javascript | function expand(x, n) {
var ans=int2bigInt(0, (x.length>n ? x.length : n)*bpe, 0);
copy_(ans, x);
return ans;
} | [
"function",
"expand",
"(",
"x",
",",
"n",
")",
"{",
"var",
"ans",
"=",
"int2bigInt",
"(",
"0",
",",
"(",
"x",
".",
"length",
">",
"n",
"?",
"x",
".",
"length",
":",
"n",
")",
"*",
"bpe",
",",
"0",
")",
";",
"copy_",
"(",
"ans",
",",
"x",
... | return a copy of x with at least n elements, adding leading zeros if needed | [
"return",
"a",
"copy",
"of",
"x",
"with",
"at",
"least",
"n",
"elements",
"adding",
"leading",
"zeros",
"if",
"needed"
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L318-L322 |
12,561 | zerobias/telegram-mtproto | src/vendor/leemon.js | randTruePrime | function randTruePrime(k) {
var ans=int2bigInt(0, k, 0);
randTruePrime_(ans, k);
return trim(ans, 1);
} | javascript | function randTruePrime(k) {
var ans=int2bigInt(0, k, 0);
randTruePrime_(ans, k);
return trim(ans, 1);
} | [
"function",
"randTruePrime",
"(",
"k",
")",
"{",
"var",
"ans",
"=",
"int2bigInt",
"(",
"0",
",",
"k",
",",
"0",
")",
";",
"randTruePrime_",
"(",
"ans",
",",
"k",
")",
";",
"return",
"trim",
"(",
"ans",
",",
"1",
")",
";",
"}"
] | return a k-bit true random prime using Maurer's algorithm. | [
"return",
"a",
"k",
"-",
"bit",
"true",
"random",
"prime",
"using",
"Maurer",
"s",
"algorithm",
"."
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L325-L329 |
12,562 | zerobias/telegram-mtproto | src/vendor/leemon.js | randProbPrime | function randProbPrime(k) {
if (k>=600) return randProbPrimeRounds(k, 2); //numbers from HAC table 4.3
if (k>=550) return randProbPrimeRounds(k, 4);
if (k>=500) return randProbPrimeRounds(k, 5);
if (k>=400) return randProbPrimeRounds(k, 6);
if (k>=350) return randProbPrimeRounds(k, 7);
if (k>=300) return randProbPrimeRounds(k, 9);
if (k>=250) return randProbPrimeRounds(k, 12); //numbers from HAC table 4.4
if (k>=200) return randProbPrimeRounds(k, 15);
if (k>=150) return randProbPrimeRounds(k, 18);
if (k>=100) return randProbPrimeRounds(k, 27);
return randProbPrimeRounds(k, 40); //number from HAC remark 4.26 (only an estimate)
} | javascript | function randProbPrime(k) {
if (k>=600) return randProbPrimeRounds(k, 2); //numbers from HAC table 4.3
if (k>=550) return randProbPrimeRounds(k, 4);
if (k>=500) return randProbPrimeRounds(k, 5);
if (k>=400) return randProbPrimeRounds(k, 6);
if (k>=350) return randProbPrimeRounds(k, 7);
if (k>=300) return randProbPrimeRounds(k, 9);
if (k>=250) return randProbPrimeRounds(k, 12); //numbers from HAC table 4.4
if (k>=200) return randProbPrimeRounds(k, 15);
if (k>=150) return randProbPrimeRounds(k, 18);
if (k>=100) return randProbPrimeRounds(k, 27);
return randProbPrimeRounds(k, 40); //number from HAC remark 4.26 (only an estimate)
} | [
"function",
"randProbPrime",
"(",
"k",
")",
"{",
"if",
"(",
"k",
">=",
"600",
")",
"return",
"randProbPrimeRounds",
"(",
"k",
",",
"2",
")",
";",
"//numbers from HAC table 4.3",
"if",
"(",
"k",
">=",
"550",
")",
"return",
"randProbPrimeRounds",
"(",
"k",
... | return a k-bit random probable prime with probability of error < 2^-80 | [
"return",
"a",
"k",
"-",
"bit",
"random",
"probable",
"prime",
"with",
"probability",
"of",
"error",
"<",
"2^",
"-",
"80"
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L332-L344 |
12,563 | zerobias/telegram-mtproto | src/vendor/leemon.js | randBigInt_ | function randBigInt_(b, n, s) {
var i, a;
for (i=0; i<b.length; i++)
b[i]=0;
a=Math.floor((n-1)/bpe)+1; //# array elements to hold the BigInt
for (i=0; i<a; i++) {
b[i]=Math.floor(Math.random()*(1<<(bpe-1)));
}
b[a-1] &= (2<<((n-1)%bpe))-1;
if (s==1)
b[a-1] |= (1<<((n-1)%bpe));
} | javascript | function randBigInt_(b, n, s) {
var i, a;
for (i=0; i<b.length; i++)
b[i]=0;
a=Math.floor((n-1)/bpe)+1; //# array elements to hold the BigInt
for (i=0; i<a; i++) {
b[i]=Math.floor(Math.random()*(1<<(bpe-1)));
}
b[a-1] &= (2<<((n-1)%bpe))-1;
if (s==1)
b[a-1] |= (1<<((n-1)%bpe));
} | [
"function",
"randBigInt_",
"(",
"b",
",",
"n",
",",
"s",
")",
"{",
"var",
"i",
",",
"a",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"b",
".",
"length",
";",
"i",
"++",
")",
"b",
"[",
"i",
"]",
"=",
"0",
";",
"a",
"=",
"Math",
".",
... | Set b to an n-bit random BigInt. If s=1, then the most significant of those n bits is set to 1. Array b must be big enough to hold the result. Must have n>=1 | [
"Set",
"b",
"to",
"an",
"n",
"-",
"bit",
"random",
"BigInt",
".",
"If",
"s",
"=",
"1",
"then",
"the",
"most",
"significant",
"of",
"those",
"n",
"bits",
"is",
"set",
"to",
"1",
".",
"Array",
"b",
"must",
"be",
"big",
"enough",
"to",
"hold",
"the"... | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L593-L604 |
12,564 | zerobias/telegram-mtproto | src/vendor/leemon.js | carry_ | function carry_(x) {
var i, k, c, b;
k=x.length;
c=0;
for (i=0; i<k; i++) {
c+=x[i];
b=0;
if (c<0) {
b=-(c>>bpe);
c+=b*radix;
}
x[i]=c & mask;
c=(c>>bpe)-b;
}
} | javascript | function carry_(x) {
var i, k, c, b;
k=x.length;
c=0;
for (i=0; i<k; i++) {
c+=x[i];
b=0;
if (c<0) {
b=-(c>>bpe);
c+=b*radix;
}
x[i]=c & mask;
c=(c>>bpe)-b;
}
} | [
"function",
"carry_",
"(",
"x",
")",
"{",
"var",
"i",
",",
"k",
",",
"c",
",",
"b",
";",
"k",
"=",
"x",
".",
"length",
";",
"c",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"k",
";",
"i",
"++",
")",
"{",
"c",
"+=",
"x",
... | do carries and borrows so each element of the bigInt x fits in bpe bits. | [
"do",
"carries",
"and",
"borrows",
"so",
"each",
"element",
"of",
"the",
"bigInt",
"x",
"fits",
"in",
"bpe",
"bits",
"."
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L944-L958 |
12,565 | zerobias/telegram-mtproto | src/vendor/leemon.js | modInt | function modInt(x, n) {
var i, c=0;
for (i=x.length-1; i>=0; i--)
c=(c*radix+x[i])%n;
return c;
} | javascript | function modInt(x, n) {
var i, c=0;
for (i=x.length-1; i>=0; i--)
c=(c*radix+x[i])%n;
return c;
} | [
"function",
"modInt",
"(",
"x",
",",
"n",
")",
"{",
"var",
"i",
",",
"c",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"x",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"c",
"=",
"(",
"c",
"*",
"radix",
"+",
"x",
"[",
"i... | return x mod n for bigInt x and integer n. | [
"return",
"x",
"mod",
"n",
"for",
"bigInt",
"x",
"and",
"integer",
"n",
"."
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L961-L966 |
12,566 | zerobias/telegram-mtproto | src/vendor/leemon.js | equals | function equals(x, y) {
var i;
var k=x.length<y.length ? x.length : y.length;
for (i=0; i<k; i++)
if (x[i]!=y[i])
return 0;
if (x.length>y.length) {
for (;i<x.length; i++)
if (x[i])
return 0;
} else {
for (;i<y.length; i++)
if (y[i])
return 0;
}
return 1;
} | javascript | function equals(x, y) {
var i;
var k=x.length<y.length ? x.length : y.length;
for (i=0; i<k; i++)
if (x[i]!=y[i])
return 0;
if (x.length>y.length) {
for (;i<x.length; i++)
if (x[i])
return 0;
} else {
for (;i<y.length; i++)
if (y[i])
return 0;
}
return 1;
} | [
"function",
"equals",
"(",
"x",
",",
"y",
")",
"{",
"var",
"i",
";",
"var",
"k",
"=",
"x",
".",
"length",
"<",
"y",
".",
"length",
"?",
"x",
".",
"length",
":",
"y",
".",
"length",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"k",
";",
... | are bigints x and y equal? this works even if x and y are different lengths and have arbitrarily many leading zeros | [
"are",
"bigints",
"x",
"and",
"y",
"equal?",
"this",
"works",
"even",
"if",
"x",
"and",
"y",
"are",
"different",
"lengths",
"and",
"have",
"arbitrarily",
"many",
"leading",
"zeros"
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L1048-L1064 |
12,567 | zerobias/telegram-mtproto | src/vendor/leemon.js | mod_ | function mod_(x, n) {
if (s4.length!=x.length)
s4=dup(x);
else
copy_(s4, x);
if (s5.length!=x.length)
s5=dup(x);
divide_(s4, n, s5, x); //x = remainder of s4 / n
} | javascript | function mod_(x, n) {
if (s4.length!=x.length)
s4=dup(x);
else
copy_(s4, x);
if (s5.length!=x.length)
s5=dup(x);
divide_(s4, n, s5, x); //x = remainder of s4 / n
} | [
"function",
"mod_",
"(",
"x",
",",
"n",
")",
"{",
"if",
"(",
"s4",
".",
"length",
"!=",
"x",
".",
"length",
")",
"s4",
"=",
"dup",
"(",
"x",
")",
";",
"else",
"copy_",
"(",
"s4",
",",
"x",
")",
";",
"if",
"(",
"s5",
".",
"length",
"!=",
"... | do x=x mod n for bigInts x and n. | [
"do",
"x",
"=",
"x",
"mod",
"n",
"for",
"bigInts",
"x",
"and",
"n",
"."
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L1345-L1353 |
12,568 | zerobias/telegram-mtproto | src/vendor/leemon.js | trim | function trim(x, k) {
var i, y;
for (i=x.length; i>0 && !x[i-1]; i--);
y=new Array(i+k);
copy_(y, x);
return y;
} | javascript | function trim(x, k) {
var i, y;
for (i=x.length; i>0 && !x[i-1]; i--);
y=new Array(i+k);
copy_(y, x);
return y;
} | [
"function",
"trim",
"(",
"x",
",",
"k",
")",
"{",
"var",
"i",
",",
"y",
";",
"for",
"(",
"i",
"=",
"x",
".",
"length",
";",
"i",
">",
"0",
"&&",
"!",
"x",
"[",
"i",
"-",
"1",
"]",
";",
"i",
"--",
")",
";",
"y",
"=",
"new",
"Array",
"(... | return x with exactly k leading zero elements | [
"return",
"x",
"with",
"exactly",
"k",
"leading",
"zero",
"elements"
] | 3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522 | https://github.com/zerobias/telegram-mtproto/blob/3f8ba3c69974f4d4d6cc183ed2893b8ef30f3522/src/vendor/leemon.js#L1393-L1399 |
12,569 | lucasferreira/react-native-flash-message | src/FlashMessage.js | parseIcon | function parseIcon(icon = "none") {
if (!!icon && icon !== "none") {
if (typeof icon === "string") {
return { icon, position: "left", style: {} };
}
return { position: "left", style: {}, ...icon };
}
return null;
} | javascript | function parseIcon(icon = "none") {
if (!!icon && icon !== "none") {
if (typeof icon === "string") {
return { icon, position: "left", style: {} };
}
return { position: "left", style: {}, ...icon };
}
return null;
} | [
"function",
"parseIcon",
"(",
"icon",
"=",
"\"none\"",
")",
"{",
"if",
"(",
"!",
"!",
"icon",
"&&",
"icon",
"!==",
"\"none\"",
")",
"{",
"if",
"(",
"typeof",
"icon",
"===",
"\"string\"",
")",
"{",
"return",
"{",
"icon",
",",
"position",
":",
"\"left\... | Translates icon prop value into complex internal object | [
"Translates",
"icon",
"prop",
"value",
"into",
"complex",
"internal",
"object"
] | 88caa5ac87f61988f5e43f39ccb137f855e1d2b8 | https://github.com/lucasferreira/react-native-flash-message/blob/88caa5ac87f61988f5e43f39ccb137f855e1d2b8/src/FlashMessage.js#L50-L60 |
12,570 | vuikit/vuikit | packages/vuikit/src/core/v-position/directive.js | getOptions | function getOptions (ctx) {
const { vnode } = ctx
const { value } = ctx.binding
if (process.env.NODE_ENV !== 'production' && (isUndefined(value) || !isObject(value))) {
warn('v-position -> configuration is missing or is not an Object', vnode.context)
}
const options = assign({
target: null,
position: 'top-center',
boundary: window,
flip: true,
offset: false,
mainClass: ''
}, value)
return options
} | javascript | function getOptions (ctx) {
const { vnode } = ctx
const { value } = ctx.binding
if (process.env.NODE_ENV !== 'production' && (isUndefined(value) || !isObject(value))) {
warn('v-position -> configuration is missing or is not an Object', vnode.context)
}
const options = assign({
target: null,
position: 'top-center',
boundary: window,
flip: true,
offset: false,
mainClass: ''
}, value)
return options
} | [
"function",
"getOptions",
"(",
"ctx",
")",
"{",
"const",
"{",
"vnode",
"}",
"=",
"ctx",
"const",
"{",
"value",
"}",
"=",
"ctx",
".",
"binding",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
"&&",
"(",
"isUndefined",
"(",
"... | Get the directive props | [
"Get",
"the",
"directive",
"props"
] | 98be3d9414edbb43cfc227d8120f090b6edab97e | https://github.com/vuikit/vuikit/blob/98be3d9414edbb43cfc227d8120f090b6edab97e/packages/vuikit/src/core/v-position/directive.js#L87-L105 |
12,571 | vuikit/vuikit | packages/vuikit/src/core/v-position/directive.js | getContext | function getContext (el, binding, vnode) {
const ctx = { el, binding, vnode }
ctx.props = getOptions(ctx)
if (!ctx.props) {
binding.def.unbind(el, binding)
return
}
return ctx
} | javascript | function getContext (el, binding, vnode) {
const ctx = { el, binding, vnode }
ctx.props = getOptions(ctx)
if (!ctx.props) {
binding.def.unbind(el, binding)
return
}
return ctx
} | [
"function",
"getContext",
"(",
"el",
",",
"binding",
",",
"vnode",
")",
"{",
"const",
"ctx",
"=",
"{",
"el",
",",
"binding",
",",
"vnode",
"}",
"ctx",
".",
"props",
"=",
"getOptions",
"(",
"ctx",
")",
"if",
"(",
"!",
"ctx",
".",
"props",
")",
"{"... | Get the context used across | [
"Get",
"the",
"context",
"used",
"across"
] | 98be3d9414edbb43cfc227d8120f090b6edab97e | https://github.com/vuikit/vuikit/blob/98be3d9414edbb43cfc227d8120f090b6edab97e/packages/vuikit/src/core/v-position/directive.js#L110-L120 |
12,572 | WP-API/node-wpapi | lib/resource-handler-spec.js | extractSetterFromNode | function extractSetterFromNode( handler, node ) {
assignSetterFnForNode( handler, node );
if ( node.children ) {
// Recurse down to this node's children
Object.keys( node.children ).forEach( ( key ) => {
extractSetterFromNode( handler, node.children[ key ] );
} );
}
} | javascript | function extractSetterFromNode( handler, node ) {
assignSetterFnForNode( handler, node );
if ( node.children ) {
// Recurse down to this node's children
Object.keys( node.children ).forEach( ( key ) => {
extractSetterFromNode( handler, node.children[ key ] );
} );
}
} | [
"function",
"extractSetterFromNode",
"(",
"handler",
",",
"node",
")",
"{",
"assignSetterFnForNode",
"(",
"handler",
",",
"node",
")",
";",
"if",
"(",
"node",
".",
"children",
")",
"{",
"// Recurse down to this node's children",
"Object",
".",
"keys",
"(",
"node... | Walk the tree of a specific resource node to create the setter methods
The API we want to produce from the node tree looks like this:
wp.posts(); /wp/v2/posts
wp.posts().id( 7 ); /wp/v2/posts/7
wp.posts().id( 7 ).revisions(); /wp/v2/posts/7/revisions
wp.posts().id( 7 ).revisions( 8 ); /wp/v2/posts/7/revisions/8
^ That last one's the tricky one: we can deduce that this parameter is "id", but
that param will already be taken by the post ID, so sub-collections have to be
set up as `.revisions()` to get the collection, and `.revisions( id )` to get a
specific resource.
@private
@param {Object} node A node object
@param {Object} [node.children] An object of child nodes
// @returns {isLeaf} A boolean indicating whether the processed node is a leaf | [
"Walk",
"the",
"tree",
"of",
"a",
"specific",
"resource",
"node",
"to",
"create",
"the",
"setter",
"methods"
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/lib/resource-handler-spec.js#L72-L82 |
12,573 | WP-API/node-wpapi | lib/resource-handler-spec.js | createNodeHandlerSpec | function createNodeHandlerSpec( routeDefinition, resource ) {
const handler = {
// A "path" is an ordered (by key) set of values composed into the final URL
_path: {
'0': resource,
},
// A "level" is a level-keyed object representing the valid options for
// one level of the resource URL
_levels: {},
// Objects that hold methods and properties which will be copied to
// instances of this endpoint's handler
_setters: {},
// Arguments (query parameters) that may be set in GET requests to endpoints
// nested within this resource route tree, used to determine the mixins to
// add to the request handler
_getArgs: routeDefinition._getArgs,
};
// Walk the tree
Object.keys( routeDefinition ).forEach( ( routeDefProp ) => {
if ( routeDefProp !== '_getArgs' ) {
extractSetterFromNode( handler, routeDefinition[ routeDefProp ] );
}
} );
return handler;
} | javascript | function createNodeHandlerSpec( routeDefinition, resource ) {
const handler = {
// A "path" is an ordered (by key) set of values composed into the final URL
_path: {
'0': resource,
},
// A "level" is a level-keyed object representing the valid options for
// one level of the resource URL
_levels: {},
// Objects that hold methods and properties which will be copied to
// instances of this endpoint's handler
_setters: {},
// Arguments (query parameters) that may be set in GET requests to endpoints
// nested within this resource route tree, used to determine the mixins to
// add to the request handler
_getArgs: routeDefinition._getArgs,
};
// Walk the tree
Object.keys( routeDefinition ).forEach( ( routeDefProp ) => {
if ( routeDefProp !== '_getArgs' ) {
extractSetterFromNode( handler, routeDefinition[ routeDefProp ] );
}
} );
return handler;
} | [
"function",
"createNodeHandlerSpec",
"(",
"routeDefinition",
",",
"resource",
")",
"{",
"const",
"handler",
"=",
"{",
"// A \"path\" is an ordered (by key) set of values composed into the final URL",
"_path",
":",
"{",
"'0'",
":",
"resource",
",",
"}",
",",
"// A \"level\... | Create a node handler specification object from a route definition object
@name create
@param {object} routeDefinition A route definition object
@param {string} resource The string key of the resource for which to create a handler
@returns {object} A handler spec object with _path, _levels and _setters properties | [
"Create",
"a",
"node",
"handler",
"specification",
"object",
"from",
"a",
"route",
"definition",
"object"
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/lib/resource-handler-spec.js#L92-L122 |
12,574 | WP-API/node-wpapi | lib/path-part-setter.js | createPathPartSetter | function createPathPartSetter( node ) {
// Local references to `node` properties used by returned functions
const nodeLevel = node.level;
const nodeName = node.names[ 0 ];
const supportedMethods = node.methods || [];
const dynamicChildren = node.children ?
Object.keys( node.children )
.map( key => node.children[ key ] )
.filter( childNode => ( childNode.namedGroup === true ) ) :
[];
const dynamicChild = dynamicChildren.length === 1 && dynamicChildren[ 0 ];
const dynamicChildLevel = dynamicChild && dynamicChild.level;
if ( node.namedGroup ) {
/**
* Set a dymanic (named-group) path part of a query URL.
*
* @example
*
* // id() is a dynamic path part setter:
* wp.posts().id( 7 ); // Get posts/7
*
* @chainable
* @param {String|Number} val The path part value to set
* @returns {Object} The handler instance (for chaining)
*/
return function( val ) {
this.setPathPart( nodeLevel, val );
if ( supportedMethods.length ) {
this._supportedMethods = supportedMethods;
}
return this;
};
} else {
/**
* Set a non-dymanic (non-named-group) path part of a query URL, and
* set the value of a subresource if an input value is provided and
* exactly one named-group child node exists.
*
* @example
*
* // revisions() is a non-dynamic path part setter:
* wp.posts().id( 4 ).revisions(); // Get posts/4/revisions
* wp.posts().id( 4 ).revisions( 1372 ); // Get posts/4/revisions/1372
*
* @chainable
* @param {String|Number} [val] The path part value to set (if provided)
* for a subresource within this resource
* @returns {Object} The handler instance (for chaining)
*/
return function( val ) {
// If the path part is not a namedGroup, it should have exactly one
// entry in the names array: use that as the value for this setter,
// as it will usually correspond to a collection endpoint.
this.setPathPart( nodeLevel, nodeName );
// If this node has exactly one dynamic child, this method may act as
// a setter for that child node. `dynamicChildLevel` will be falsy if the
// node does not have a child or has multiple children.
if ( val !== undefined && dynamicChildLevel ) {
this.setPathPart( dynamicChildLevel, val );
}
return this;
};
}
} | javascript | function createPathPartSetter( node ) {
// Local references to `node` properties used by returned functions
const nodeLevel = node.level;
const nodeName = node.names[ 0 ];
const supportedMethods = node.methods || [];
const dynamicChildren = node.children ?
Object.keys( node.children )
.map( key => node.children[ key ] )
.filter( childNode => ( childNode.namedGroup === true ) ) :
[];
const dynamicChild = dynamicChildren.length === 1 && dynamicChildren[ 0 ];
const dynamicChildLevel = dynamicChild && dynamicChild.level;
if ( node.namedGroup ) {
/**
* Set a dymanic (named-group) path part of a query URL.
*
* @example
*
* // id() is a dynamic path part setter:
* wp.posts().id( 7 ); // Get posts/7
*
* @chainable
* @param {String|Number} val The path part value to set
* @returns {Object} The handler instance (for chaining)
*/
return function( val ) {
this.setPathPart( nodeLevel, val );
if ( supportedMethods.length ) {
this._supportedMethods = supportedMethods;
}
return this;
};
} else {
/**
* Set a non-dymanic (non-named-group) path part of a query URL, and
* set the value of a subresource if an input value is provided and
* exactly one named-group child node exists.
*
* @example
*
* // revisions() is a non-dynamic path part setter:
* wp.posts().id( 4 ).revisions(); // Get posts/4/revisions
* wp.posts().id( 4 ).revisions( 1372 ); // Get posts/4/revisions/1372
*
* @chainable
* @param {String|Number} [val] The path part value to set (if provided)
* for a subresource within this resource
* @returns {Object} The handler instance (for chaining)
*/
return function( val ) {
// If the path part is not a namedGroup, it should have exactly one
// entry in the names array: use that as the value for this setter,
// as it will usually correspond to a collection endpoint.
this.setPathPart( nodeLevel, nodeName );
// If this node has exactly one dynamic child, this method may act as
// a setter for that child node. `dynamicChildLevel` will be falsy if the
// node does not have a child or has multiple children.
if ( val !== undefined && dynamicChildLevel ) {
this.setPathPart( dynamicChildLevel, val );
}
return this;
};
}
} | [
"function",
"createPathPartSetter",
"(",
"node",
")",
"{",
"// Local references to `node` properties used by returned functions",
"const",
"nodeLevel",
"=",
"node",
".",
"level",
";",
"const",
"nodeName",
"=",
"node",
".",
"names",
"[",
"0",
"]",
";",
"const",
"supp... | Return a function to set part of the request URL path.
Path part setter methods may be either dynamic (*i.e.* may represent a
"named group") or non-dynamic (representing a static part of the URL, which
is usually a collection endpoint of some sort). Which type of function is
returned depends on whether a given route has one or many sub-resources.
@alias module:lib/path-part-setter.create
@param {Object} node An object representing a level of an endpoint path hierarchy
@returns {Function} A path part setter function | [
"Return",
"a",
"function",
"to",
"set",
"part",
"of",
"the",
"request",
"URL",
"path",
"."
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/lib/path-part-setter.js#L18-L83 |
12,575 | WP-API/node-wpapi | lib/wp-register-route.js | registerRoute | function registerRoute( namespace, restBase, options = {} ) {
// Support all methods until requested to do otherwise
let supportedMethods = [ 'head', 'get', 'patch', 'put', 'post', 'delete' ];
if ( Array.isArray( options.methods ) ) {
// Permit supported methods to be specified as an array
supportedMethods = options.methods.map( method => method.trim().toLowerCase() );
} else if ( typeof options.methods === 'string' ) {
// Permit a supported method to be specified as a string
supportedMethods = [ options.methods.trim().toLowerCase() ];
}
// Ensure that if GET is supported, then HEAD is as well, and vice-versa
if ( supportedMethods.indexOf( 'get' ) !== -1 && supportedMethods.indexOf( 'head' ) === -1 ) {
supportedMethods.push( 'head' );
} else if ( supportedMethods.indexOf( 'head' ) !== -1 && supportedMethods.indexOf( 'get' ) === -1 ) {
supportedMethods.push( 'get' );
}
const fullRoute = namespace
// Route should always have preceding slash
.replace( /^[\s/]*/, '/' )
// Route should always be joined to namespace with a single slash
.replace( /[\s/]*$/, '/' ) + restBase.replace( /^[\s/]*/, '' );
const routeObj = {};
routeObj[ fullRoute ] = {
namespace: namespace,
methods: supportedMethods,
};
// Go through the same steps used to bootstrap the client to parse the
// provided route out into a handler request method
const routeTree = buildRouteTree( routeObj );
// Parse the mock route object into endpoint factories
const endpointFactories = generateEndpointFactories( routeTree )[ namespace ];
const EndpointRequest = endpointFactories[ Object.keys( endpointFactories )[ 0 ] ].Ctor;
if ( options && options.params ) {
options.params.forEach( ( param ) => {
// Only accept string parameters
if ( typeof param !== 'string' ) {
return;
}
// If the parameter can be mapped to a mixin, apply that mixin
if ( typeof mixins[ param ] === 'object' ) {
Object.keys( mixins[ param ] ).forEach( ( key ) => {
applyMixin( EndpointRequest.prototype, key, mixins[ param ][ key ] );
} );
return;
}
// Attempt to create a simple setter for any parameters for which
// we do not already have a custom mixin
applyMixin( EndpointRequest.prototype, param, paramSetter( param ) );
} );
}
// Set any explicitly-provided object mixins
if ( options && typeof options.mixins === 'object' ) {
// Set any specified mixin functions on the response
Object.keys( options.mixins ).forEach( ( key ) => {
applyMixin( EndpointRequest.prototype, key, options.mixins[ key ] );
} );
}
function endpointFactory( options = {} ) {
return new EndpointRequest( {
...options,
...( this ? this._options : {} ),
} );
}
endpointFactory.Ctor = EndpointRequest;
return endpointFactory;
} | javascript | function registerRoute( namespace, restBase, options = {} ) {
// Support all methods until requested to do otherwise
let supportedMethods = [ 'head', 'get', 'patch', 'put', 'post', 'delete' ];
if ( Array.isArray( options.methods ) ) {
// Permit supported methods to be specified as an array
supportedMethods = options.methods.map( method => method.trim().toLowerCase() );
} else if ( typeof options.methods === 'string' ) {
// Permit a supported method to be specified as a string
supportedMethods = [ options.methods.trim().toLowerCase() ];
}
// Ensure that if GET is supported, then HEAD is as well, and vice-versa
if ( supportedMethods.indexOf( 'get' ) !== -1 && supportedMethods.indexOf( 'head' ) === -1 ) {
supportedMethods.push( 'head' );
} else if ( supportedMethods.indexOf( 'head' ) !== -1 && supportedMethods.indexOf( 'get' ) === -1 ) {
supportedMethods.push( 'get' );
}
const fullRoute = namespace
// Route should always have preceding slash
.replace( /^[\s/]*/, '/' )
// Route should always be joined to namespace with a single slash
.replace( /[\s/]*$/, '/' ) + restBase.replace( /^[\s/]*/, '' );
const routeObj = {};
routeObj[ fullRoute ] = {
namespace: namespace,
methods: supportedMethods,
};
// Go through the same steps used to bootstrap the client to parse the
// provided route out into a handler request method
const routeTree = buildRouteTree( routeObj );
// Parse the mock route object into endpoint factories
const endpointFactories = generateEndpointFactories( routeTree )[ namespace ];
const EndpointRequest = endpointFactories[ Object.keys( endpointFactories )[ 0 ] ].Ctor;
if ( options && options.params ) {
options.params.forEach( ( param ) => {
// Only accept string parameters
if ( typeof param !== 'string' ) {
return;
}
// If the parameter can be mapped to a mixin, apply that mixin
if ( typeof mixins[ param ] === 'object' ) {
Object.keys( mixins[ param ] ).forEach( ( key ) => {
applyMixin( EndpointRequest.prototype, key, mixins[ param ][ key ] );
} );
return;
}
// Attempt to create a simple setter for any parameters for which
// we do not already have a custom mixin
applyMixin( EndpointRequest.prototype, param, paramSetter( param ) );
} );
}
// Set any explicitly-provided object mixins
if ( options && typeof options.mixins === 'object' ) {
// Set any specified mixin functions on the response
Object.keys( options.mixins ).forEach( ( key ) => {
applyMixin( EndpointRequest.prototype, key, options.mixins[ key ] );
} );
}
function endpointFactory( options = {} ) {
return new EndpointRequest( {
...options,
...( this ? this._options : {} ),
} );
}
endpointFactory.Ctor = EndpointRequest;
return endpointFactory;
} | [
"function",
"registerRoute",
"(",
"namespace",
",",
"restBase",
",",
"options",
"=",
"{",
"}",
")",
"{",
"// Support all methods until requested to do otherwise",
"let",
"supportedMethods",
"=",
"[",
"'head'",
",",
"'get'",
",",
"'patch'",
",",
"'put'",
",",
"'pos... | Create and return a handler for an arbitrary WP REST API endpoint.
The first two parameters mirror `register_rest_route` in the REST API
codebase:
@memberof! WPAPI#
@param {string} namespace A namespace string, e.g. 'myplugin/v1'
@param {string} restBase A REST route string, e.g. '/author/(?P<id>\d+)'
@param {object} [options] An (optional) options object
@param {object} [options.mixins] A hash of functions to apply as mixins
@param {string[]} [options.methods] An array of methods to whitelist (on the leaf node only)
@returns {Function} An endpoint handler factory function for the specified route | [
"Create",
"and",
"return",
"a",
"handler",
"for",
"an",
"arbitrary",
"WP",
"REST",
"API",
"endpoint",
"."
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/lib/wp-register-route.js#L23-L100 |
12,576 | WP-API/node-wpapi | lib/route-tree.js | reduceRouteComponents | function reduceRouteComponents( routeObj, topLevel, parentLevel, component, idx, components ) {
// Check to see if this component is a dynamic URL segment (i.e. defined by
// a named capture group regular expression). namedGroup will be `null` if
// the regexp does not match, or else an array defining the RegExp match, e.g.
// [
// 'P<id>[\\d]+)',
// 'id', // Name of the group
// '[\\d]+', // regular expression for this URL segment's contents
// index: 15,
// input: '/wp/v2/posts/(?P<id>[\\d]+)'
// ]
const namedGroup = component.match( namedGroupRE );
// Pull out references to the relevant indices of the match, for utility:
// `null` checking is necessary in case the component did not match the RE,
// hence the `namedGroup &&`.
const groupName = namedGroup && namedGroup[ 1 ];
const groupPattern = namedGroup && namedGroup[ 2 ];
// When branching based on a dynamic capture group we used the group's RE
// pattern as the unique identifier: this is done because the same group
// could be assigned different names in different endpoint handlers, e.g.
// "id" for posts/:id vs "parent_id" for posts/:parent_id/revisions.
//
// There is an edge case where groupPattern will be "" if we are registering
// a custom route via `.registerRoute` that does not include parameter
// validation. In this case we assume the groupName is sufficiently unique,
// and fall back to `|| groupName` for the levelKey string.
const levelKey = namedGroup ? ( groupPattern || groupName ) : component;
// Level name on the other hand takes its value from the group's name, if
// defined, and falls back to the component string to handle situations where
// `component` is a collection (e.g. "revisions")
const levelName = namedGroup ? groupName : component;
// Check whether we have a preexisting node at this level of the tree, and
// create a new level object if not. The component string is included so that
// validators can throw meaningful errors as appropriate.
const currentLevel = parentLevel[ levelKey ] || {
component: component,
namedGroup: namedGroup ? true : false,
level: idx,
names: [],
};
// A level's "names" correspond to the list of strings which could describe
// an endpoint's component setter functions: "id", "revisions", etc.
if ( currentLevel.names.indexOf( levelName ) < 0 ) {
currentLevel.names.push( levelName );
}
// A level's validate method is called to check whether a value being set
// on the request URL is of the proper type for the location in which it
// is specified. If a group pattern was found, the validator checks whether
// the input string exactly matches the group pattern.
const groupPatternRE = groupPattern === '' ?
// If groupPattern is an empty string, accept any input without validation
/.*/ :
// Otherwise, validate against the group pattern or the component string
new RegExp( groupPattern ? '^' + groupPattern + '$' : component, 'i' );
// Only one validate function is maintained for each node, because each node
// is defined either by a string literal or by a specific regular expression.
currentLevel.validate = input => groupPatternRE.test( input );
// Check to see whether to expect more nodes within this branch of the tree,
if ( components[ idx + 1 ] ) {
// and create a "children" object to hold those nodes if necessary
currentLevel.children = currentLevel.children || {};
} else {
// At leaf nodes, specify the method capabilities of this endpoint
currentLevel.methods = ( routeObj.methods || [] ).map( str => str.toLowerCase() );
// Ensure HEAD is included whenever GET is supported: the API automatically
// adds support for HEAD if you have GET
if ( currentLevel.methods.indexOf( 'get' ) > -1 && currentLevel.methods.indexOf( 'head' ) === -1 ) {
currentLevel.methods.push( 'head' );
}
// At leaf nodes also flag (at the top level) what arguments are
// available to GET requests, so that we may automatically apply the
// appropriate parameter mixins
if ( routeObj.endpoints ) {
topLevel._getArgs = topLevel._getArgs || {};
routeObj.endpoints.forEach( ( endpoint ) => {
// `endpoint.methods` will be an array of methods like `[ 'GET' ]`: we
// only care about GET for this exercise. Validating POST and PUT args
// could be useful but is currently deemed to be out-of-scope.
endpoint.methods.forEach( ( method ) => {
if ( method.toLowerCase() === 'get' ) {
Object.keys( endpoint.args ).forEach( ( argKey ) => {
// Reference param definition objects in the top _getArgs dictionary
topLevel._getArgs[ argKey ] = endpoint.args[ argKey ];
} );
}
} );
} );
}
}
// Return the child node object as the new "level"
parentLevel[ levelKey ] = currentLevel;
return currentLevel.children;
} | javascript | function reduceRouteComponents( routeObj, topLevel, parentLevel, component, idx, components ) {
// Check to see if this component is a dynamic URL segment (i.e. defined by
// a named capture group regular expression). namedGroup will be `null` if
// the regexp does not match, or else an array defining the RegExp match, e.g.
// [
// 'P<id>[\\d]+)',
// 'id', // Name of the group
// '[\\d]+', // regular expression for this URL segment's contents
// index: 15,
// input: '/wp/v2/posts/(?P<id>[\\d]+)'
// ]
const namedGroup = component.match( namedGroupRE );
// Pull out references to the relevant indices of the match, for utility:
// `null` checking is necessary in case the component did not match the RE,
// hence the `namedGroup &&`.
const groupName = namedGroup && namedGroup[ 1 ];
const groupPattern = namedGroup && namedGroup[ 2 ];
// When branching based on a dynamic capture group we used the group's RE
// pattern as the unique identifier: this is done because the same group
// could be assigned different names in different endpoint handlers, e.g.
// "id" for posts/:id vs "parent_id" for posts/:parent_id/revisions.
//
// There is an edge case where groupPattern will be "" if we are registering
// a custom route via `.registerRoute` that does not include parameter
// validation. In this case we assume the groupName is sufficiently unique,
// and fall back to `|| groupName` for the levelKey string.
const levelKey = namedGroup ? ( groupPattern || groupName ) : component;
// Level name on the other hand takes its value from the group's name, if
// defined, and falls back to the component string to handle situations where
// `component` is a collection (e.g. "revisions")
const levelName = namedGroup ? groupName : component;
// Check whether we have a preexisting node at this level of the tree, and
// create a new level object if not. The component string is included so that
// validators can throw meaningful errors as appropriate.
const currentLevel = parentLevel[ levelKey ] || {
component: component,
namedGroup: namedGroup ? true : false,
level: idx,
names: [],
};
// A level's "names" correspond to the list of strings which could describe
// an endpoint's component setter functions: "id", "revisions", etc.
if ( currentLevel.names.indexOf( levelName ) < 0 ) {
currentLevel.names.push( levelName );
}
// A level's validate method is called to check whether a value being set
// on the request URL is of the proper type for the location in which it
// is specified. If a group pattern was found, the validator checks whether
// the input string exactly matches the group pattern.
const groupPatternRE = groupPattern === '' ?
// If groupPattern is an empty string, accept any input without validation
/.*/ :
// Otherwise, validate against the group pattern or the component string
new RegExp( groupPattern ? '^' + groupPattern + '$' : component, 'i' );
// Only one validate function is maintained for each node, because each node
// is defined either by a string literal or by a specific regular expression.
currentLevel.validate = input => groupPatternRE.test( input );
// Check to see whether to expect more nodes within this branch of the tree,
if ( components[ idx + 1 ] ) {
// and create a "children" object to hold those nodes if necessary
currentLevel.children = currentLevel.children || {};
} else {
// At leaf nodes, specify the method capabilities of this endpoint
currentLevel.methods = ( routeObj.methods || [] ).map( str => str.toLowerCase() );
// Ensure HEAD is included whenever GET is supported: the API automatically
// adds support for HEAD if you have GET
if ( currentLevel.methods.indexOf( 'get' ) > -1 && currentLevel.methods.indexOf( 'head' ) === -1 ) {
currentLevel.methods.push( 'head' );
}
// At leaf nodes also flag (at the top level) what arguments are
// available to GET requests, so that we may automatically apply the
// appropriate parameter mixins
if ( routeObj.endpoints ) {
topLevel._getArgs = topLevel._getArgs || {};
routeObj.endpoints.forEach( ( endpoint ) => {
// `endpoint.methods` will be an array of methods like `[ 'GET' ]`: we
// only care about GET for this exercise. Validating POST and PUT args
// could be useful but is currently deemed to be out-of-scope.
endpoint.methods.forEach( ( method ) => {
if ( method.toLowerCase() === 'get' ) {
Object.keys( endpoint.args ).forEach( ( argKey ) => {
// Reference param definition objects in the top _getArgs dictionary
topLevel._getArgs[ argKey ] = endpoint.args[ argKey ];
} );
}
} );
} );
}
}
// Return the child node object as the new "level"
parentLevel[ levelKey ] = currentLevel;
return currentLevel.children;
} | [
"function",
"reduceRouteComponents",
"(",
"routeObj",
",",
"topLevel",
",",
"parentLevel",
",",
"component",
",",
"idx",
",",
"components",
")",
"{",
"// Check to see if this component is a dynamic URL segment (i.e. defined by",
"// a named capture group regular expression). namedG... | Method to use when reducing route components array.
@private
@param {object} routeObj A route definition object (set via .bind partial application)
@param {object} topLevel The top-level route tree object for this set of routes (set
via .bind partial application)
@param {object} parentLevel The memo object, which is mutated as the reducer adds
a new level handler for each level in the route
@param {string} component The string defining this route component
@param {number} idx The index of this component within the components array
@param {string[]} components The array of all components
@returns {object} The child object of the level being reduced | [
"Method",
"to",
"use",
"when",
"reducing",
"route",
"components",
"array",
"."
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/lib/route-tree.js#L25-L127 |
12,577 | WP-API/node-wpapi | wpapi.js | WPAPI | function WPAPI( options ) {
// Enforce `new`
if ( this instanceof WPAPI === false ) {
return new WPAPI( options );
}
if ( typeof options.endpoint !== 'string' ) {
throw new Error( 'options hash must contain an API endpoint URL string' );
}
// Dictionary to be filled by handlers for default namespaces
this._ns = {};
this._options = {
// Ensure trailing slash on endpoint URI
endpoint: options.endpoint.replace( /\/?$/, '/' ),
};
// If any authentication credentials were provided, assign them now
if ( options && ( options.username || options.password || options.nonce ) ) {
this.auth( options );
}
return this
// Configure custom HTTP transport methods, if provided
.transport( options.transport )
// Bootstrap with a specific routes object, if provided
.bootstrap( options && options.routes );
} | javascript | function WPAPI( options ) {
// Enforce `new`
if ( this instanceof WPAPI === false ) {
return new WPAPI( options );
}
if ( typeof options.endpoint !== 'string' ) {
throw new Error( 'options hash must contain an API endpoint URL string' );
}
// Dictionary to be filled by handlers for default namespaces
this._ns = {};
this._options = {
// Ensure trailing slash on endpoint URI
endpoint: options.endpoint.replace( /\/?$/, '/' ),
};
// If any authentication credentials were provided, assign them now
if ( options && ( options.username || options.password || options.nonce ) ) {
this.auth( options );
}
return this
// Configure custom HTTP transport methods, if provided
.transport( options.transport )
// Bootstrap with a specific routes object, if provided
.bootstrap( options && options.routes );
} | [
"function",
"WPAPI",
"(",
"options",
")",
"{",
"// Enforce `new`",
"if",
"(",
"this",
"instanceof",
"WPAPI",
"===",
"false",
")",
"{",
"return",
"new",
"WPAPI",
"(",
"options",
")",
";",
"}",
"if",
"(",
"typeof",
"options",
".",
"endpoint",
"!==",
"'stri... | Construct a REST API client instance object to create
@constructor WPAPI
@param {Object} options An options hash to configure the instance
@param {String} options.endpoint The URI for a WP-API endpoint
@param {String} [options.username] A WP-API Basic Auth username
@param {String} [options.password] A WP-API Basic Auth password
@param {String} [options.nonce] A WP nonce for use with cookie authentication
@param {Object} [options.routes] A dictionary of API routes with which to
bootstrap the WPAPI instance: the instance will
be initialized with default routes only
if this property is omitted
@param {String} [options.transport] An optional dictionary of HTTP transport
methods (.get, .post, .put, .delete, .head)
to use instead of the defaults, e.g. to use
a different HTTP library than superagent | [
"Construct",
"a",
"REST",
"API",
"client",
"instance",
"object",
"to",
"create"
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/wpapi.js#L54-L83 |
12,578 | WP-API/node-wpapi | lib/constructors/wp-request.js | WPRequest | function WPRequest( options ) {
/**
* Configuration options for the request
*
* @property _options
* @type Object
* @private
* @default {}
*/
this._options = [
// Whitelisted options keys
'auth',
'endpoint',
'headers',
'username',
'password',
'nonce',
].reduce( ( localOptions, key ) => {
if ( options && options[ key ] ) {
localOptions[ key ] = options[ key ];
}
return localOptions;
}, {} );
/**
* The HTTP transport methods (.get, .post, .put, .delete, .head) to use for this request
*
* @property transport
* @type {Object}
* @private
*/
this.transport = options && options.transport;
/**
* A hash of query parameters
* This is used to store the values for supported query parameters like ?_embed
*
* @property _params
* @type Object
* @private
* @default {}
*/
this._params = {};
/**
* Methods supported by this API request instance:
* Individual endpoint handlers specify their own subset of supported methods
*
* @property _supportedMethods
* @type Array
* @private
* @default [ 'head', 'get', 'put', 'post', 'delete' ]
*/
this._supportedMethods = [ 'head', 'get', 'put', 'post', 'delete' ];
/**
* A hash of values to assemble into the API request path
* (This will be overwritten by each specific endpoint handler constructor)
*
* @property _path
* @type Object
* @private
* @default {}
*/
this._path = {};
} | javascript | function WPRequest( options ) {
/**
* Configuration options for the request
*
* @property _options
* @type Object
* @private
* @default {}
*/
this._options = [
// Whitelisted options keys
'auth',
'endpoint',
'headers',
'username',
'password',
'nonce',
].reduce( ( localOptions, key ) => {
if ( options && options[ key ] ) {
localOptions[ key ] = options[ key ];
}
return localOptions;
}, {} );
/**
* The HTTP transport methods (.get, .post, .put, .delete, .head) to use for this request
*
* @property transport
* @type {Object}
* @private
*/
this.transport = options && options.transport;
/**
* A hash of query parameters
* This is used to store the values for supported query parameters like ?_embed
*
* @property _params
* @type Object
* @private
* @default {}
*/
this._params = {};
/**
* Methods supported by this API request instance:
* Individual endpoint handlers specify their own subset of supported methods
*
* @property _supportedMethods
* @type Array
* @private
* @default [ 'head', 'get', 'put', 'post', 'delete' ]
*/
this._supportedMethods = [ 'head', 'get', 'put', 'post', 'delete' ];
/**
* A hash of values to assemble into the API request path
* (This will be overwritten by each specific endpoint handler constructor)
*
* @property _path
* @type Object
* @private
* @default {}
*/
this._path = {};
} | [
"function",
"WPRequest",
"(",
"options",
")",
"{",
"/**\n\t * Configuration options for the request\n\t *\n\t * @property _options\n\t * @type Object\n\t * @private\n\t * @default {}\n\t */",
"this",
".",
"_options",
"=",
"[",
"// Whitelisted options keys",
"'auth'",
",",
"'endpoint'",... | WPRequest is the base API request object constructor
@constructor WPRequest
@param {Object} options A hash of options for the WPRequest instance
@param {String} options.endpoint The endpoint URI for the invoking WPAPI instance
@param {Object} options.transport An object of http transport methods (get, post, etc)
@param {String} [options.username] A username for authenticating API requests
@param {String} [options.password] A password for authenticating API requests
@param {String} [options.nonce] A WP nonce for use with cookie authentication | [
"WPRequest",
"is",
"the",
"base",
"API",
"request",
"object",
"constructor"
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/lib/constructors/wp-request.js#L22-L87 |
12,579 | WP-API/node-wpapi | lib/endpoint-request.js | createEndpointRequest | function createEndpointRequest( handlerSpec, resource, namespace ) {
// Create the constructor function for this endpoint
class EndpointRequest extends WPRequest {
constructor( options ) {
super( options );
/**
* Semi-private instance property specifying the available URL path options
* for this endpoint request handler, keyed by ascending whole numbers.
*
* @property _levels
* @type {object}
* @private
*/
this._levels = handlerSpec._levels;
// Configure handler for this endpoint's root URL path & set namespace
this
.setPathPart( 0, resource )
.namespace( namespace );
}
}
// Mix in all available shortcut methods for GET request query parameters that
// are valid within this endpoint tree
if ( typeof handlerSpec._getArgs === 'object' ) {
Object.keys( handlerSpec._getArgs ).forEach( ( supportedQueryParam ) => {
const mixinsForParam = mixins[ supportedQueryParam ];
// Only proceed if there is a mixin available AND the specified mixins will
// not overwrite any previously-set prototype method
if ( typeof mixinsForParam === 'object' ) {
Object.keys( mixinsForParam ).forEach( ( methodName ) => {
applyMixin( EndpointRequest.prototype, methodName, mixinsForParam[ methodName ] );
} );
}
} );
}
Object.keys( handlerSpec._setters ).forEach( ( setterFnName ) => {
// Only assign setter functions if they do not overwrite preexisting methods
if ( ! EndpointRequest.prototype[ setterFnName ] ) {
EndpointRequest.prototype[ setterFnName ] = handlerSpec._setters[ setterFnName ];
}
} );
return EndpointRequest;
} | javascript | function createEndpointRequest( handlerSpec, resource, namespace ) {
// Create the constructor function for this endpoint
class EndpointRequest extends WPRequest {
constructor( options ) {
super( options );
/**
* Semi-private instance property specifying the available URL path options
* for this endpoint request handler, keyed by ascending whole numbers.
*
* @property _levels
* @type {object}
* @private
*/
this._levels = handlerSpec._levels;
// Configure handler for this endpoint's root URL path & set namespace
this
.setPathPart( 0, resource )
.namespace( namespace );
}
}
// Mix in all available shortcut methods for GET request query parameters that
// are valid within this endpoint tree
if ( typeof handlerSpec._getArgs === 'object' ) {
Object.keys( handlerSpec._getArgs ).forEach( ( supportedQueryParam ) => {
const mixinsForParam = mixins[ supportedQueryParam ];
// Only proceed if there is a mixin available AND the specified mixins will
// not overwrite any previously-set prototype method
if ( typeof mixinsForParam === 'object' ) {
Object.keys( mixinsForParam ).forEach( ( methodName ) => {
applyMixin( EndpointRequest.prototype, methodName, mixinsForParam[ methodName ] );
} );
}
} );
}
Object.keys( handlerSpec._setters ).forEach( ( setterFnName ) => {
// Only assign setter functions if they do not overwrite preexisting methods
if ( ! EndpointRequest.prototype[ setterFnName ] ) {
EndpointRequest.prototype[ setterFnName ] = handlerSpec._setters[ setterFnName ];
}
} );
return EndpointRequest;
} | [
"function",
"createEndpointRequest",
"(",
"handlerSpec",
",",
"resource",
",",
"namespace",
")",
"{",
"// Create the constructor function for this endpoint",
"class",
"EndpointRequest",
"extends",
"WPRequest",
"{",
"constructor",
"(",
"options",
")",
"{",
"super",
"(",
... | Create an endpoint request handler constructor for a specific resource tree
@method create
@param {Object} handlerSpec A resource handler specification object
@param {String} resource The root resource of requests created from the returned factory
@param {String} namespace The namespace string for the returned factory's handlers
@returns {Function} A constructor inheriting from {@link WPRequest} | [
"Create",
"an",
"endpoint",
"request",
"handler",
"constructor",
"for",
"a",
"specific",
"resource",
"tree"
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/lib/endpoint-request.js#L20-L68 |
12,580 | WP-API/node-wpapi | superagent/http-transport.js | _setHeaders | function _setHeaders( request, options ) {
// If there's no headers, do nothing
if ( ! options.headers ) {
return request;
}
return objectReduce(
options.headers,
( request, value, key ) => request.set( key, value ),
request
);
} | javascript | function _setHeaders( request, options ) {
// If there's no headers, do nothing
if ( ! options.headers ) {
return request;
}
return objectReduce(
options.headers,
( request, value, key ) => request.set( key, value ),
request
);
} | [
"function",
"_setHeaders",
"(",
"request",
",",
"options",
")",
"{",
"// If there's no headers, do nothing",
"if",
"(",
"!",
"options",
".",
"headers",
")",
"{",
"return",
"request",
";",
"}",
"return",
"objectReduce",
"(",
"options",
".",
"headers",
",",
"(",... | Set any provided headers on the outgoing request object. Runs after _auth.
@method _setHeaders
@private
@param {Object} request A superagent request object
@param {Object} options A WPRequest _options object
@param {Object} A superagent request object, with any available headers set | [
"Set",
"any",
"provided",
"headers",
"on",
"the",
"outgoing",
"request",
"object",
".",
"Runs",
"after",
"_auth",
"."
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/superagent/http-transport.js#L23-L34 |
12,581 | WP-API/node-wpapi | superagent/http-transport.js | _auth | function _auth( request, options, forceAuthentication ) {
// If we're not supposed to authenticate, don't even start
if ( ! forceAuthentication && ! options.auth && ! options.nonce ) {
return request;
}
// Enable nonce in options for Cookie authentication http://wp-api.org/guides/authentication.html
if ( options.nonce ) {
request.set( 'X-WP-Nonce', options.nonce );
return request;
}
// Retrieve the username & password from the request options if they weren't provided
const username = options.username;
const password = options.password;
// If no username or no password, can't authenticate
if ( ! username || ! password ) {
return request;
}
// Can authenticate: set basic auth parameters on the request
return request.auth( username, password );
} | javascript | function _auth( request, options, forceAuthentication ) {
// If we're not supposed to authenticate, don't even start
if ( ! forceAuthentication && ! options.auth && ! options.nonce ) {
return request;
}
// Enable nonce in options for Cookie authentication http://wp-api.org/guides/authentication.html
if ( options.nonce ) {
request.set( 'X-WP-Nonce', options.nonce );
return request;
}
// Retrieve the username & password from the request options if they weren't provided
const username = options.username;
const password = options.password;
// If no username or no password, can't authenticate
if ( ! username || ! password ) {
return request;
}
// Can authenticate: set basic auth parameters on the request
return request.auth( username, password );
} | [
"function",
"_auth",
"(",
"request",
",",
"options",
",",
"forceAuthentication",
")",
"{",
"// If we're not supposed to authenticate, don't even start",
"if",
"(",
"!",
"forceAuthentication",
"&&",
"!",
"options",
".",
"auth",
"&&",
"!",
"options",
".",
"nonce",
")"... | Conditionally set basic authentication on a server request object.
@method _auth
@private
@param {Object} request A superagent request object
@param {Object} options A WPRequest _options object
@param {Boolean} forceAuthentication whether to force authentication on the request
@param {Object} A superagent request object, conditionally configured to use basic auth | [
"Conditionally",
"set",
"basic",
"authentication",
"on",
"a",
"server",
"request",
"object",
"."
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/superagent/http-transport.js#L46-L69 |
12,582 | WP-API/node-wpapi | superagent/http-transport.js | createPaginationObject | function createPaginationObject( result, options, httpTransport ) {
let _paging = null;
if ( ! result.headers ) {
// No headers: return as-is
return _paging;
}
// Guard against capitalization inconsistencies in returned headers
Object.keys( result.headers ).forEach( ( header ) => {
result.headers[ header.toLowerCase() ] = result.headers[ header ];
} );
if ( ! result.headers[ 'x-wp-totalpages' ] ) {
// No paging: return as-is
return _paging;
}
const totalPages = +result.headers[ 'x-wp-totalpages' ];
if ( ! totalPages || totalPages === 0 ) {
// No paging: return as-is
return _paging;
}
// Decode the link header object
const links = result.headers.link ?
parseLinkHeader( result.headers.link ) :
{};
// Store pagination data from response headers on the response collection
_paging = {
total: +result.headers[ 'x-wp-total' ],
totalPages: totalPages,
links: links,
};
// Create a WPRequest instance pre-bound to the "next" page, if available
if ( links.next ) {
_paging.next = new WPRequest( {
...options,
transport: httpTransport,
endpoint: links.next,
} );
}
// Create a WPRequest instance pre-bound to the "prev" page, if available
if ( links.prev ) {
_paging.prev = new WPRequest( {
...options,
transport: httpTransport,
endpoint: links.prev,
} );
}
return _paging;
} | javascript | function createPaginationObject( result, options, httpTransport ) {
let _paging = null;
if ( ! result.headers ) {
// No headers: return as-is
return _paging;
}
// Guard against capitalization inconsistencies in returned headers
Object.keys( result.headers ).forEach( ( header ) => {
result.headers[ header.toLowerCase() ] = result.headers[ header ];
} );
if ( ! result.headers[ 'x-wp-totalpages' ] ) {
// No paging: return as-is
return _paging;
}
const totalPages = +result.headers[ 'x-wp-totalpages' ];
if ( ! totalPages || totalPages === 0 ) {
// No paging: return as-is
return _paging;
}
// Decode the link header object
const links = result.headers.link ?
parseLinkHeader( result.headers.link ) :
{};
// Store pagination data from response headers on the response collection
_paging = {
total: +result.headers[ 'x-wp-total' ],
totalPages: totalPages,
links: links,
};
// Create a WPRequest instance pre-bound to the "next" page, if available
if ( links.next ) {
_paging.next = new WPRequest( {
...options,
transport: httpTransport,
endpoint: links.next,
} );
}
// Create a WPRequest instance pre-bound to the "prev" page, if available
if ( links.prev ) {
_paging.prev = new WPRequest( {
...options,
transport: httpTransport,
endpoint: links.prev,
} );
}
return _paging;
} | [
"function",
"createPaginationObject",
"(",
"result",
",",
"options",
",",
"httpTransport",
")",
"{",
"let",
"_paging",
"=",
"null",
";",
"if",
"(",
"!",
"result",
".",
"headers",
")",
"{",
"// No headers: return as-is",
"return",
"_paging",
";",
"}",
"// Guard... | If the response is not paged, return the body as-is. If pagination
information is present in the response headers, parse those headers into
a custom `_paging` property on the response body. `_paging` contains links
to the previous and next pages in the collection, as well as metadata
about the size and number of pages in the collection.
The structure of the `_paging` property is as follows:
- `total` {Integer} The total number of records in the collection
- `totalPages` {Integer} The number of pages available
- `links` {Object} The parsed "links" headers, separated into individual URI strings
- `next` {WPRequest} A WPRequest object bound to the "next" page (if page exists)
- `prev` {WPRequest} A WPRequest object bound to the "previous" page (if page exists)
@private
@param {Object} result The response object from the HTTP request
@param {Object} options The options hash from the original request
@param {String} options.endpoint The base URL of the requested API endpoint
@param {Object} httpTransport The HTTP transport object used by the original request
@returns {Object} The pagination metadata object for this HTTP request, or else null | [
"If",
"the",
"response",
"is",
"not",
"paged",
"return",
"the",
"body",
"as",
"-",
"is",
".",
"If",
"pagination",
"information",
"is",
"present",
"in",
"the",
"response",
"headers",
"parse",
"those",
"headers",
"into",
"a",
"custom",
"_paging",
"property",
... | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/superagent/http-transport.js#L120-L176 |
12,583 | WP-API/node-wpapi | superagent/http-transport.js | returnBody | function returnBody( wpreq, result ) {
const body = extractResponseBody( result );
const _paging = createPaginationObject( result, wpreq._options, wpreq.transport );
if ( _paging ) {
body._paging = _paging;
}
return body;
} | javascript | function returnBody( wpreq, result ) {
const body = extractResponseBody( result );
const _paging = createPaginationObject( result, wpreq._options, wpreq.transport );
if ( _paging ) {
body._paging = _paging;
}
return body;
} | [
"function",
"returnBody",
"(",
"wpreq",
",",
"result",
")",
"{",
"const",
"body",
"=",
"extractResponseBody",
"(",
"result",
")",
";",
"const",
"_paging",
"=",
"createPaginationObject",
"(",
"result",
",",
"wpreq",
".",
"_options",
",",
"wpreq",
".",
"transp... | Return the body of the request, augmented with pagination information if the
result is a paged collection.
@private
@param {WPRequest} wpreq The WPRequest representing the returned HTTP response
@param {Object} result The results from the HTTP request
@returns {Object} The "body" property of the result, conditionally augmented with
pagination information if the result is a partial collection. | [
"Return",
"the",
"body",
"of",
"the",
"request",
"augmented",
"with",
"pagination",
"information",
"if",
"the",
"result",
"is",
"a",
"paged",
"collection",
"."
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/superagent/http-transport.js#L240-L247 |
12,584 | WP-API/node-wpapi | superagent/http-transport.js | _httpPost | function _httpPost( wpreq, data, callback ) {
checkMethodSupport( 'post', wpreq );
const url = wpreq.toString();
data = data || {};
let request = _auth( agent.post( url ), wpreq._options, true );
request = _setHeaders( request, wpreq._options );
if ( wpreq._attachment ) {
// Data must be form-encoded alongside image attachment
request = objectReduce(
data,
( req, value, key ) => req.field( key, value ),
request.attach( 'file', wpreq._attachment, wpreq._attachmentName )
);
} else {
request = request.send( data );
}
return invokeAndPromisify( request, callback, returnBody.bind( null, wpreq ) );
} | javascript | function _httpPost( wpreq, data, callback ) {
checkMethodSupport( 'post', wpreq );
const url = wpreq.toString();
data = data || {};
let request = _auth( agent.post( url ), wpreq._options, true );
request = _setHeaders( request, wpreq._options );
if ( wpreq._attachment ) {
// Data must be form-encoded alongside image attachment
request = objectReduce(
data,
( req, value, key ) => req.field( key, value ),
request.attach( 'file', wpreq._attachment, wpreq._attachmentName )
);
} else {
request = request.send( data );
}
return invokeAndPromisify( request, callback, returnBody.bind( null, wpreq ) );
} | [
"function",
"_httpPost",
"(",
"wpreq",
",",
"data",
",",
"callback",
")",
"{",
"checkMethodSupport",
"(",
"'post'",
",",
"wpreq",
")",
";",
"const",
"url",
"=",
"wpreq",
".",
"toString",
"(",
")",
";",
"data",
"=",
"data",
"||",
"{",
"}",
";",
"let",... | Invoke an HTTP "POST" request against the provided endpoint
@method post
@async
@param {WPRequest} wpreq A WPRequest query object
@param {Object} data The data for the POST request
@param {Function} [callback] A callback to invoke with the results of the POST request
@returns {Promise} A promise to the results of the HTTP request | [
"Invoke",
"an",
"HTTP",
"POST",
"request",
"against",
"the",
"provided",
"endpoint"
] | 613655cde217548bf1d7e2842b1b5e7a338114fd | https://github.com/WP-API/node-wpapi/blob/613655cde217548bf1d7e2842b1b5e7a338114fd/superagent/http-transport.js#L289-L308 |
12,585 | zeit/now-env | lib/apply-env.js | applyEnv | function applyEnv(env, secrets = {}, required = {}) {
if (Array.isArray(env)) {
env.forEach(key => {
// if the key already exists don't overwrite it
if (!process.env[key]) {
const value = getValue(key, {}, secrets, required)
process.env[key] = value
}
})
} else {
Object.entries(env).forEach(([key, value]) => {
// if the key already exists don't overwrite it
if (!process.env[key]) {
const value = getValue(key, env, secrets, required)
process.env[key] = value
}
})
}
} | javascript | function applyEnv(env, secrets = {}, required = {}) {
if (Array.isArray(env)) {
env.forEach(key => {
// if the key already exists don't overwrite it
if (!process.env[key]) {
const value = getValue(key, {}, secrets, required)
process.env[key] = value
}
})
} else {
Object.entries(env).forEach(([key, value]) => {
// if the key already exists don't overwrite it
if (!process.env[key]) {
const value = getValue(key, env, secrets, required)
process.env[key] = value
}
})
}
} | [
"function",
"applyEnv",
"(",
"env",
",",
"secrets",
"=",
"{",
"}",
",",
"required",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"env",
")",
")",
"{",
"env",
".",
"forEach",
"(",
"key",
"=>",
"{",
"// if the key already exists do... | Apply the environment variables to `process.env`
@param {Object} env Map of environment variables
@param {Object} secrets Map of secrets
@param {Object} required Map of required values | [
"Apply",
"the",
"environment",
"variables",
"to",
"process",
".",
"env"
] | 7761209e7c2500a17ca89398e62f65e6eb31af5d | https://github.com/zeit/now-env/blob/7761209e7c2500a17ca89398e62f65e6eb31af5d/lib/apply-env.js#L9-L27 |
12,586 | zeit/now-env | index.js | config | function config() {
// only run this if it's not running inside Now.sh
if (Boolean(process.env.NOW_REGION || process.env.NOW)) return
const secrets = loadSecrets()
const required = loadRequired()
// load environment variables from now.json
loadNowJSON(secrets, required)
} | javascript | function config() {
// only run this if it's not running inside Now.sh
if (Boolean(process.env.NOW_REGION || process.env.NOW)) return
const secrets = loadSecrets()
const required = loadRequired()
// load environment variables from now.json
loadNowJSON(secrets, required)
} | [
"function",
"config",
"(",
")",
"{",
"// only run this if it's not running inside Now.sh",
"if",
"(",
"Boolean",
"(",
"process",
".",
"env",
".",
"NOW_REGION",
"||",
"process",
".",
"env",
".",
"NOW",
")",
")",
"return",
"const",
"secrets",
"=",
"loadSecrets",
... | Check if is running inside Now.sh and apply variables and secrets to `process.env` | [
"Check",
"if",
"is",
"running",
"inside",
"Now",
".",
"sh",
"and",
"apply",
"variables",
"and",
"secrets",
"to",
"process",
".",
"env"
] | 7761209e7c2500a17ca89398e62f65e6eb31af5d | https://github.com/zeit/now-env/blob/7761209e7c2500a17ca89398e62f65e6eb31af5d/index.js#L11-L20 |
12,587 | RasCarlito/axios-cache-adapter | src/index.js | setupCache | function setupCache (config = {}) {
// Extend default configuration
config = makeConfig(config)
// Axios adapter. Receives the axios request configuration as only parameter
async function adapter (req) {
// Merge the per-request config with the instance config.
const reqConfig = mergeRequestConfig(config, req)
// Execute request against local cache
let res = await request(reqConfig, req)
let next = res.next
// Response is not function, something was in cache, return it
if (!isFunction(next)) return next
// Nothing in cache so we execute the default adapter or any given adapter
// Will throw if the request has a status different than 2xx
let networkError
try {
res = await reqConfig.adapter(req)
} catch (err) {
networkError = err
}
if (networkError) {
// Check if we should attempt reading stale cache data
let readOnError = isFunction(reqConfig.readOnError)
? reqConfig.readOnError(networkError, req)
: reqConfig.readOnError
if (readOnError) {
try {
// Force cache tu return stale data
reqConfig.acceptStale = true
// Try to read from cache again
res = await request(reqConfig, req)
// Signal that data is from stale cache
res.next.request.stale = true
// No need to check if `next` is a function just return cache data
return res.next
} catch (cacheReadError) {
// Failed to read stale cache, do nothing here, just let the network error be thrown
}
}
// Re-throw error so that it can be caught in userland if we didn't find any stale cache to read
throw networkError
}
// Process response to store in cache
return next(res)
}
// Return adapter and store instance
return {
adapter,
config,
store: config.store
}
} | javascript | function setupCache (config = {}) {
// Extend default configuration
config = makeConfig(config)
// Axios adapter. Receives the axios request configuration as only parameter
async function adapter (req) {
// Merge the per-request config with the instance config.
const reqConfig = mergeRequestConfig(config, req)
// Execute request against local cache
let res = await request(reqConfig, req)
let next = res.next
// Response is not function, something was in cache, return it
if (!isFunction(next)) return next
// Nothing in cache so we execute the default adapter or any given adapter
// Will throw if the request has a status different than 2xx
let networkError
try {
res = await reqConfig.adapter(req)
} catch (err) {
networkError = err
}
if (networkError) {
// Check if we should attempt reading stale cache data
let readOnError = isFunction(reqConfig.readOnError)
? reqConfig.readOnError(networkError, req)
: reqConfig.readOnError
if (readOnError) {
try {
// Force cache tu return stale data
reqConfig.acceptStale = true
// Try to read from cache again
res = await request(reqConfig, req)
// Signal that data is from stale cache
res.next.request.stale = true
// No need to check if `next` is a function just return cache data
return res.next
} catch (cacheReadError) {
// Failed to read stale cache, do nothing here, just let the network error be thrown
}
}
// Re-throw error so that it can be caught in userland if we didn't find any stale cache to read
throw networkError
}
// Process response to store in cache
return next(res)
}
// Return adapter and store instance
return {
adapter,
config,
store: config.store
}
} | [
"function",
"setupCache",
"(",
"config",
"=",
"{",
"}",
")",
"{",
"// Extend default configuration",
"config",
"=",
"makeConfig",
"(",
"config",
")",
"// Axios adapter. Receives the axios request configuration as only parameter",
"async",
"function",
"adapter",
"(",
"req",
... | Configure cache adapter
@param {object} [config={}] Cache adapter options
@returns {object} Object containing cache `adapter` and `store` | [
"Configure",
"cache",
"adapter"
] | af9808c2e862b32ac76a0921e9b27a310be83c67 | https://github.com/RasCarlito/axios-cache-adapter/blob/af9808c2e862b32ac76a0921e9b27a310be83c67/src/index.js#L16-L80 |
12,588 | parro-it/libui-node | examples/histogram.js | buildSolidBrush | function buildSolidBrush(color, alpha) {
let component;
component = (color >> 16) & 0xff;
const R = component / 255;
component = (color >> 8) & 0xff;
const G = component / 255;
component = color & 0xff;
const B = component / 255;
const A = alpha;
const brush = new libui.DrawBrush();
brush.color = new libui.Color(R, G, B, A);
brush.type = libui.brushType.solid;
return brush;
} | javascript | function buildSolidBrush(color, alpha) {
let component;
component = (color >> 16) & 0xff;
const R = component / 255;
component = (color >> 8) & 0xff;
const G = component / 255;
component = color & 0xff;
const B = component / 255;
const A = alpha;
const brush = new libui.DrawBrush();
brush.color = new libui.Color(R, G, B, A);
brush.type = libui.brushType.solid;
return brush;
} | [
"function",
"buildSolidBrush",
"(",
"color",
",",
"alpha",
")",
"{",
"let",
"component",
";",
"component",
"=",
"(",
"color",
">>",
"16",
")",
"&",
"0xff",
";",
"const",
"R",
"=",
"component",
"/",
"255",
";",
"component",
"=",
"(",
"color",
">>",
"8... | Helper to quickly set a brush color | [
"Helper",
"to",
"quickly",
"set",
"a",
"brush",
"color"
] | 7da20e42f446cae99088c6fbacad18ab2944061b | https://github.com/parro-it/libui-node/blob/7da20e42f446cae99088c6fbacad18ab2944061b/examples/histogram.js#L177-L193 |
12,589 | aishek/jquery-animateNumber | jquery.animateNumber.js | function(suffix) {
return function(now, tween) {
var floored_number = Math.floor(now),
target = $(tween.elem);
target.prop('number', now).text(floored_number + suffix);
};
} | javascript | function(suffix) {
return function(now, tween) {
var floored_number = Math.floor(now),
target = $(tween.elem);
target.prop('number', now).text(floored_number + suffix);
};
} | [
"function",
"(",
"suffix",
")",
"{",
"return",
"function",
"(",
"now",
",",
"tween",
")",
"{",
"var",
"floored_number",
"=",
"Math",
".",
"floor",
"(",
"now",
")",
",",
"target",
"=",
"$",
"(",
"tween",
".",
"elem",
")",
";",
"target",
".",
"prop",... | Creates numberStep handler, which appends string to floored animated number on each step.
@example
// will animate to 100 with "1 %", "2 %", "3 %", ...
$('#someid').animateNumber({
number: 100,
numberStep: $.animateNumber.numberStepFactories.append(' %')
});
@params {String} suffix string to append to animated number
@returns {Function} numberStep-compatible function for use in animateNumber's parameters | [
"Creates",
"numberStep",
"handler",
"which",
"appends",
"string",
"to",
"floored",
"animated",
"number",
"on",
"each",
"step",
"."
] | 59fa20d3f12b76ad19876ab7d04a9feb10b0ed80 | https://github.com/aishek/jquery-animateNumber/blob/59fa20d3f12b76ad19876ab7d04a9feb10b0ed80/jquery.animateNumber.js#L86-L93 | |
12,590 | aishek/jquery-animateNumber | jquery.animateNumber.js | function(separator, group_length, suffix) {
separator = separator || ' ';
group_length = group_length || 3;
suffix = suffix || '';
return function(now, tween) {
var negative = now < 0,
floored_number = Math.floor((negative ? -1 : 1) * now),
separated_number = floored_number.toString(),
target = $(tween.elem);
if (separated_number.length > group_length) {
var number_parts = extract_number_parts(separated_number, group_length);
separated_number = remove_precending_zeros(number_parts).join(separator);
separated_number = reverse(separated_number);
}
target.prop('number', now).text((negative ? '-' : '') + separated_number + suffix);
};
} | javascript | function(separator, group_length, suffix) {
separator = separator || ' ';
group_length = group_length || 3;
suffix = suffix || '';
return function(now, tween) {
var negative = now < 0,
floored_number = Math.floor((negative ? -1 : 1) * now),
separated_number = floored_number.toString(),
target = $(tween.elem);
if (separated_number.length > group_length) {
var number_parts = extract_number_parts(separated_number, group_length);
separated_number = remove_precending_zeros(number_parts).join(separator);
separated_number = reverse(separated_number);
}
target.prop('number', now).text((negative ? '-' : '') + separated_number + suffix);
};
} | [
"function",
"(",
"separator",
",",
"group_length",
",",
"suffix",
")",
"{",
"separator",
"=",
"separator",
"||",
"' '",
";",
"group_length",
"=",
"group_length",
"||",
"3",
";",
"suffix",
"=",
"suffix",
"||",
"''",
";",
"return",
"function",
"(",
"now",
... | Creates numberStep handler, which format floored numbers by separating them to groups.
@example
// will animate with 1 ... 217,980 ... 95,217,980 ... 7,095,217,980
$('#world-population').animateNumber({
number: 7095217980,
numberStep: $.animateNumber.numberStepFactories.separator(',')
});
@example
// will animate with 1% ... 217,980% ... 95,217,980% ... 7,095,217,980%
$('#salesIncrease').animateNumber({
number: 7095217980,
numberStep: $.animateNumber.numberStepFactories.separator(',', 3, '%')
});
@params {String} [separator=' '] string to separate number groups
@params {String} [group_length=3] number group length
@params {String} [suffix=''] suffix to append to number
@returns {Function} numberStep-compatible function for use in animateNumber's parameters | [
"Creates",
"numberStep",
"handler",
"which",
"format",
"floored",
"numbers",
"by",
"separating",
"them",
"to",
"groups",
"."
] | 59fa20d3f12b76ad19876ab7d04a9feb10b0ed80 | https://github.com/aishek/jquery-animateNumber/blob/59fa20d3f12b76ad19876ab7d04a9feb10b0ed80/jquery.animateNumber.js#L116-L136 | |
12,591 | Vestride/Shuffle | docs/js/demos/ajax.js | getMarkupFromData | function getMarkupFromData(dataForSingleItem) {
var name = dataForSingleItem.first_name + ' ' + dataForSingleItem.last_name;
// https://www.paulirish.com/2009/random-hex-color-code-snippets/
var randomColor = ('000000' + Math.random().toString(16).slice(2, 8)).slice(-6);
return [
'<div class="js-item col-3@xs col-3@sm person-item" data-id="' + dataForSingleItem.id + '">',
'<div class="person-item__inner" style="background-color:#' + randomColor + '">',
'<span>' + name + '</span>',
'</div>',
'</div>',
].join('');
} | javascript | function getMarkupFromData(dataForSingleItem) {
var name = dataForSingleItem.first_name + ' ' + dataForSingleItem.last_name;
// https://www.paulirish.com/2009/random-hex-color-code-snippets/
var randomColor = ('000000' + Math.random().toString(16).slice(2, 8)).slice(-6);
return [
'<div class="js-item col-3@xs col-3@sm person-item" data-id="' + dataForSingleItem.id + '">',
'<div class="person-item__inner" style="background-color:#' + randomColor + '">',
'<span>' + name + '</span>',
'</div>',
'</div>',
].join('');
} | [
"function",
"getMarkupFromData",
"(",
"dataForSingleItem",
")",
"{",
"var",
"name",
"=",
"dataForSingleItem",
".",
"first_name",
"+",
"' '",
"+",
"dataForSingleItem",
".",
"last_name",
";",
"// https://www.paulirish.com/2009/random-hex-color-code-snippets/",
"var",
"randomC... | Convert an object to HTML markup for an item.
@param {object} dataForSingleItem Data object.
@return {string} | [
"Convert",
"an",
"object",
"to",
"HTML",
"markup",
"for",
"an",
"item",
"."
] | 9fd4b557b6030e23c5b4b8e68233a42833df423f | https://github.com/Vestride/Shuffle/blob/9fd4b557b6030e23c5b4b8e68233a42833df423f/docs/js/demos/ajax.js#L66-L77 |
12,592 | Vestride/Shuffle | docs/js/demos/ajax.js | replaceLoadMoreButton | function replaceLoadMoreButton() {
var text = document.createTextNode('All users loaded');
var replacement = document.createElement('p');
replacement.appendChild(text);
loadMoreButton.parentNode.replaceChild(replacement, loadMoreButton);
} | javascript | function replaceLoadMoreButton() {
var text = document.createTextNode('All users loaded');
var replacement = document.createElement('p');
replacement.appendChild(text);
loadMoreButton.parentNode.replaceChild(replacement, loadMoreButton);
} | [
"function",
"replaceLoadMoreButton",
"(",
")",
"{",
"var",
"text",
"=",
"document",
".",
"createTextNode",
"(",
"'All users loaded'",
")",
";",
"var",
"replacement",
"=",
"document",
".",
"createElement",
"(",
"'p'",
")",
";",
"replacement",
".",
"appendChild",
... | Remove the load more button so that the user cannot click it again. | [
"Remove",
"the",
"load",
"more",
"button",
"so",
"that",
"the",
"user",
"cannot",
"click",
"it",
"again",
"."
] | 9fd4b557b6030e23c5b4b8e68233a42833df423f | https://github.com/Vestride/Shuffle/blob/9fd4b557b6030e23c5b4b8e68233a42833df423f/docs/js/demos/ajax.js#L101-L106 |
12,593 | Vestride/Shuffle | docs/js/demos/react.js | PhotoItem | function PhotoItem({ id, username, src, name }) {
return (
<div key={id} className="col-3@xs col-4@sm photo-item">
<div className="aspect aspect--4x3">
<div className="aspect__inner">
<img src={src} />
<PhotoAttribution username={username} name={name} />
</div>
</div>
</div>
)
} | javascript | function PhotoItem({ id, username, src, name }) {
return (
<div key={id} className="col-3@xs col-4@sm photo-item">
<div className="aspect aspect--4x3">
<div className="aspect__inner">
<img src={src} />
<PhotoAttribution username={username} name={name} />
</div>
</div>
</div>
)
} | [
"function",
"PhotoItem",
"(",
"{",
"id",
",",
"username",
",",
"src",
",",
"name",
"}",
")",
"{",
"return",
"(",
"<",
"div",
"key",
"=",
"{",
"id",
"}",
"className",
"=",
"\"col-3@xs col-4@sm photo-item\"",
">",
"\n ",
"<",
"div",
"className",
"=",
... | A grid item for a photo.
@param {{ id: number, username: string, src: string, name: string }} props Component props.
@return {JSX.Element} | [
"A",
"grid",
"item",
"for",
"a",
"photo",
"."
] | 9fd4b557b6030e23c5b4b8e68233a42833df423f | https://github.com/Vestride/Shuffle/blob/9fd4b557b6030e23c5b4b8e68233a42833df423f/docs/js/demos/react.js#L123-L134 |
12,594 | Vestride/Shuffle | docs/js/demos/react.js | PhotoAttribution | function PhotoAttribution({ username, name }) {
if (!username) {
return null;
}
const href = `https://unsplash.com/${username}?utm_medium=referral&utm_campaign=photographer-credit&utm_content=creditBadge`;
const title = `Download free do whatever you want high-resolution photos from ${name}`;
return (
<a className="photo-attribution" href={href} target="_blank" rel="noopener noreferrer" title={title}>
<span>
<svg viewBox="0 0 32 32">
<path d="M20.8 18.1c0 2.7-2.2 4.8-4.8 4.8s-4.8-2.1-4.8-4.8c0-2.7 2.2-4.8 4.8-4.8 2.7.1 4.8 2.2 4.8 4.8zm11.2-7.4v14.9c0 2.3-1.9 4.3-4.3 4.3h-23.4c-2.4 0-4.3-1.9-4.3-4.3v-15c0-2.3 1.9-4.3 4.3-4.3h3.7l.8-2.3c.4-1.1 1.7-2 2.9-2h8.6c1.2 0 2.5.9 2.9 2l.8 2.4h3.7c2.4 0 4.3 1.9 4.3 4.3zm-8.6 7.5c0-4.1-3.3-7.5-7.5-7.5-4.1 0-7.5 3.4-7.5 7.5s3.3 7.5 7.5 7.5c4.2-.1 7.5-3.4 7.5-7.5z"></path>
</svg>
</span>
<span>{name}</span>
</a>
);
} | javascript | function PhotoAttribution({ username, name }) {
if (!username) {
return null;
}
const href = `https://unsplash.com/${username}?utm_medium=referral&utm_campaign=photographer-credit&utm_content=creditBadge`;
const title = `Download free do whatever you want high-resolution photos from ${name}`;
return (
<a className="photo-attribution" href={href} target="_blank" rel="noopener noreferrer" title={title}>
<span>
<svg viewBox="0 0 32 32">
<path d="M20.8 18.1c0 2.7-2.2 4.8-4.8 4.8s-4.8-2.1-4.8-4.8c0-2.7 2.2-4.8 4.8-4.8 2.7.1 4.8 2.2 4.8 4.8zm11.2-7.4v14.9c0 2.3-1.9 4.3-4.3 4.3h-23.4c-2.4 0-4.3-1.9-4.3-4.3v-15c0-2.3 1.9-4.3 4.3-4.3h3.7l.8-2.3c.4-1.1 1.7-2 2.9-2h8.6c1.2 0 2.5.9 2.9 2l.8 2.4h3.7c2.4 0 4.3 1.9 4.3 4.3zm-8.6 7.5c0-4.1-3.3-7.5-7.5-7.5-4.1 0-7.5 3.4-7.5 7.5s3.3 7.5 7.5 7.5c4.2-.1 7.5-3.4 7.5-7.5z"></path>
</svg>
</span>
<span>{name}</span>
</a>
);
} | [
"function",
"PhotoAttribution",
"(",
"{",
"username",
",",
"name",
"}",
")",
"{",
"if",
"(",
"!",
"username",
")",
"{",
"return",
"null",
";",
"}",
"const",
"href",
"=",
"`",
"${",
"username",
"}",
"`",
";",
"const",
"title",
"=",
"`",
"${",
"name"... | A small badge with a link to the author of the photo's profile.
@param {{ username: string, name: string }} props Component props.
@return {JSX.Element} | [
"A",
"small",
"badge",
"with",
"a",
"link",
"to",
"the",
"author",
"of",
"the",
"photo",
"s",
"profile",
"."
] | 9fd4b557b6030e23c5b4b8e68233a42833df423f | https://github.com/Vestride/Shuffle/blob/9fd4b557b6030e23c5b4b8e68233a42833df423f/docs/js/demos/react.js#L141-L158 |
12,595 | ondras/rot.js | lib/map/ellermaze.js | addToList | function addToList(i, L, R) {
R[L[i + 1]] = R[i];
L[R[i]] = L[i + 1];
R[i] = i + 1;
L[i + 1] = i;
} | javascript | function addToList(i, L, R) {
R[L[i + 1]] = R[i];
L[R[i]] = L[i + 1];
R[i] = i + 1;
L[i + 1] = i;
} | [
"function",
"addToList",
"(",
"i",
",",
"L",
",",
"R",
")",
"{",
"R",
"[",
"L",
"[",
"i",
"+",
"1",
"]",
"]",
"=",
"R",
"[",
"i",
"]",
";",
"L",
"[",
"R",
"[",
"i",
"]",
"]",
"=",
"L",
"[",
"i",
"+",
"1",
"]",
";",
"R",
"[",
"i",
... | Join lists with "i" and "i+1" | [
"Join",
"lists",
"with",
"i",
"and",
"i",
"+",
"1"
] | 57c4c9e22fa4614f69f42d34ccc83f679615bbf1 | https://github.com/ondras/rot.js/blob/57c4c9e22fa4614f69f42d34ccc83f679615bbf1/lib/map/ellermaze.js#L6-L11 |
12,596 | ondras/rot.js | lib/map/ellermaze.js | removeFromList | function removeFromList(i, L, R) {
R[L[i]] = R[i];
L[R[i]] = L[i];
R[i] = i;
L[i] = i;
} | javascript | function removeFromList(i, L, R) {
R[L[i]] = R[i];
L[R[i]] = L[i];
R[i] = i;
L[i] = i;
} | [
"function",
"removeFromList",
"(",
"i",
",",
"L",
",",
"R",
")",
"{",
"R",
"[",
"L",
"[",
"i",
"]",
"]",
"=",
"R",
"[",
"i",
"]",
";",
"L",
"[",
"R",
"[",
"i",
"]",
"]",
"=",
"L",
"[",
"i",
"]",
";",
"R",
"[",
"i",
"]",
"=",
"i",
";... | Remove "i" from its list | [
"Remove",
"i",
"from",
"its",
"list"
] | 57c4c9e22fa4614f69f42d34ccc83f679615bbf1 | https://github.com/ondras/rot.js/blob/57c4c9e22fa4614f69f42d34ccc83f679615bbf1/lib/map/ellermaze.js#L15-L20 |
12,597 | ondras/rot.js | lib/text.js | breakInsideToken | function breakInsideToken(tokens, tokenIndex, breakIndex, removeBreakChar) {
let newBreakToken = {
type: TYPE_NEWLINE
};
let newTextToken = {
type: TYPE_TEXT,
value: tokens[tokenIndex].value.substring(breakIndex + (removeBreakChar ? 1 : 0))
};
tokens.splice(tokenIndex + 1, 0, newBreakToken, newTextToken);
return tokens[tokenIndex].value.substring(0, breakIndex);
} | javascript | function breakInsideToken(tokens, tokenIndex, breakIndex, removeBreakChar) {
let newBreakToken = {
type: TYPE_NEWLINE
};
let newTextToken = {
type: TYPE_TEXT,
value: tokens[tokenIndex].value.substring(breakIndex + (removeBreakChar ? 1 : 0))
};
tokens.splice(tokenIndex + 1, 0, newBreakToken, newTextToken);
return tokens[tokenIndex].value.substring(0, breakIndex);
} | [
"function",
"breakInsideToken",
"(",
"tokens",
",",
"tokenIndex",
",",
"breakIndex",
",",
"removeBreakChar",
")",
"{",
"let",
"newBreakToken",
"=",
"{",
"type",
":",
"TYPE_NEWLINE",
"}",
";",
"let",
"newTextToken",
"=",
"{",
"type",
":",
"TYPE_TEXT",
",",
"v... | Create new tokens and insert them into the stream
@param {object[]} tokens
@param {int} tokenIndex Token being processed
@param {int} breakIndex Index within current token's value
@param {bool} removeBreakChar Do we want to remove the breaking character?
@returns {string} remaining unbroken token value | [
"Create",
"new",
"tokens",
"and",
"insert",
"them",
"into",
"the",
"stream"
] | 57c4c9e22fa4614f69f42d34ccc83f679615bbf1 | https://github.com/ondras/rot.js/blob/57c4c9e22fa4614f69f42d34ccc83f679615bbf1/lib/text.js#L172-L182 |
12,598 | aframevr/aframe-inspector | src/lib/entity.js | insertAfter | function insertAfter(newNode, referenceNode) {
if (!referenceNode.parentNode) {
referenceNode = AFRAME.INSPECTOR.selectedEntity;
}
if (!referenceNode) {
AFRAME.INSPECTOR.sceneEl.appendChild(newNode);
} else {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
} | javascript | function insertAfter(newNode, referenceNode) {
if (!referenceNode.parentNode) {
referenceNode = AFRAME.INSPECTOR.selectedEntity;
}
if (!referenceNode) {
AFRAME.INSPECTOR.sceneEl.appendChild(newNode);
} else {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
} | [
"function",
"insertAfter",
"(",
"newNode",
",",
"referenceNode",
")",
"{",
"if",
"(",
"!",
"referenceNode",
".",
"parentNode",
")",
"{",
"referenceNode",
"=",
"AFRAME",
".",
"INSPECTOR",
".",
"selectedEntity",
";",
"}",
"if",
"(",
"!",
"referenceNode",
")",
... | Insert an node after a referenced node.
@param {Element} newNode Node to insert.
@param {Element} referenceNode Node used as reference to insert after it. | [
"Insert",
"an",
"node",
"after",
"a",
"referenced",
"node",
"."
] | bb0de5e92e4f0ee727726d5f580a0876d5e49047 | https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L112-L122 |
12,599 | aframevr/aframe-inspector | src/lib/entity.js | prepareForSerialization | function prepareForSerialization(entity) {
var clone = entity.cloneNode(false);
var children = entity.childNodes;
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
if (
child.nodeType !== Node.ELEMENT_NODE ||
(!child.hasAttribute('aframe-injected') &&
!child.hasAttribute('data-aframe-inspector') &&
!child.hasAttribute('data-aframe-canvas'))
) {
clone.appendChild(prepareForSerialization(children[i]));
}
}
optimizeComponents(clone, entity);
return clone;
} | javascript | function prepareForSerialization(entity) {
var clone = entity.cloneNode(false);
var children = entity.childNodes;
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
if (
child.nodeType !== Node.ELEMENT_NODE ||
(!child.hasAttribute('aframe-injected') &&
!child.hasAttribute('data-aframe-inspector') &&
!child.hasAttribute('data-aframe-canvas'))
) {
clone.appendChild(prepareForSerialization(children[i]));
}
}
optimizeComponents(clone, entity);
return clone;
} | [
"function",
"prepareForSerialization",
"(",
"entity",
")",
"{",
"var",
"clone",
"=",
"entity",
".",
"cloneNode",
"(",
"false",
")",
";",
"var",
"children",
"=",
"entity",
".",
"childNodes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"childre... | Returns a copy of the DOM hierarchy prepared for serialization.
The process optimises component representation to avoid values coming from
primitive attributes, mixins and defaults.
@param {Element} entity Root of the DOM hierarchy.
@return {Elment} Copy of the DOM hierarchy ready for serialization. | [
"Returns",
"a",
"copy",
"of",
"the",
"DOM",
"hierarchy",
"prepared",
"for",
"serialization",
".",
"The",
"process",
"optimises",
"component",
"representation",
"to",
"avoid",
"values",
"coming",
"from",
"primitive",
"attributes",
"mixins",
"and",
"defaults",
"."
] | bb0de5e92e4f0ee727726d5f580a0876d5e49047 | https://github.com/aframevr/aframe-inspector/blob/bb0de5e92e4f0ee727726d5f580a0876d5e49047/src/lib/entity.js#L171-L187 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.