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
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
bq/corbel-js
dist/corbel.with-polyfills.js
function(scopes) { console.log('iamInterface.group.addScopes', scopes); corbel.validate.value('id', this.id); return this.request({ url: this._buildUriWithDomain(this.uri, this.id) + '/scope', method: corbel.request.method.PUT, data: scopes, withAuth: true }); }
javascript
function(scopes) { console.log('iamInterface.group.addScopes', scopes); corbel.validate.value('id', this.id); return this.request({ url: this._buildUriWithDomain(this.uri, this.id) + '/scope', method: corbel.request.method.PUT, data: scopes, withAuth: true }); }
[ "function", "(", "scopes", ")", "{", "console", ".", "log", "(", "'iamInterface.group.addScopes'", ",", "scopes", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'id'", ",", "this", ".", "id", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", ",", "this", ".", "id", ")", "+", "'/scope'", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "data", ":", "scopes", ",", "withAuth", ":", "true", "}", ")", ";", "}" ]
Add scopes to a group. @method @memberOf corbel.Iam.GroupBuilder @param {Array} scopes Group scopes to add. @return {Promise} A promise which resolves to undefined(void) or fails with a {@link SilkRoadError}.
[ "Add", "scopes", "to", "a", "group", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L4658-L4667
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(email) { console.log('iamInterface.email.availability', email); corbel.validate.value('email', email); return this.request({ url: this._buildUriWithDomain(this.uri, email), method: corbel.request.method.HEAD }).then( function() { return false; }, function(response) { if (response.status === 404) { return true; } else { return Promise.reject(response); } } ); }
javascript
function(email) { console.log('iamInterface.email.availability', email); corbel.validate.value('email', email); return this.request({ url: this._buildUriWithDomain(this.uri, email), method: corbel.request.method.HEAD }).then( function() { return false; }, function(response) { if (response.status === 404) { return true; } else { return Promise.reject(response); } } ); }
[ "function", "(", "email", ")", "{", "console", ".", "log", "(", "'iamInterface.email.availability'", ",", "email", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'email'", ",", "email", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", ",", "email", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "HEAD", "}", ")", ".", "then", "(", "function", "(", ")", "{", "return", "false", ";", "}", ",", "function", "(", "response", ")", "{", "if", "(", "response", ".", "status", "===", "404", ")", "{", "return", "true", ";", "}", "else", "{", "return", "Promise", ".", "reject", "(", "response", ")", ";", "}", "}", ")", ";", "}" ]
Return availability endpoint. @method @memberOf corbel.Iam.EmailBuilder @param {String} email The email. @return {Promise} A promise which resolves into email availability boolean state.
[ "Return", "availability", "endpoint", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L4763-L4782
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(srcType, srcId, destType, destId) { var urlBase = this.driver.config.getCurrentEndpoint(corbel.Resources.moduleName, this._buildPort(this.driver.config)); var domain = this.driver.config.get(corbel.Iam.IAM_DOMAIN, 'unauthenticated'); var customDomain = this.driver.config.get(corbel.Domain.CUSTOM_DOMAIN, domain); this.driver.config.set(corbel.Domain.CUSTOM_DOMAIN, undefined); var uri = urlBase + customDomain + '/resource/' + srcType; if (srcId) { uri += '/' + srcId; if (destType) { uri += '/' + destType; if (destId) { uri += ';r=' + destType + '/' + destId; } } } return uri; }
javascript
function(srcType, srcId, destType, destId) { var urlBase = this.driver.config.getCurrentEndpoint(corbel.Resources.moduleName, this._buildPort(this.driver.config)); var domain = this.driver.config.get(corbel.Iam.IAM_DOMAIN, 'unauthenticated'); var customDomain = this.driver.config.get(corbel.Domain.CUSTOM_DOMAIN, domain); this.driver.config.set(corbel.Domain.CUSTOM_DOMAIN, undefined); var uri = urlBase + customDomain + '/resource/' + srcType; if (srcId) { uri += '/' + srcId; if (destType) { uri += '/' + destType; if (destId) { uri += ';r=' + destType + '/' + destId; } } } return uri; }
[ "function", "(", "srcType", ",", "srcId", ",", "destType", ",", "destId", ")", "{", "var", "urlBase", "=", "this", ".", "driver", ".", "config", ".", "getCurrentEndpoint", "(", "corbel", ".", "Resources", ".", "moduleName", ",", "this", ".", "_buildPort", "(", "this", ".", "driver", ".", "config", ")", ")", ";", "var", "domain", "=", "this", ".", "driver", ".", "config", ".", "get", "(", "corbel", ".", "Iam", ".", "IAM_DOMAIN", ",", "'unauthenticated'", ")", ";", "var", "customDomain", "=", "this", ".", "driver", ".", "config", ".", "get", "(", "corbel", ".", "Domain", ".", "CUSTOM_DOMAIN", ",", "domain", ")", ";", "this", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Domain", ".", "CUSTOM_DOMAIN", ",", "undefined", ")", ";", "var", "uri", "=", "urlBase", "+", "customDomain", "+", "'/resource/'", "+", "srcType", ";", "if", "(", "srcId", ")", "{", "uri", "+=", "'/'", "+", "srcId", ";", "if", "(", "destType", ")", "{", "uri", "+=", "'/'", "+", "destType", ";", "if", "(", "destId", ")", "{", "uri", "+=", "';r='", "+", "destType", "+", "'/'", "+", "destId", ";", "}", "}", "}", "return", "uri", ";", "}" ]
Helper function to build the request uri @param {String} srcType Type of the resource @param {String} srcId Id of the resource @param {String} relType Type of the relationed resource @param {String} destId Information of the relationed resource @return {String} Uri to perform the request
[ "Helper", "function", "to", "build", "the", "request", "uri" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L5457-L5479
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(destId, relationData, options) { options = this.getDefaultOptions(options); corbel.validate.value('destId', destId); var args = corbel.utils.extend(options, { url: this.buildUri(this.type, this.srcId, this.destType, destId), data: relationData, method: corbel.request.method.PUT, contentType: options.dataType, Accept: options.dataType }); return this.request(args); }
javascript
function(destId, relationData, options) { options = this.getDefaultOptions(options); corbel.validate.value('destId', destId); var args = corbel.utils.extend(options, { url: this.buildUri(this.type, this.srcId, this.destType, destId), data: relationData, method: corbel.request.method.PUT, contentType: options.dataType, Accept: options.dataType }); return this.request(args); }
[ "function", "(", "destId", ",", "relationData", ",", "options", ")", "{", "options", "=", "this", ".", "getDefaultOptions", "(", "options", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'destId'", ",", "destId", ")", ";", "var", "args", "=", "corbel", ".", "utils", ".", "extend", "(", "options", ",", "{", "url", ":", "this", ".", "buildUri", "(", "this", ".", "type", ",", "this", ".", "srcId", ",", "this", ".", "destType", ",", "destId", ")", ",", "data", ":", "relationData", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "contentType", ":", "options", ".", "dataType", ",", "Accept", ":", "options", ".", "dataType", "}", ")", ";", "return", "this", ".", "request", "(", "args", ")", ";", "}" ]
Adds a new relation between Resources @method @memberOf Resources.Relation @param {String} destId Relationed resource @param {Object} relationData Additional data to be added to the relation (in json) @return {Promise} ES6 promise that resolves to undefined (void) or rejects with a {@link CorbelError} @example uri = '555'
[ "Adds", "a", "new", "relation", "between", "Resources" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L5566-L5579
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(relationData, options) { options = this.getDefaultOptions(options); var args = corbel.utils.extend(options, { url: this.buildUri(this.type, this.srcId, this.destType), data: relationData, method: corbel.request.method.POST, contentType: options.dataType, Accept: options.dataType }); return this.request(args); }
javascript
function(relationData, options) { options = this.getDefaultOptions(options); var args = corbel.utils.extend(options, { url: this.buildUri(this.type, this.srcId, this.destType), data: relationData, method: corbel.request.method.POST, contentType: options.dataType, Accept: options.dataType }); return this.request(args); }
[ "function", "(", "relationData", ",", "options", ")", "{", "options", "=", "this", ".", "getDefaultOptions", "(", "options", ")", ";", "var", "args", "=", "corbel", ".", "utils", ".", "extend", "(", "options", ",", "{", "url", ":", "this", ".", "buildUri", "(", "this", ".", "type", ",", "this", ".", "srcId", ",", "this", ".", "destType", ")", ",", "data", ":", "relationData", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "contentType", ":", "options", ".", "dataType", ",", "Accept", ":", "options", ".", "dataType", "}", ")", ";", "return", "this", ".", "request", "(", "args", ")", ";", "}" ]
Adds a new anonymous relation @method @memberOf Resources.Relation @param {Object} relationData Additional data to be added to the relation (in json) @return {Promise} ES6 promise that resolves to undefined (void) or rejects with a {@link CorbelError} @example uri = '555'
[ "Adds", "a", "new", "anonymous", "relation" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L5589-L5601
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(destId, pos, options) { corbel.validate.value('destId', destId); var positionStartId = destId.indexOf('/'); if (positionStartId !== -1) { destId = destId.substring(positionStartId + 1); } options = this.getDefaultOptions(options); var args = corbel.utils.extend(options, { url: this.buildUri(this.type, this.srcId, this.destType, destId), contentType: 'application/json', data: { '_order': '$pos(' + pos + ')' }, method: corbel.request.method.PUT }); return this.request(args); }
javascript
function(destId, pos, options) { corbel.validate.value('destId', destId); var positionStartId = destId.indexOf('/'); if (positionStartId !== -1) { destId = destId.substring(positionStartId + 1); } options = this.getDefaultOptions(options); var args = corbel.utils.extend(options, { url: this.buildUri(this.type, this.srcId, this.destType, destId), contentType: 'application/json', data: { '_order': '$pos(' + pos + ')' }, method: corbel.request.method.PUT }); return this.request(args); }
[ "function", "(", "destId", ",", "pos", ",", "options", ")", "{", "corbel", ".", "validate", ".", "value", "(", "'destId'", ",", "destId", ")", ";", "var", "positionStartId", "=", "destId", ".", "indexOf", "(", "'/'", ")", ";", "if", "(", "positionStartId", "!==", "-", "1", ")", "{", "destId", "=", "destId", ".", "substring", "(", "positionStartId", "+", "1", ")", ";", "}", "options", "=", "this", ".", "getDefaultOptions", "(", "options", ")", ";", "var", "args", "=", "corbel", ".", "utils", ".", "extend", "(", "options", ",", "{", "url", ":", "this", ".", "buildUri", "(", "this", ".", "type", ",", "this", ".", "srcId", ",", "this", ".", "destType", ",", "destId", ")", ",", "contentType", ":", "'application/json'", ",", "data", ":", "{", "'_order'", ":", "'$pos('", "+", "pos", "+", "')'", "}", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", "}", ")", ";", "return", "this", ".", "request", "(", "args", ")", ";", "}" ]
Move a relation @method @memberOf Resources.Relation @param {Integer} pos The new position @return {Promise} ES6 promise that resolves to undefined (void) or rejects with a {@link CorbelError}
[ "Move", "a", "relation" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L5610-L5629
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(data, options) { options = this.getDefaultOptions(options); var args = corbel.utils.extend(options, { url: this.buildUri(this.type), method: corbel.request.method.POST, contentType: options.dataType, Accept: options.dataType, data: data }); return this.request(args).then(function(res) { return corbel.Services.getLocationId(res); }); }
javascript
function(data, options) { options = this.getDefaultOptions(options); var args = corbel.utils.extend(options, { url: this.buildUri(this.type), method: corbel.request.method.POST, contentType: options.dataType, Accept: options.dataType, data: data }); return this.request(args).then(function(res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "data", ",", "options", ")", "{", "options", "=", "this", ".", "getDefaultOptions", "(", "options", ")", ";", "var", "args", "=", "corbel", ".", "utils", ".", "extend", "(", "options", ",", "{", "url", ":", "this", ".", "buildUri", "(", "this", ".", "type", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "contentType", ":", "options", ".", "dataType", ",", "Accept", ":", "options", ".", "dataType", ",", "data", ":", "data", "}", ")", ";", "return", "this", ".", "request", "(", "args", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Adds a new element to a collection @method @memberOf Resources.CollectionBuilder @param {object} data Data array added to the collection @param {object} options Options object with dataType request option @return {Promise} ES6 promise that resolves to the new resource id or rejects with a {@link CorbelError}
[ "Adds", "a", "new", "element", "to", "a", "collection" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L5704-L5718
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(data, options) { options = this.getDefaultOptions(options); var args = corbel.utils.extend(options, { url: this.buildUri(this.type), method: corbel.request.method.PUT, contentType: options.dataType, Accept: options.dataType, data: data }); return this.request(args); }
javascript
function(data, options) { options = this.getDefaultOptions(options); var args = corbel.utils.extend(options, { url: this.buildUri(this.type), method: corbel.request.method.PUT, contentType: options.dataType, Accept: options.dataType, data: data }); return this.request(args); }
[ "function", "(", "data", ",", "options", ")", "{", "options", "=", "this", ".", "getDefaultOptions", "(", "options", ")", ";", "var", "args", "=", "corbel", ".", "utils", ".", "extend", "(", "options", ",", "{", "url", ":", "this", ".", "buildUri", "(", "this", ".", "type", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "contentType", ":", "options", ".", "dataType", ",", "Accept", ":", "options", ".", "dataType", ",", "data", ":", "data", "}", ")", ";", "return", "this", ".", "request", "(", "args", ")", ";", "}" ]
Update every element in a collection, accepts query params @method @memberOf resources.CollectionBuilder @param {Object} data The element to be updated @param {Object} options/query Options object with dataType request option @return {Promise} ES6 promise that resolves to an {Array} of resources or rejects with a {@link CorbelError}
[ "Update", "every", "element", "in", "a", "collection", "accepts", "query", "params" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L5728-L5740
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(acl) { var args = { url: this.buildUri(this.type, this.id), method: corbel.request.method.PUT, data: acl, Accept: 'application/corbel.acl+json' }; return this.request(args); }
javascript
function(acl) { var args = { url: this.buildUri(this.type, this.id), method: corbel.request.method.PUT, data: acl, Accept: 'application/corbel.acl+json' }; return this.request(args); }
[ "function", "(", "acl", ")", "{", "var", "args", "=", "{", "url", ":", "this", ".", "buildUri", "(", "this", ".", "type", ",", "this", ".", "id", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "data", ":", "acl", ",", "Accept", ":", "'application/corbel.acl+json'", "}", ";", "return", "this", ".", "request", "(", "args", ")", ";", "}" ]
Updates the ACL of a resource @method @memberOf resources.Resource @param {Object} acl Acl to be updated @return {Promise} ES6 promise that resolves to undefined (void) or rejects with a {@link CorbelError}
[ "Updates", "the", "ACL", "of", "a", "resource" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L5846-L5855
train
bq/corbel-js
dist/corbel.with-polyfills.js
function() { console.log('oauthInterface.authorization.dialog'); var that = this; return this.request({ url: this._buildUri(this.uri + '/authorize'), method: corbel.request.method.GET, dataType: 'text', withCredentials: true, query: corbel.utils.toURLEncoded(this.params.data), noRedirect: true, contentType: corbel.Oauth._URL_ENCODED }) .then(function(res) { var params = { url: corbel.Services.getLocation(res), withCredentials: true }; return that.request(params); }); }
javascript
function() { console.log('oauthInterface.authorization.dialog'); var that = this; return this.request({ url: this._buildUri(this.uri + '/authorize'), method: corbel.request.method.GET, dataType: 'text', withCredentials: true, query: corbel.utils.toURLEncoded(this.params.data), noRedirect: true, contentType: corbel.Oauth._URL_ENCODED }) .then(function(res) { var params = { url: corbel.Services.getLocation(res), withCredentials: true }; return that.request(params); }); }
[ "function", "(", ")", "{", "console", ".", "log", "(", "'oauthInterface.authorization.dialog'", ")", ";", "var", "that", "=", "this", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", "+", "'/authorize'", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "GET", ",", "dataType", ":", "'text'", ",", "withCredentials", ":", "true", ",", "query", ":", "corbel", ".", "utils", ".", "toURLEncoded", "(", "this", ".", "params", ".", "data", ")", ",", "noRedirect", ":", "true", ",", "contentType", ":", "corbel", ".", "Oauth", ".", "_URL_ENCODED", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "var", "params", "=", "{", "url", ":", "corbel", ".", "Services", ".", "getLocation", "(", "res", ")", ",", "withCredentials", ":", "true", "}", ";", "return", "that", ".", "request", "(", "params", ")", ";", "}", ")", ";", "}" ]
Does a login with stored cookie in oauth server @method @memberOf corbel.Oauth.AuthorizationBuilder @return {Promise} Q promise that resolves to a redirection to redirectUri or rejects with a 404 {@link CorbelError}
[ "Does", "a", "login", "with", "stored", "cookie", "in", "oauth", "server" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L6021-L6041
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(username, password, setCookie, redirect) { console.log('oauthInterface.authorization.login', username + ':' + password); if (username) { this.params.data.username = username; } if (password) { this.params.data.password = password; } this.params.withCredentials = true; var that = this; // make request, generate oauth cookie, then redirect manually return this.request({ url: this._buildUri(this.uri + '/authorize'), method: corbel.request.method.POST, data: this.params.data, contentType: this.params.contentType, noRedirect: redirect ? redirect : true }) .then(function(res) { if (corbel.Services.getLocation(res)) { var req = { url: corbel.Services.getLocation(res) }; if (setCookie) { req.headers = { RequestCookie: 'true' }; req.withCredentials = true; } return that.request(req).then(function(response) { var accessToken = response.data.accessToken || response.data.query.code; that.driver.config.set(corbel.Iam.IAM_TOKEN, response.data); that.driver.config.set(corbel.Iam.IAM_DOMAIN, corbel.jwt.decode(accessToken).domainId); if (that.params.jwt) { that.driver.config.set(corbel.Iam.IAM_TOKEN_SCOPES, corbel.jwt.decode(that.params.jwt).scope); } if (that.params.claims) { if (that.params.claims.scope) { that.driver.config.set(corbel.Iam.IAM_TOKEN_SCOPES, that.params.claims.scope); } else { that.driver.config.set(corbel.Iam.IAM_TOKEN_SCOPES, that.driver.config.get('scopes', '')); } } return response; }); } else { return res.data; } }); }
javascript
function(username, password, setCookie, redirect) { console.log('oauthInterface.authorization.login', username + ':' + password); if (username) { this.params.data.username = username; } if (password) { this.params.data.password = password; } this.params.withCredentials = true; var that = this; // make request, generate oauth cookie, then redirect manually return this.request({ url: this._buildUri(this.uri + '/authorize'), method: corbel.request.method.POST, data: this.params.data, contentType: this.params.contentType, noRedirect: redirect ? redirect : true }) .then(function(res) { if (corbel.Services.getLocation(res)) { var req = { url: corbel.Services.getLocation(res) }; if (setCookie) { req.headers = { RequestCookie: 'true' }; req.withCredentials = true; } return that.request(req).then(function(response) { var accessToken = response.data.accessToken || response.data.query.code; that.driver.config.set(corbel.Iam.IAM_TOKEN, response.data); that.driver.config.set(corbel.Iam.IAM_DOMAIN, corbel.jwt.decode(accessToken).domainId); if (that.params.jwt) { that.driver.config.set(corbel.Iam.IAM_TOKEN_SCOPES, corbel.jwt.decode(that.params.jwt).scope); } if (that.params.claims) { if (that.params.claims.scope) { that.driver.config.set(corbel.Iam.IAM_TOKEN_SCOPES, that.params.claims.scope); } else { that.driver.config.set(corbel.Iam.IAM_TOKEN_SCOPES, that.driver.config.get('scopes', '')); } } return response; }); } else { return res.data; } }); }
[ "function", "(", "username", ",", "password", ",", "setCookie", ",", "redirect", ")", "{", "console", ".", "log", "(", "'oauthInterface.authorization.login'", ",", "username", "+", "':'", "+", "password", ")", ";", "if", "(", "username", ")", "{", "this", ".", "params", ".", "data", ".", "username", "=", "username", ";", "}", "if", "(", "password", ")", "{", "this", ".", "params", ".", "data", ".", "password", "=", "password", ";", "}", "this", ".", "params", ".", "withCredentials", "=", "true", ";", "var", "that", "=", "this", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", "+", "'/authorize'", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "data", ":", "this", ".", "params", ".", "data", ",", "contentType", ":", "this", ".", "params", ".", "contentType", ",", "noRedirect", ":", "redirect", "?", "redirect", ":", "true", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "if", "(", "corbel", ".", "Services", ".", "getLocation", "(", "res", ")", ")", "{", "var", "req", "=", "{", "url", ":", "corbel", ".", "Services", ".", "getLocation", "(", "res", ")", "}", ";", "if", "(", "setCookie", ")", "{", "req", ".", "headers", "=", "{", "RequestCookie", ":", "'true'", "}", ";", "req", ".", "withCredentials", "=", "true", ";", "}", "return", "that", ".", "request", "(", "req", ")", ".", "then", "(", "function", "(", "response", ")", "{", "var", "accessToken", "=", "response", ".", "data", ".", "accessToken", "||", "response", ".", "data", ".", "query", ".", "code", ";", "that", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Iam", ".", "IAM_TOKEN", ",", "response", ".", "data", ")", ";", "that", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Iam", ".", "IAM_DOMAIN", ",", "corbel", ".", "jwt", ".", "decode", "(", "accessToken", ")", ".", "domainId", ")", ";", "if", "(", "that", ".", "params", ".", "jwt", ")", "{", "that", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Iam", ".", "IAM_TOKEN_SCOPES", ",", "corbel", ".", "jwt", ".", "decode", "(", "that", ".", "params", ".", "jwt", ")", ".", "scope", ")", ";", "}", "if", "(", "that", ".", "params", ".", "claims", ")", "{", "if", "(", "that", ".", "params", ".", "claims", ".", "scope", ")", "{", "that", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Iam", ".", "IAM_TOKEN_SCOPES", ",", "that", ".", "params", ".", "claims", ".", "scope", ")", ";", "}", "else", "{", "that", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Iam", ".", "IAM_TOKEN_SCOPES", ",", "that", ".", "driver", ".", "config", ".", "get", "(", "'scopes'", ",", "''", ")", ")", ";", "}", "}", "return", "response", ";", "}", ")", ";", "}", "else", "{", "return", "res", ".", "data", ";", "}", "}", ")", ";", "}" ]
Does a login in oauth server @method @memberOf corbel.Oauth.AuthorizationBuilder @param {String} username The username of the user to log in @param {String} password The password of the user @param {Boolean} setCookie Sends 'RequestCookie' to the server @param {Boolean} redirect The user when he does the login @return {Promise} Q promise that resolves to a redirection to redirectUri or rejects with a {@link CorbelError}
[ "Does", "a", "login", "in", "oauth", "server" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L6052-L6108
train
bq/corbel-js
dist/corbel.with-polyfills.js
function() { console.log('oauthInterface.authorization.signOut'); delete this.params.data; return this.request({ url: this._buildUri(this.uri + '/signout'), method: corbel.request.method.GET, withCredentials: true }).then(function(res) { return corbel.Services.getLocationId(res); }); }
javascript
function() { console.log('oauthInterface.authorization.signOut'); delete this.params.data; return this.request({ url: this._buildUri(this.uri + '/signout'), method: corbel.request.method.GET, withCredentials: true }).then(function(res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", ")", "{", "console", ".", "log", "(", "'oauthInterface.authorization.signOut'", ")", ";", "delete", "this", ".", "params", ".", "data", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", "+", "'/signout'", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "GET", ",", "withCredentials", ":", "true", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Sign out from oauth server @method @memberOf corbel.Oauth.SignOutBuilder @return {Promise} promise that resolves empty when the sign out process completes or rejects with a {@link CorbelError}
[ "Sign", "out", "from", "oauth", "server" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L6116-L6126
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(user) { console.log('oauthInterface.user.create', user); return this.request({ url: this._buildUri(this.uri), method: corbel.request.method.POST, headers: { Authorization: 'Basic ' + this.getSerializer()(this.clientId + ':' + this.clientSecret) }, dataType: 'text', data: user }) .then(function(res) { return corbel.Services.getLocationId(res); }); }
javascript
function(user) { console.log('oauthInterface.user.create', user); return this.request({ url: this._buildUri(this.uri), method: corbel.request.method.POST, headers: { Authorization: 'Basic ' + this.getSerializer()(this.clientId + ':' + this.clientSecret) }, dataType: 'text', data: user }) .then(function(res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "user", ")", "{", "console", ".", "log", "(", "'oauthInterface.user.create'", ",", "user", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "headers", ":", "{", "Authorization", ":", "'Basic '", "+", "this", ".", "getSerializer", "(", ")", "(", "this", ".", "clientId", "+", "':'", "+", "this", ".", "clientSecret", ")", "}", ",", "dataType", ":", "'text'", ",", "data", ":", "user", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Adds a new user to the oauth server. @method @memberOf corbel.Oauth.UserBuilder @param {Object} user The user to be created @return {Promise} A promise with the id of the created user or fails with a {@link corbelError}.
[ "Adds", "a", "new", "user", "to", "the", "oauth", "server", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L6266-L6281
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(notification) { console.log('notificationsInterface.notification.sendNotification', notification); this.uri += '/send'; return this.request({ url: this.buildUri(this.uri), method: corbel.request.method.POST, data: notification }); }
javascript
function(notification) { console.log('notificationsInterface.notification.sendNotification', notification); this.uri += '/send'; return this.request({ url: this.buildUri(this.uri), method: corbel.request.method.POST, data: notification }); }
[ "function", "(", "notification", ")", "{", "console", ".", "log", "(", "'notificationsInterface.notification.sendNotification'", ",", "notification", ")", ";", "this", ".", "uri", "+=", "'/send'", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "buildUri", "(", "this", ".", "uri", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "data", ":", "notification", "}", ")", ";", "}" ]
Send a notification @method @memberOf Corbel.Notifications.NotificationsBuilder @param {Object} notification Notification @param {String} notification.notificationId Notification id (mail, sms...) @param {String} notification.recipient Notification recipient @param {Object} notification.propierties Notification propierties @return {Promise} Promise that resolves to undefined (void) or rejects with a {@link CorbelError}
[ "Send", "a", "notification" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L6551-L6559
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(couponIds) { console.log('ecInterface.order.prepare'); corbel.validate.value('id', this.id); return this.request({ url: this._buildUri(this.uri, this.id, '/prepare'), method: corbel.request.method.POST, data: couponIds }); }
javascript
function(couponIds) { console.log('ecInterface.order.prepare'); corbel.validate.value('id', this.id); return this.request({ url: this._buildUri(this.uri, this.id, '/prepare'), method: corbel.request.method.POST, data: couponIds }); }
[ "function", "(", "couponIds", ")", "{", "console", ".", "log", "(", "'ecInterface.order.prepare'", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'id'", ",", "this", ".", "id", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ",", "this", ".", "id", ",", "'/prepare'", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "data", ":", "couponIds", "}", ")", ";", "}" ]
Prepares the order, required to checkout @method @memberOf corbel.Ec.OrderBuilder @param {string[]} couponIds Array of String with the coupons ids to prepare the order @return {Promise} Q promise that resolves to undefined (void) or rejects with a {@link SilkRoadError}
[ "Prepares", "the", "order", "required", "to", "checkout" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L6975-L6984
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(data) { console.log('ecInterface.order.checkout'); if (!data.paymentMethodIds) { return Promise.reject(new Error('paymentMethodIds lists needed')); } if (!data.paymentMethodIds.length) { return Promise.reject(new Error('One payment method is needed at least')); } corbel.validate.value('id', this.id); return this.request({ method: corbel.request.method.POST, url: this._buildUri(this.uri, this.id, '/checkout'), data: data }).then(function(res) { return corbel.Services.getLocationId(res); }); }
javascript
function(data) { console.log('ecInterface.order.checkout'); if (!data.paymentMethodIds) { return Promise.reject(new Error('paymentMethodIds lists needed')); } if (!data.paymentMethodIds.length) { return Promise.reject(new Error('One payment method is needed at least')); } corbel.validate.value('id', this.id); return this.request({ method: corbel.request.method.POST, url: this._buildUri(this.uri, this.id, '/checkout'), data: data }).then(function(res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "data", ")", "{", "console", ".", "log", "(", "'ecInterface.order.checkout'", ")", ";", "if", "(", "!", "data", ".", "paymentMethodIds", ")", "{", "return", "Promise", ".", "reject", "(", "new", "Error", "(", "'paymentMethodIds lists needed'", ")", ")", ";", "}", "if", "(", "!", "data", ".", "paymentMethodIds", ".", "length", ")", "{", "return", "Promise", ".", "reject", "(", "new", "Error", "(", "'One payment method is needed at least'", ")", ")", ";", "}", "corbel", ".", "validate", ".", "value", "(", "'id'", ",", "this", ".", "id", ")", ";", "return", "this", ".", "request", "(", "{", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ",", "this", ".", "id", ",", "'/checkout'", ")", ",", "data", ":", "data", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Checks out the Order @method @memberOf corbel.Ec.OrderBuilder @param {Object} data Purchase information to do the checkout @param {string[]} data.paymentMethodIds Array of String with the payment methods ids to checkout the order @return {Promise} Promise that resolves in the new purchase id or rejects with a {@link SilkRoadError}
[ "Checks", "out", "the", "Order" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L6995-L7012
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(product) { console.log('ecInterface.product.create', product); return this.request({ url: this._buildUri(this.uri), method: corbel.request.method.POST, data: product }).then(function(res) { return corbel.Services.getLocationId(res); }); }
javascript
function(product) { console.log('ecInterface.product.create', product); return this.request({ url: this._buildUri(this.uri), method: corbel.request.method.POST, data: product }).then(function(res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "product", ")", "{", "console", ".", "log", "(", "'ecInterface.product.create'", ",", "product", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "data", ":", "product", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Create a new product. @method @memberOf corbel.Ec.ProductBuilder @param {Object} product Contains the data of the new product @param {Object} product.name The name of the product @param {String} product.price Information about price @param {String} product.price.currency Currency code fro the price @param {Number} product.price.amount The amount of the price @param {String} product.type Define the type of the product, which can trigger different behaviors @param {String} product.href The resource uri @param {Array} product.assets Array with the permissions assigned to the product @param {String} product.assets.name Identifier of the asset @param {String} product.assets.period Define if the product asset has a validity in ISO8601 period format @param {Array} product.assets.scopes String array with the scopes associated with the asset @param {Array} product.paymentPlan Array with the service associated to the product @param {String} product.paymentPlan.duration Define the period of service has a validity in ISO8601 period @param {String} product.paymentPlan.period The data to hire the service has a validity in ISO8601 period format @return {Promise} A promise with the id of the created loanable resources or fails with a {@link corbelError}.
[ "Create", "a", "new", "product", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L7083-L7093
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(eventData) { if (!eventData) { throw new Error('Send event require data'); } console.log('evciInterface.publish', eventData); corbel.validate.value('eventType', this.eventType); return this.request({ url: this._buildUri(this.uri, this.eventType), method: corbel.request.method.POST, data: eventData }).then(function(res) { return res; }); }
javascript
function(eventData) { if (!eventData) { throw new Error('Send event require data'); } console.log('evciInterface.publish', eventData); corbel.validate.value('eventType', this.eventType); return this.request({ url: this._buildUri(this.uri, this.eventType), method: corbel.request.method.POST, data: eventData }).then(function(res) { return res; }); }
[ "function", "(", "eventData", ")", "{", "if", "(", "!", "eventData", ")", "{", "throw", "new", "Error", "(", "'Send event require data'", ")", ";", "}", "console", ".", "log", "(", "'evciInterface.publish'", ",", "eventData", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'eventType'", ",", "this", ".", "eventType", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ",", "this", ".", "eventType", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "data", ":", "eventData", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "res", ";", "}", ")", ";", "}" ]
Publish a new event. @method @memberOf corbel.Evci.EventBuilder @param {Object} eventData The data of the event. @return {Promise} A promise with the id of the created scope or fails with a {@link corbelError}.
[ "Publish", "a", "new", "event", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L7271-L7284
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(id) { var resource = new corbel.Borrow.BorrowBuilder(id); resource.driver = this.driver; return resource; }
javascript
function(id) { var resource = new corbel.Borrow.BorrowBuilder(id); resource.driver = this.driver; return resource; }
[ "function", "(", "id", ")", "{", "var", "resource", "=", "new", "corbel", ".", "Borrow", ".", "BorrowBuilder", "(", "id", ")", ";", "resource", ".", "driver", "=", "this", ".", "driver", ";", "return", "resource", ";", "}" ]
Create a BorrowBuilder for resource managing requests. @param {String} id The id of the borrow. @return {corbel.Borrow.BorrowBuilder}
[ "Create", "a", "BorrowBuilder", "for", "resource", "managing", "requests", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L7339-L7343
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(id) { var lender = new corbel.Borrow.LenderBuilder(id); lender.driver = this.driver; return lender; }
javascript
function(id) { var lender = new corbel.Borrow.LenderBuilder(id); lender.driver = this.driver; return lender; }
[ "function", "(", "id", ")", "{", "var", "lender", "=", "new", "corbel", ".", "Borrow", ".", "LenderBuilder", "(", "id", ")", ";", "lender", ".", "driver", "=", "this", ".", "driver", ";", "return", "lender", ";", "}" ]
Create a LenderBuilder for lender managing requests. @param {String} id The id of the lender. @return {corbel.Borrow.LenderBuilder}
[ "Create", "a", "LenderBuilder", "for", "lender", "managing", "requests", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L7352-L7356
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(id) { var user = new corbel.Borrow.UserBuilder(id); user.driver = this.driver; return user; }
javascript
function(id) { var user = new corbel.Borrow.UserBuilder(id); user.driver = this.driver; return user; }
[ "function", "(", "id", ")", "{", "var", "user", "=", "new", "corbel", ".", "Borrow", ".", "UserBuilder", "(", "id", ")", ";", "user", ".", "driver", "=", "this", ".", "driver", ";", "return", "user", ";", "}" ]
Create a UserBuilder for user managing requests. @param {String} id The id of the user. @return {corbel.Borrow.UserBuilder}
[ "Create", "a", "UserBuilder", "for", "user", "managing", "requests", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L7365-L7369
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(license) { console.log('borrowInterface.resource.addLicense', license); corbel.validate.value('id', this.id); return this.request({ url: this._buildUri(this.uri, this.id, 'license'), method: corbel.request.method.POST, data: license }).then(function(res) { return corbel.Services.getLocationId(res); }); }
javascript
function(license) { console.log('borrowInterface.resource.addLicense', license); corbel.validate.value('id', this.id); return this.request({ url: this._buildUri(this.uri, this.id, 'license'), method: corbel.request.method.POST, data: license }).then(function(res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "license", ")", "{", "console", ".", "log", "(", "'borrowInterface.resource.addLicense'", ",", "license", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'id'", ",", "this", ".", "id", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ",", "this", ".", "id", ",", "'license'", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "data", ":", "license", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Add license to loanable resource. @method @memberOf corbel.Borrow.BorrowBuilder @param {Object} data licenses data. @param {Object} license The license data. @param {String} license.resourceId Identifier of resource @param {number} licensee.availableUses Amount of uses that the resource is available @param {number} license.availableLoans Amount of concurrent loans are available for the resource @param {timestamp} license.expire Expire date @param {timestamp} licensee.start Start date @param {String} license.asset Asigned to the resource @return {Promise} A promise with the id of the created a license or fails with a {@link corbelError}.
[ "Add", "license", "to", "loanable", "resource", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L7510-L7520
train
bq/corbel-js
dist/corbel.with-polyfills.js
function() { console.log('borrowInterface.user.getAllLoans', this.id); return this.request({ url: this._buildUri(this.uri, this.id, 'loan'), method: corbel.request.method.GET }); }
javascript
function() { console.log('borrowInterface.user.getAllLoans', this.id); return this.request({ url: this._buildUri(this.uri, this.id, 'loan'), method: corbel.request.method.GET }); }
[ "function", "(", ")", "{", "console", ".", "log", "(", "'borrowInterface.user.getAllLoans'", ",", "this", ".", "id", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ",", "this", ".", "id", ",", "'loan'", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "GET", "}", ")", ";", "}" ]
Get all loans of a user. @method @memberOf corbel.Borrow.UserBuilder @return {Promise} A promise with all user loans {Object} or fails with a {@link corbelError}.
[ "Get", "all", "loans", "of", "a", "user", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L7836-L7842
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(lender) { console.log('borrowInterface.lender.update'); return this.request({ url: this._buildUri(this.uri, this.id), method: corbel.request.method.PUT, data: lender }); }
javascript
function(lender) { console.log('borrowInterface.lender.update'); return this.request({ url: this._buildUri(this.uri, this.id), method: corbel.request.method.PUT, data: lender }); }
[ "function", "(", "lender", ")", "{", "console", ".", "log", "(", "'borrowInterface.lender.update'", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ",", "this", ".", "id", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "data", ":", "lender", "}", ")", ";", "}" ]
Update a Lender. @method @memberOf corbel.Borrow.LenderBuilder @param {Object} lender The lender data. @return {Promise} A promise resolves to undefined (void) or fails with a {@link corbelError}.
[ "Update", "a", "Lender", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L7904-L7912
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(id) { var phraseBuilder = new corbel.CompoSR.PhraseBuilder(id); phraseBuilder.driver = this.driver; return phraseBuilder; }
javascript
function(id) { var phraseBuilder = new corbel.CompoSR.PhraseBuilder(id); phraseBuilder.driver = this.driver; return phraseBuilder; }
[ "function", "(", "id", ")", "{", "var", "phraseBuilder", "=", "new", "corbel", ".", "CompoSR", ".", "PhraseBuilder", "(", "id", ")", ";", "phraseBuilder", ".", "driver", "=", "this", ".", "driver", ";", "return", "phraseBuilder", ";", "}" ]
Create a PhraseBuilder for phrase managing requests. @param {String} id The id of the phrase. @return {corbel.CompoSR.PhraseBuilder}
[ "Create", "a", "PhraseBuilder", "for", "phrase", "managing", "requests", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L8005-L8009
train
bq/corbel-js
dist/corbel.with-polyfills.js
function() { var requestBuilder = new corbel.CompoSR.RequestBuilder(Array.prototype.slice.call(arguments)); requestBuilder.driver = this.driver; return requestBuilder; }
javascript
function() { var requestBuilder = new corbel.CompoSR.RequestBuilder(Array.prototype.slice.call(arguments)); requestBuilder.driver = this.driver; return requestBuilder; }
[ "function", "(", ")", "{", "var", "requestBuilder", "=", "new", "corbel", ".", "CompoSR", ".", "RequestBuilder", "(", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ")", ";", "requestBuilder", ".", "driver", "=", "this", ".", "driver", ";", "return", "requestBuilder", ";", "}" ]
Create a RequestBuilder for phrase requests. @param {String} id phrase id @param {String} param1 path parameter @param {String} param2 path parameter @param {String} paramN path parameter @return {corbel.CompoSR.RequestBuilder}
[ "Create", "a", "RequestBuilder", "for", "phrase", "requests", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L8021-L8025
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(params) { corbel.validate.value('id', this.id); var options = params ? corbel.utils.clone(params) : {}; var args = corbel.utils.extend(options, { url: this._buildUriWithDomain(this.id), method: corbel.request.method.GET, query: params ? corbel.utils.serializeParams(params) : null }); return this.request(args); }
javascript
function(params) { corbel.validate.value('id', this.id); var options = params ? corbel.utils.clone(params) : {}; var args = corbel.utils.extend(options, { url: this._buildUriWithDomain(this.id), method: corbel.request.method.GET, query: params ? corbel.utils.serializeParams(params) : null }); return this.request(args); }
[ "function", "(", "params", ")", "{", "corbel", ".", "validate", ".", "value", "(", "'id'", ",", "this", ".", "id", ")", ";", "var", "options", "=", "params", "?", "corbel", ".", "utils", ".", "clone", "(", "params", ")", ":", "{", "}", ";", "var", "args", "=", "corbel", ".", "utils", ".", "extend", "(", "options", ",", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "id", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "GET", ",", "query", ":", "params", "?", "corbel", ".", "utils", ".", "serializeParams", "(", "params", ")", ":", "null", "}", ")", ";", "return", "this", ".", "request", "(", "args", ")", ";", "}" ]
Gets the content @memberof corbel.Webfs.WebfsBuilder.prototype @param {object} [params] Params of a {@link corbel.request} @return {Promise} Promise that resolves with a resource or rejects with a {@link CorbelError}
[ "Gets", "the", "content" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L8314-L8328
train
bq/corbel-js
dist/corbel.with-polyfills.js
function(driver) { this.driver = driver; return function(id) { driver.config.set(corbel.Domain.CUSTOM_DOMAIN, id); return driver; }; }
javascript
function(driver) { this.driver = driver; return function(id) { driver.config.set(corbel.Domain.CUSTOM_DOMAIN, id); return driver; }; }
[ "function", "(", "driver", ")", "{", "this", ".", "driver", "=", "driver", ";", "return", "function", "(", "id", ")", "{", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Domain", ".", "CUSTOM_DOMAIN", ",", "id", ")", ";", "return", "driver", ";", "}", ";", "}" ]
Creates a new instance of corbelDriver with a custom domain @memberof corbel.Domain.prototype @param {string} id String with the custom domain value @return {corbelDriver}
[ "Creates", "a", "new", "instance", "of", "corbelDriver", "with", "a", "custom", "domain" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L8414-L8422
train
cronvel/doormen
lib/assert.js
FunctionCall
function FunctionCall( fn , isAsync , thisArg , ... args ) { this.function = fn ; this.isAsync = isAsync ; this.this = thisArg ; this.args = args ; this.hasThrown = false ; this.error = undefined ; this.return = undefined ; try { this.return = this.function.call( this.this || null , ... this.args ) ; } catch ( error ) { this.hasThrown = true ; this.error = error ; } if ( this.isAsync ) { if ( this.hasThrown ) { this.promise = Promise.resolve() ; } else { this.promise = Promise.resolve( this.return ) .then( value => this.return = value , error => { this.hasThrown = true ; this.error = error ; } ) ; } } }
javascript
function FunctionCall( fn , isAsync , thisArg , ... args ) { this.function = fn ; this.isAsync = isAsync ; this.this = thisArg ; this.args = args ; this.hasThrown = false ; this.error = undefined ; this.return = undefined ; try { this.return = this.function.call( this.this || null , ... this.args ) ; } catch ( error ) { this.hasThrown = true ; this.error = error ; } if ( this.isAsync ) { if ( this.hasThrown ) { this.promise = Promise.resolve() ; } else { this.promise = Promise.resolve( this.return ) .then( value => this.return = value , error => { this.hasThrown = true ; this.error = error ; } ) ; } } }
[ "function", "FunctionCall", "(", "fn", ",", "isAsync", ",", "thisArg", ",", "...", "args", ")", "{", "this", ".", "function", "=", "fn", ";", "this", ".", "isAsync", "=", "isAsync", ";", "this", ".", "this", "=", "thisArg", ";", "this", ".", "args", "=", "args", ";", "this", ".", "hasThrown", "=", "false", ";", "this", ".", "error", "=", "undefined", ";", "this", ".", "return", "=", "undefined", ";", "try", "{", "this", ".", "return", "=", "this", ".", "function", ".", "call", "(", "this", ".", "this", "||", "null", ",", "...", "this", ".", "args", ")", ";", "}", "catch", "(", "error", ")", "{", "this", ".", "hasThrown", "=", "true", ";", "this", ".", "error", "=", "error", ";", "}", "if", "(", "this", ".", "isAsync", ")", "{", "if", "(", "this", ".", "hasThrown", ")", "{", "this", ".", "promise", "=", "Promise", ".", "resolve", "(", ")", ";", "}", "else", "{", "this", ".", "promise", "=", "Promise", ".", "resolve", "(", "this", ".", "return", ")", ".", "then", "(", "value", "=>", "this", ".", "return", "=", "value", ",", "error", "=>", "{", "this", ".", "hasThrown", "=", "true", ";", "this", ".", "error", "=", "error", ";", "}", ")", ";", "}", "}", "}" ]
A class for actual function, arguments, return value and thrown error
[ "A", "class", "for", "actual", "function", "arguments", "return", "value", "and", "thrown", "error" ]
e17e801736be326cc57d93095a73571f4cbaf1cc
https://github.com/cronvel/doormen/blob/e17e801736be326cc57d93095a73571f4cbaf1cc/lib/assert.js#L52-L84
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.10/xtemplate/runtime.js
function (commandName, fn) { var config = this.config; config.commands = config.commands || {}; config.commands[commandName] = fn; }
javascript
function (commandName, fn) { var config = this.config; config.commands = config.commands || {}; config.commands[commandName] = fn; }
[ "function", "(", "commandName", ",", "fn", ")", "{", "var", "config", "=", "this", ".", "config", ";", "config", ".", "commands", "=", "config", ".", "commands", "||", "{", "}", ";", "config", ".", "commands", "[", "commandName", "]", "=", "fn", ";", "}" ]
add command definition to current template @param commandName @param {Function} fn command definition
[ "add", "command", "definition", "to", "current", "template" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.10/xtemplate/runtime.js#L196-L200
train
Automattic/wpcom-unpublished
index.js
WPCOMUnpublished
function WPCOMUnpublished( token, reqHandler ) { if ( ! ( this instanceof WPCOMUnpublished ) ) { return new WPCOMUnpublished( token, reqHandler ); } WPCOM.call( this, token, reqHandler ); }
javascript
function WPCOMUnpublished( token, reqHandler ) { if ( ! ( this instanceof WPCOMUnpublished ) ) { return new WPCOMUnpublished( token, reqHandler ); } WPCOM.call( this, token, reqHandler ); }
[ "function", "WPCOMUnpublished", "(", "token", ",", "reqHandler", ")", "{", "if", "(", "!", "(", "this", "instanceof", "WPCOMUnpublished", ")", ")", "{", "return", "new", "WPCOMUnpublished", "(", "token", ",", "reqHandler", ")", ";", "}", "WPCOM", ".", "call", "(", "this", ",", "token", ",", "reqHandler", ")", ";", "}" ]
Creates a `WPCOMUnpublished` instance Example // Create WPCOMUnpublished instance var WPCOMUnpublished = require( 'wpcom-unpublished' ); var wpcom = WPCOM(); Example // Create WPCOMUnpublished instance passing a token var WPCOMUnpublished = require( 'wpcom-unpublished' ); var wpcom = WPCOM( '<your-token>' ); Example // Create WPCOMUnpublished instance passing request handler var WPCOMUnpublished = require( 'wpcom-unpublished' ); var proxy = require( 'wpcom-proxy-request' ); var wpcom = WPCOM( proxy ); @param {String} [token] - OAuth API access token @param {Function} [reqHandler] - function Request Handler @public
[ "Creates", "a", "WPCOMUnpublished", "instance" ]
9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e
https://github.com/Automattic/wpcom-unpublished/blob/9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e/index.js#L35-L41
train
dumberjs/dumber-module-loader
src/index.js
toUrl
function toUrl(mId) { const parsed = parse(mId); let url = parsed.bareId; if (url[0] !== '/' && !url.match(/^https?:\/\//)) url = _baseUrl + url; if (!parsed.ext) { // no known ext, add .js url += '.js'; } return url; }
javascript
function toUrl(mId) { const parsed = parse(mId); let url = parsed.bareId; if (url[0] !== '/' && !url.match(/^https?:\/\//)) url = _baseUrl + url; if (!parsed.ext) { // no known ext, add .js url += '.js'; } return url; }
[ "function", "toUrl", "(", "mId", ")", "{", "const", "parsed", "=", "parse", "(", "mId", ")", ";", "let", "url", "=", "parsed", ".", "bareId", ";", "if", "(", "url", "[", "0", "]", "!==", "'/'", "&&", "!", "url", ".", "match", "(", "/", "^https?:\\/\\/", "/", ")", ")", "url", "=", "_baseUrl", "+", "url", ";", "if", "(", "!", "parsed", ".", "ext", ")", "{", "url", "+=", "'.js'", ";", "}", "return", "url", ";", "}" ]
incoming id is already mapped
[ "incoming", "id", "is", "already", "mapped" ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L188-L197
train
dumberjs/dumber-module-loader
src/index.js
runtimeReq
function runtimeReq(mId) { const parsed = parse(mId); return _fetch(parsed.cleanId) .then(response => { // ensure default user space define.switchToUserSpace(); for (let i = 0, len = _translators.length; i < len; i++) { const result = _translators[i](parsed, response); if (result && typeof result.then === 'function') return result; } throw new Error(`no runtime translator to handle ${parsed.cleanId}`); }) .then(() => { if (userSpace.has(parsed.cleanId)) return userSpace.req(parsed.cleanId); throw new Error(`module "${parsed.cleanId}" is missing from url "${toUrl(mId)}"`); }) .catch(err => { console.error(`could not load module "${parsed.cleanId}" from remote`); // eslint-disable-line no-console throw err; }); }
javascript
function runtimeReq(mId) { const parsed = parse(mId); return _fetch(parsed.cleanId) .then(response => { // ensure default user space define.switchToUserSpace(); for (let i = 0, len = _translators.length; i < len; i++) { const result = _translators[i](parsed, response); if (result && typeof result.then === 'function') return result; } throw new Error(`no runtime translator to handle ${parsed.cleanId}`); }) .then(() => { if (userSpace.has(parsed.cleanId)) return userSpace.req(parsed.cleanId); throw new Error(`module "${parsed.cleanId}" is missing from url "${toUrl(mId)}"`); }) .catch(err => { console.error(`could not load module "${parsed.cleanId}" from remote`); // eslint-disable-line no-console throw err; }); }
[ "function", "runtimeReq", "(", "mId", ")", "{", "const", "parsed", "=", "parse", "(", "mId", ")", ";", "return", "_fetch", "(", "parsed", ".", "cleanId", ")", ".", "then", "(", "response", "=>", "{", "define", ".", "switchToUserSpace", "(", ")", ";", "for", "(", "let", "i", "=", "0", ",", "len", "=", "_translators", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "const", "result", "=", "_translators", "[", "i", "]", "(", "parsed", ",", "response", ")", ";", "if", "(", "result", "&&", "typeof", "result", ".", "then", "===", "'function'", ")", "return", "result", ";", "}", "throw", "new", "Error", "(", "`", "${", "parsed", ".", "cleanId", "}", "`", ")", ";", "}", ")", ".", "then", "(", "(", ")", "=>", "{", "if", "(", "userSpace", ".", "has", "(", "parsed", ".", "cleanId", ")", ")", "return", "userSpace", ".", "req", "(", "parsed", ".", "cleanId", ")", ";", "throw", "new", "Error", "(", "`", "${", "parsed", ".", "cleanId", "}", "${", "toUrl", "(", "mId", ")", "}", "`", ")", ";", "}", ")", ".", "catch", "(", "err", "=>", "{", "console", ".", "error", "(", "`", "${", "parsed", ".", "cleanId", "}", "`", ")", ";", "throw", "err", ";", "}", ")", ";", "}" ]
incoming id is already mapped return a promise
[ "incoming", "id", "is", "already", "mapped", "return", "a", "promise" ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L286-L307
train
dumberjs/dumber-module-loader
src/index.js
userReqFromBundle
function userReqFromBundle(mId) { const possibleIds = nodejsIds(mId); const bundleName = Object.keys(_bundles).find(bn => { const {nameSpace, user} = _bundles[bn]; return possibleIds.some(d => { if (nameSpace) { const parsed = parse(d); if (parsed.bareId.slice(0, nameSpace.length + 1) === nameSpace + '/') { d = parsed.prefix + parsed.bareId.slice(nameSpace.length + 1); } } if (user.hasOwnProperty(d)) return true; const p = parse(d); // For module with unknown plugin prefix, try bareId. // This relies on dumber bundler's default behaviour, it write in bundle config // both 'foo.html' and 'text!foo.html'. if (p.prefix) return user.hasOwnProperty(p.bareId); }); }); if (bundleName) { return loadBundle(bundleName) .then(() => { if (userSpace.has(mId)) return userSpace.req(mId); // mId is not directly defined in the bundle, it could be // behind a customised plugin or ext plugin. const tried = tryPlugin(mId, userSpace); if (tried) return tried; throw new Error(`module "${mId}" is missing from bundle "${bundleName}"`); }); } }
javascript
function userReqFromBundle(mId) { const possibleIds = nodejsIds(mId); const bundleName = Object.keys(_bundles).find(bn => { const {nameSpace, user} = _bundles[bn]; return possibleIds.some(d => { if (nameSpace) { const parsed = parse(d); if (parsed.bareId.slice(0, nameSpace.length + 1) === nameSpace + '/') { d = parsed.prefix + parsed.bareId.slice(nameSpace.length + 1); } } if (user.hasOwnProperty(d)) return true; const p = parse(d); // For module with unknown plugin prefix, try bareId. // This relies on dumber bundler's default behaviour, it write in bundle config // both 'foo.html' and 'text!foo.html'. if (p.prefix) return user.hasOwnProperty(p.bareId); }); }); if (bundleName) { return loadBundle(bundleName) .then(() => { if (userSpace.has(mId)) return userSpace.req(mId); // mId is not directly defined in the bundle, it could be // behind a customised plugin or ext plugin. const tried = tryPlugin(mId, userSpace); if (tried) return tried; throw new Error(`module "${mId}" is missing from bundle "${bundleName}"`); }); } }
[ "function", "userReqFromBundle", "(", "mId", ")", "{", "const", "possibleIds", "=", "nodejsIds", "(", "mId", ")", ";", "const", "bundleName", "=", "Object", ".", "keys", "(", "_bundles", ")", ".", "find", "(", "bn", "=>", "{", "const", "{", "nameSpace", ",", "user", "}", "=", "_bundles", "[", "bn", "]", ";", "return", "possibleIds", ".", "some", "(", "d", "=>", "{", "if", "(", "nameSpace", ")", "{", "const", "parsed", "=", "parse", "(", "d", ")", ";", "if", "(", "parsed", ".", "bareId", ".", "slice", "(", "0", ",", "nameSpace", ".", "length", "+", "1", ")", "===", "nameSpace", "+", "'/'", ")", "{", "d", "=", "parsed", ".", "prefix", "+", "parsed", ".", "bareId", ".", "slice", "(", "nameSpace", ".", "length", "+", "1", ")", ";", "}", "}", "if", "(", "user", ".", "hasOwnProperty", "(", "d", ")", ")", "return", "true", ";", "const", "p", "=", "parse", "(", "d", ")", ";", "if", "(", "p", ".", "prefix", ")", "return", "user", ".", "hasOwnProperty", "(", "p", ".", "bareId", ")", ";", "}", ")", ";", "}", ")", ";", "if", "(", "bundleName", ")", "{", "return", "loadBundle", "(", "bundleName", ")", ".", "then", "(", "(", ")", "=>", "{", "if", "(", "userSpace", ".", "has", "(", "mId", ")", ")", "return", "userSpace", ".", "req", "(", "mId", ")", ";", "const", "tried", "=", "tryPlugin", "(", "mId", ",", "userSpace", ")", ";", "if", "(", "tried", ")", "return", "tried", ";", "throw", "new", "Error", "(", "`", "${", "mId", "}", "${", "bundleName", "}", "`", ")", ";", "}", ")", ";", "}", "}" ]
incoming id is already mapped return a promise to load additional bundle or return undefined.
[ "incoming", "id", "is", "already", "mapped", "return", "a", "promise", "to", "load", "additional", "bundle", "or", "return", "undefined", "." ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L312-L344
train
dumberjs/dumber-module-loader
src/index.js
packageReqFromBundle
function packageReqFromBundle(mId) { const possibleIds = nodejsIds(mId); const bundleName = Object.keys(_bundles).find(bn => possibleIds.some(d => { const pack = _bundles[bn].package; if (pack.hasOwnProperty(d)) return true; const p = parse(d); // For module with unknown plugin prefix, try bareId. // This relies on dumber bundler's default behaviour, it write in bundle config // both 'foo.html' and 'text!foo.html'. if (p.prefix) return pack.hasOwnProperty(p.bareId); }) ); if (bundleName) { return loadBundle(bundleName) .then(() => { if (packageSpace.has(mId)) return packageSpace.req(mId); const tried = tryPlugin(mId, packageSpace); if (tried) return tried; throw new Error(`module "${mId}" is missing from bundle "${bundleName}"`); }); } const err = new Error(`no bundle for module "${mId}"`); err.__unkown = mId; throw err; }
javascript
function packageReqFromBundle(mId) { const possibleIds = nodejsIds(mId); const bundleName = Object.keys(_bundles).find(bn => possibleIds.some(d => { const pack = _bundles[bn].package; if (pack.hasOwnProperty(d)) return true; const p = parse(d); // For module with unknown plugin prefix, try bareId. // This relies on dumber bundler's default behaviour, it write in bundle config // both 'foo.html' and 'text!foo.html'. if (p.prefix) return pack.hasOwnProperty(p.bareId); }) ); if (bundleName) { return loadBundle(bundleName) .then(() => { if (packageSpace.has(mId)) return packageSpace.req(mId); const tried = tryPlugin(mId, packageSpace); if (tried) return tried; throw new Error(`module "${mId}" is missing from bundle "${bundleName}"`); }); } const err = new Error(`no bundle for module "${mId}"`); err.__unkown = mId; throw err; }
[ "function", "packageReqFromBundle", "(", "mId", ")", "{", "const", "possibleIds", "=", "nodejsIds", "(", "mId", ")", ";", "const", "bundleName", "=", "Object", ".", "keys", "(", "_bundles", ")", ".", "find", "(", "bn", "=>", "possibleIds", ".", "some", "(", "d", "=>", "{", "const", "pack", "=", "_bundles", "[", "bn", "]", ".", "package", ";", "if", "(", "pack", ".", "hasOwnProperty", "(", "d", ")", ")", "return", "true", ";", "const", "p", "=", "parse", "(", "d", ")", ";", "if", "(", "p", ".", "prefix", ")", "return", "pack", ".", "hasOwnProperty", "(", "p", ".", "bareId", ")", ";", "}", ")", ")", ";", "if", "(", "bundleName", ")", "{", "return", "loadBundle", "(", "bundleName", ")", ".", "then", "(", "(", ")", "=>", "{", "if", "(", "packageSpace", ".", "has", "(", "mId", ")", ")", "return", "packageSpace", ".", "req", "(", "mId", ")", ";", "const", "tried", "=", "tryPlugin", "(", "mId", ",", "packageSpace", ")", ";", "if", "(", "tried", ")", "return", "tried", ";", "throw", "new", "Error", "(", "`", "${", "mId", "}", "${", "bundleName", "}", "`", ")", ";", "}", ")", ";", "}", "const", "err", "=", "new", "Error", "(", "`", "${", "mId", "}", "`", ")", ";", "err", ".", "__unkown", "=", "mId", ";", "throw", "err", ";", "}" ]
incoming id is already mapped return a promise to load additional bundle or throw an error to help userSpaceTesseract to identify sync return.
[ "incoming", "id", "is", "already", "mapped", "return", "a", "promise", "to", "load", "additional", "bundle", "or", "throw", "an", "error", "to", "help", "userSpaceTesseract", "to", "identify", "sync", "return", "." ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L349-L376
train
dumberjs/dumber-module-loader
src/index.js
loadBundle
function loadBundle(bundleName) { if (!_bundleLoad[bundleName]) { const mappedBundleName = _paths[bundleName] || bundleName; const url = toUrl(mappedBundleName); const {nameSpace} = _bundles[bundleName] || {}; let job; // I really hate this. // Use script tag, not fetch, only to support sourcemaps. // And I don't know how to mock it up, so __skip_script_load_test if (!define.__skip_script_load_test && isBrowser && // no name space or browser has support of document.currentScript (!nameSpace || 'currentScript' in _global.document)) { job = new Promise((resolve, reject) => { const script = document.createElement('script'); if (nameSpace) { script.setAttribute('data-namespace', nameSpace); } script.type = 'text/javascript'; script.charset = 'utf-8'; script.async = true; script.addEventListener('load', resolve); script.addEventListener('error', reject); script.src = url; // If the script is cached, IE10 executes the script body and the // onload handler synchronously here. That's a spec violation, // so be sure to do this asynchronously. if (document.documentMode === 10) { setTimeout(() => { document.head.appendChild(script); }); } else { document.head.appendChild(script); } }); } if (!job) { // in nodejs or web worker // or need name space in browser doesn't support document.currentScipt job = _fetch(mappedBundleName) .then(response => response.text()) .then(text => { // ensure default user space // the bundle itself may switch to package space in middle of the file switchToUserSpace(); if (!nameSpace) { (new Function(text)).call(_global); } else { const wrapped = function(id, deps, cb) { nameSpacedDefine(nameSpace, id, deps, cb); }; wrapped.amd = define.amd; wrapped.switchToUserSpace = switchToUserSpace; wrapped.switchToPackageSpace = switchToPackageSpace; const f = new Function('define', text); f.call(_global, wrapped); } }); } _bundleLoad[bundleName] = job; } return _bundleLoad[bundleName]; }
javascript
function loadBundle(bundleName) { if (!_bundleLoad[bundleName]) { const mappedBundleName = _paths[bundleName] || bundleName; const url = toUrl(mappedBundleName); const {nameSpace} = _bundles[bundleName] || {}; let job; // I really hate this. // Use script tag, not fetch, only to support sourcemaps. // And I don't know how to mock it up, so __skip_script_load_test if (!define.__skip_script_load_test && isBrowser && // no name space or browser has support of document.currentScript (!nameSpace || 'currentScript' in _global.document)) { job = new Promise((resolve, reject) => { const script = document.createElement('script'); if (nameSpace) { script.setAttribute('data-namespace', nameSpace); } script.type = 'text/javascript'; script.charset = 'utf-8'; script.async = true; script.addEventListener('load', resolve); script.addEventListener('error', reject); script.src = url; // If the script is cached, IE10 executes the script body and the // onload handler synchronously here. That's a spec violation, // so be sure to do this asynchronously. if (document.documentMode === 10) { setTimeout(() => { document.head.appendChild(script); }); } else { document.head.appendChild(script); } }); } if (!job) { // in nodejs or web worker // or need name space in browser doesn't support document.currentScipt job = _fetch(mappedBundleName) .then(response => response.text()) .then(text => { // ensure default user space // the bundle itself may switch to package space in middle of the file switchToUserSpace(); if (!nameSpace) { (new Function(text)).call(_global); } else { const wrapped = function(id, deps, cb) { nameSpacedDefine(nameSpace, id, deps, cb); }; wrapped.amd = define.amd; wrapped.switchToUserSpace = switchToUserSpace; wrapped.switchToPackageSpace = switchToPackageSpace; const f = new Function('define', text); f.call(_global, wrapped); } }); } _bundleLoad[bundleName] = job; } return _bundleLoad[bundleName]; }
[ "function", "loadBundle", "(", "bundleName", ")", "{", "if", "(", "!", "_bundleLoad", "[", "bundleName", "]", ")", "{", "const", "mappedBundleName", "=", "_paths", "[", "bundleName", "]", "||", "bundleName", ";", "const", "url", "=", "toUrl", "(", "mappedBundleName", ")", ";", "const", "{", "nameSpace", "}", "=", "_bundles", "[", "bundleName", "]", "||", "{", "}", ";", "let", "job", ";", "if", "(", "!", "define", ".", "__skip_script_load_test", "&&", "isBrowser", "&&", "(", "!", "nameSpace", "||", "'currentScript'", "in", "_global", ".", "document", ")", ")", "{", "job", "=", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const", "script", "=", "document", ".", "createElement", "(", "'script'", ")", ";", "if", "(", "nameSpace", ")", "{", "script", ".", "setAttribute", "(", "'data-namespace'", ",", "nameSpace", ")", ";", "}", "script", ".", "type", "=", "'text/javascript'", ";", "script", ".", "charset", "=", "'utf-8'", ";", "script", ".", "async", "=", "true", ";", "script", ".", "addEventListener", "(", "'load'", ",", "resolve", ")", ";", "script", ".", "addEventListener", "(", "'error'", ",", "reject", ")", ";", "script", ".", "src", "=", "url", ";", "if", "(", "document", ".", "documentMode", "===", "10", ")", "{", "setTimeout", "(", "(", ")", "=>", "{", "document", ".", "head", ".", "appendChild", "(", "script", ")", ";", "}", ")", ";", "}", "else", "{", "document", ".", "head", ".", "appendChild", "(", "script", ")", ";", "}", "}", ")", ";", "}", "if", "(", "!", "job", ")", "{", "job", "=", "_fetch", "(", "mappedBundleName", ")", ".", "then", "(", "response", "=>", "response", ".", "text", "(", ")", ")", ".", "then", "(", "text", "=>", "{", "switchToUserSpace", "(", ")", ";", "if", "(", "!", "nameSpace", ")", "{", "(", "new", "Function", "(", "text", ")", ")", ".", "call", "(", "_global", ")", ";", "}", "else", "{", "const", "wrapped", "=", "function", "(", "id", ",", "deps", ",", "cb", ")", "{", "nameSpacedDefine", "(", "nameSpace", ",", "id", ",", "deps", ",", "cb", ")", ";", "}", ";", "wrapped", ".", "amd", "=", "define", ".", "amd", ";", "wrapped", ".", "switchToUserSpace", "=", "switchToUserSpace", ";", "wrapped", ".", "switchToPackageSpace", "=", "switchToPackageSpace", ";", "const", "f", "=", "new", "Function", "(", "'define'", ",", "text", ")", ";", "f", ".", "call", "(", "_global", ",", "wrapped", ")", ";", "}", "}", ")", ";", "}", "_bundleLoad", "[", "bundleName", "]", "=", "job", ";", "}", "return", "_bundleLoad", "[", "bundleName", "]", ";", "}" ]
return a promise
[ "return", "a", "promise" ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L380-L447
train
dumberjs/dumber-module-loader
src/index.js
nameSpacedDefine
function nameSpacedDefine(nameSpace, id, deps, callback) { // only add name space for modules in user space // also skip any ext: plugin (a dumber-module-loader feature) if (currentSpace === userSpace && id.slice(0, 4) !== 'ext:') { const parsed = parse(id); userSpace.define(parsed.prefix + nameSpace + '/' + parsed.bareId, deps, callback); } else { currentSpace.define(id, deps, callback); } }
javascript
function nameSpacedDefine(nameSpace, id, deps, callback) { // only add name space for modules in user space // also skip any ext: plugin (a dumber-module-loader feature) if (currentSpace === userSpace && id.slice(0, 4) !== 'ext:') { const parsed = parse(id); userSpace.define(parsed.prefix + nameSpace + '/' + parsed.bareId, deps, callback); } else { currentSpace.define(id, deps, callback); } }
[ "function", "nameSpacedDefine", "(", "nameSpace", ",", "id", ",", "deps", ",", "callback", ")", "{", "if", "(", "currentSpace", "===", "userSpace", "&&", "id", ".", "slice", "(", "0", ",", "4", ")", "!==", "'ext:'", ")", "{", "const", "parsed", "=", "parse", "(", "id", ")", ";", "userSpace", ".", "define", "(", "parsed", ".", "prefix", "+", "nameSpace", "+", "'/'", "+", "parsed", ".", "bareId", ",", "deps", ",", "callback", ")", ";", "}", "else", "{", "currentSpace", ".", "define", "(", "id", ",", "deps", ",", "callback", ")", ";", "}", "}" ]
Special named spaced define Designed to load runtime extensions
[ "Special", "named", "spaced", "define", "Designed", "to", "load", "runtime", "extensions" ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L480-L489
train
dumberjs/dumber-module-loader
src/index.js
requireFunc
function requireFunc() { if (typeof arguments[0] === 'string') { const dep = arguments[0]; const got = defined(dep); if (got) return got.val; throw new Error(`commonjs dependency "${dep}" is not prepared.`); } return requirejs.apply(null, arguments); }
javascript
function requireFunc() { if (typeof arguments[0] === 'string') { const dep = arguments[0]; const got = defined(dep); if (got) return got.val; throw new Error(`commonjs dependency "${dep}" is not prepared.`); } return requirejs.apply(null, arguments); }
[ "function", "requireFunc", "(", ")", "{", "if", "(", "typeof", "arguments", "[", "0", "]", "===", "'string'", ")", "{", "const", "dep", "=", "arguments", "[", "0", "]", ";", "const", "got", "=", "defined", "(", "dep", ")", ";", "if", "(", "got", ")", "return", "got", ".", "val", ";", "throw", "new", "Error", "(", "`", "${", "dep", "}", "`", ")", ";", "}", "return", "requirejs", ".", "apply", "(", "null", ",", "arguments", ")", ";", "}" ]
return AMD require function or commonjs require function
[ "return", "AMD", "require", "function", "or", "commonjs", "require", "function" ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L506-L515
train
dumberjs/dumber-module-loader
src/index.js
loadWasm
function loadWasm(name, req, load) { req(['raw!' + name], response => { response.arrayBuffer().then(buffer => WebAssembly.instantiate(buffer, /*importObject*/) ) .then( obj => { load(obj.instance.exports); }, load.error ); }); }
javascript
function loadWasm(name, req, load) { req(['raw!' + name], response => { response.arrayBuffer().then(buffer => WebAssembly.instantiate(buffer, /*importObject*/) ) .then( obj => { load(obj.instance.exports); }, load.error ); }); }
[ "function", "loadWasm", "(", "name", ",", "req", ",", "load", ")", "{", "req", "(", "[", "'raw!'", "+", "name", "]", ",", "response", "=>", "{", "response", ".", "arrayBuffer", "(", ")", ".", "then", "(", "buffer", "=>", "WebAssembly", ".", "instantiate", "(", "buffer", ",", ")", ")", ".", "then", "(", "obj", "=>", "{", "load", "(", "obj", ".", "instance", ".", "exports", ")", ";", "}", ",", "load", ".", "error", ")", ";", "}", ")", ";", "}" ]
Only support wasm without importObject. How to know what kind of importObject the wasm file needs?
[ "Only", "support", "wasm", "without", "importObject", ".", "How", "to", "know", "what", "kind", "of", "importObject", "the", "wasm", "file", "needs?" ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L566-L578
train
dumberjs/dumber-module-loader
src/index.js
config
function config(opts) { if (!opts) return; if (opts.baseUrl) _baseUrl = parse(opts.baseUrl).bareId + '/'; if (opts.paths) { Object.keys(opts.paths).forEach(path => { let alias = opts.paths[path]; _paths[cleanPath(path)] = cleanPath(alias); }); } if (opts.bundles) { Object.keys(opts.bundles).forEach(bundleName => { const spaces = opts.bundles[bundleName]; if (Array.isArray(spaces)) { _bundles[bundleName] = { user: arrayToHash(spaces), package: arrayToHash([]) }; } else { _bundles[bundleName] = { nameSpace: spaces.nameSpace || null, user: arrayToHash(spaces.user || []), package: arrayToHash(spaces.package || []) }; } }); } }
javascript
function config(opts) { if (!opts) return; if (opts.baseUrl) _baseUrl = parse(opts.baseUrl).bareId + '/'; if (opts.paths) { Object.keys(opts.paths).forEach(path => { let alias = opts.paths[path]; _paths[cleanPath(path)] = cleanPath(alias); }); } if (opts.bundles) { Object.keys(opts.bundles).forEach(bundleName => { const spaces = opts.bundles[bundleName]; if (Array.isArray(spaces)) { _bundles[bundleName] = { user: arrayToHash(spaces), package: arrayToHash([]) }; } else { _bundles[bundleName] = { nameSpace: spaces.nameSpace || null, user: arrayToHash(spaces.user || []), package: arrayToHash(spaces.package || []) }; } }); } }
[ "function", "config", "(", "opts", ")", "{", "if", "(", "!", "opts", ")", "return", ";", "if", "(", "opts", ".", "baseUrl", ")", "_baseUrl", "=", "parse", "(", "opts", ".", "baseUrl", ")", ".", "bareId", "+", "'/'", ";", "if", "(", "opts", ".", "paths", ")", "{", "Object", ".", "keys", "(", "opts", ".", "paths", ")", ".", "forEach", "(", "path", "=>", "{", "let", "alias", "=", "opts", ".", "paths", "[", "path", "]", ";", "_paths", "[", "cleanPath", "(", "path", ")", "]", "=", "cleanPath", "(", "alias", ")", ";", "}", ")", ";", "}", "if", "(", "opts", ".", "bundles", ")", "{", "Object", ".", "keys", "(", "opts", ".", "bundles", ")", ".", "forEach", "(", "bundleName", "=>", "{", "const", "spaces", "=", "opts", ".", "bundles", "[", "bundleName", "]", ";", "if", "(", "Array", ".", "isArray", "(", "spaces", ")", ")", "{", "_bundles", "[", "bundleName", "]", "=", "{", "user", ":", "arrayToHash", "(", "spaces", ")", ",", "package", ":", "arrayToHash", "(", "[", "]", ")", "}", ";", "}", "else", "{", "_bundles", "[", "bundleName", "]", "=", "{", "nameSpace", ":", "spaces", ".", "nameSpace", "||", "null", ",", "user", ":", "arrayToHash", "(", "spaces", ".", "user", "||", "[", "]", ")", ",", "package", ":", "arrayToHash", "(", "spaces", ".", "package", "||", "[", "]", ")", "}", ";", "}", "}", ")", ";", "}", "}" ]
minimum support of requirejs config baseUrl paths, relative to baseUrl bundles, for code splitting
[ "minimum", "support", "of", "requirejs", "config", "baseUrl", "paths", "relative", "to", "baseUrl", "bundles", "for", "code", "splitting" ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L635-L663
train
llorsat/wonkajs
dist/templates/core/contrib/less.js
function () { var name, index = i; if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) { return new(tree.Variable)(name, index, env.currentFileInfo); } }
javascript
function () { var name, index = i; if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) { return new(tree.Variable)(name, index, env.currentFileInfo); } }
[ "function", "(", ")", "{", "var", "name", ",", "index", "=", "i", ";", "if", "(", "input", ".", "charAt", "(", "i", ")", "===", "'@'", "&&", "(", "name", "=", "$", "(", "/", "^@@?[\\w-]+", "/", ")", ")", ")", "{", "return", "new", "(", "tree", ".", "Variable", ")", "(", "name", ",", "index", ",", "env", ".", "currentFileInfo", ")", ";", "}", "}" ]
A Variable entity, such as `@fink`, in width: @fink + 2px We use a different parser for variable definitions, see `parsers.variable`.
[ "A", "Variable", "entity", "such", "as" ]
c45d7feaefa8dbf29b6fd1c824a1767173452611
https://github.com/llorsat/wonkajs/blob/c45d7feaefa8dbf29b6fd1c824a1767173452611/dist/templates/core/contrib/less.js#L713-L719
train
taskcluster/taskcluster-lib-loader
src/loader.js
validateComponent
function validateComponent(def, name) { let e = 'Invalid component definition: ' + name; // Check that it's an object if (typeof def !== 'object' && def !== null && def !== undefined) { throw new Error(e + ' must be an object, null or undefined'); } // Check that is object has a setup function if (!(def.setup instanceof Function)) { throw new Error(e + ' is missing setup function'); } // If requires is defined, then we check that it's an array of strings if (def.requires) { if (!(def.requires instanceof Array)) { throw new Error(e + ' if present, requires must be array'); } // Check that all entries in def.requires are strings if (!def.requires.every(entry => typeof entry === 'string')) { throw new Error(e + ' all items in requires must be strings'); } } }
javascript
function validateComponent(def, name) { let e = 'Invalid component definition: ' + name; // Check that it's an object if (typeof def !== 'object' && def !== null && def !== undefined) { throw new Error(e + ' must be an object, null or undefined'); } // Check that is object has a setup function if (!(def.setup instanceof Function)) { throw new Error(e + ' is missing setup function'); } // If requires is defined, then we check that it's an array of strings if (def.requires) { if (!(def.requires instanceof Array)) { throw new Error(e + ' if present, requires must be array'); } // Check that all entries in def.requires are strings if (!def.requires.every(entry => typeof entry === 'string')) { throw new Error(e + ' all items in requires must be strings'); } } }
[ "function", "validateComponent", "(", "def", ",", "name", ")", "{", "let", "e", "=", "'Invalid component definition: '", "+", "name", ";", "if", "(", "typeof", "def", "!==", "'object'", "&&", "def", "!==", "null", "&&", "def", "!==", "undefined", ")", "{", "throw", "new", "Error", "(", "e", "+", "' must be an object, null or undefined'", ")", ";", "}", "if", "(", "!", "(", "def", ".", "setup", "instanceof", "Function", ")", ")", "{", "throw", "new", "Error", "(", "e", "+", "' is missing setup function'", ")", ";", "}", "if", "(", "def", ".", "requires", ")", "{", "if", "(", "!", "(", "def", ".", "requires", "instanceof", "Array", ")", ")", "{", "throw", "new", "Error", "(", "e", "+", "' if present, requires must be array'", ")", ";", "}", "if", "(", "!", "def", ".", "requires", ".", "every", "(", "entry", "=>", "typeof", "entry", "===", "'string'", ")", ")", "{", "throw", "new", "Error", "(", "e", "+", "' all items in requires must be strings'", ")", ";", "}", "}", "}" ]
Validate component definition
[ "Validate", "component", "definition" ]
b68f0a8f7b495a51d51b9a438a5bb1516608b359
https://github.com/taskcluster/taskcluster-lib-loader/blob/b68f0a8f7b495a51d51b9a438a5bb1516608b359/src/loader.js#L16-L36
train
taskcluster/taskcluster-lib-loader
src/loader.js
renderGraph
function renderGraph(componentDirectory, sortedComponents) { let dot = [ '// This graph shows all dependencies for this loader.', '// You might find http://www.webgraphviz.com/ useful!', '', 'digraph G {', ]; for (let component of sortedComponents) { dot.push(util.format(' "%s"', component)); let def = componentDirectory[component] || {}; for (let dep of def.requires || []) { dot.push(util.format(' "%s" -> "%s" [dir=back]', dep, component)); } } dot.push('}'); return dot.join('\n'); }
javascript
function renderGraph(componentDirectory, sortedComponents) { let dot = [ '// This graph shows all dependencies for this loader.', '// You might find http://www.webgraphviz.com/ useful!', '', 'digraph G {', ]; for (let component of sortedComponents) { dot.push(util.format(' "%s"', component)); let def = componentDirectory[component] || {}; for (let dep of def.requires || []) { dot.push(util.format(' "%s" -> "%s" [dir=back]', dep, component)); } } dot.push('}'); return dot.join('\n'); }
[ "function", "renderGraph", "(", "componentDirectory", ",", "sortedComponents", ")", "{", "let", "dot", "=", "[", "'// This graph shows all dependencies for this loader.'", ",", "'// You might find http://www.webgraphviz.com/ useful!'", ",", "''", ",", "'digraph G {'", ",", "]", ";", "for", "(", "let", "component", "of", "sortedComponents", ")", "{", "dot", ".", "push", "(", "util", ".", "format", "(", "' \"%s\"'", ",", "component", ")", ")", ";", "let", "def", "=", "componentDirectory", "[", "component", "]", "||", "{", "}", ";", "for", "(", "let", "dep", "of", "def", ".", "requires", "||", "[", "]", ")", "{", "dot", ".", "push", "(", "util", ".", "format", "(", "' \"%s\" -> \"%s\" [dir=back]'", ",", "dep", ",", "component", ")", ")", ";", "}", "}", "dot", ".", "push", "(", "'}'", ")", ";", "return", "dot", ".", "join", "(", "'\\n'", ")", ";", "}" ]
Render componentDirectory to dot format for graphviz given a topologically sorted list of components
[ "Render", "componentDirectory", "to", "dot", "format", "for", "graphviz", "given", "a", "topologically", "sorted", "list", "of", "components" ]
b68f0a8f7b495a51d51b9a438a5bb1516608b359
https://github.com/taskcluster/taskcluster-lib-loader/blob/b68f0a8f7b495a51d51b9a438a5bb1516608b359/src/loader.js#L42-L60
train
taskcluster/taskcluster-lib-loader
src/loader.js
load
function load(target) { if (!loaded[target]) { var def = componentDirectory[target]; // Initialize component, this won't cause an infinite loop because // we've already check that the componentDirectory is a DAG let requires = def.requires || []; return loaded[target] = Promise.all(requires.map(load)).then(deps => { let ctx = {}; for (let i = 0; i < deps.length; i++) { ctx[def.requires[i]] = deps[i]; } return new Promise((resolve, reject) => { try { resolve(def.setup.call(null, ctx)); } catch (err) { reject(err); } }).catch(function(err) { debug(`error while loading component '${target}': ${err}`); throw err; }); }); } return loaded[target]; }
javascript
function load(target) { if (!loaded[target]) { var def = componentDirectory[target]; // Initialize component, this won't cause an infinite loop because // we've already check that the componentDirectory is a DAG let requires = def.requires || []; return loaded[target] = Promise.all(requires.map(load)).then(deps => { let ctx = {}; for (let i = 0; i < deps.length; i++) { ctx[def.requires[i]] = deps[i]; } return new Promise((resolve, reject) => { try { resolve(def.setup.call(null, ctx)); } catch (err) { reject(err); } }).catch(function(err) { debug(`error while loading component '${target}': ${err}`); throw err; }); }); } return loaded[target]; }
[ "function", "load", "(", "target", ")", "{", "if", "(", "!", "loaded", "[", "target", "]", ")", "{", "var", "def", "=", "componentDirectory", "[", "target", "]", ";", "let", "requires", "=", "def", ".", "requires", "||", "[", "]", ";", "return", "loaded", "[", "target", "]", "=", "Promise", ".", "all", "(", "requires", ".", "map", "(", "load", ")", ")", ".", "then", "(", "deps", "=>", "{", "let", "ctx", "=", "{", "}", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "deps", ".", "length", ";", "i", "++", ")", "{", "ctx", "[", "def", ".", "requires", "[", "i", "]", "]", "=", "deps", "[", "i", "]", ";", "}", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "try", "{", "resolve", "(", "def", ".", "setup", ".", "call", "(", "null", ",", "ctx", ")", ")", ";", "}", "catch", "(", "err", ")", "{", "reject", "(", "err", ")", ";", "}", "}", ")", ".", "catch", "(", "function", "(", "err", ")", "{", "debug", "(", "`", "${", "target", "}", "${", "err", "}", "`", ")", ";", "throw", "err", ";", "}", ")", ";", "}", ")", ";", "}", "return", "loaded", "[", "target", "]", ";", "}" ]
Load a component
[ "Load", "a", "component" ]
b68f0a8f7b495a51d51b9a438a5bb1516608b359
https://github.com/taskcluster/taskcluster-lib-loader/blob/b68f0a8f7b495a51d51b9a438a5bb1516608b359/src/loader.js#L204-L228
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/menu-debug.js
function (element) { var self = this; var $el = self.$el; // 隐藏当然不包含了 // 隐藏当然不包含了 if (!self.get('visible') || !$el) { return false; } if ($el && ($el[0] === element || $el.contains(element))) { return true; } var children = self.get('children'); for (var i = 0, count = children.length; i < count; i++) { var child = children[i]; if (child.containsElement && child.containsElement(element)) { return true; } } return false; }
javascript
function (element) { var self = this; var $el = self.$el; // 隐藏当然不包含了 // 隐藏当然不包含了 if (!self.get('visible') || !$el) { return false; } if ($el && ($el[0] === element || $el.contains(element))) { return true; } var children = self.get('children'); for (var i = 0, count = children.length; i < count; i++) { var child = children[i]; if (child.containsElement && child.containsElement(element)) { return true; } } return false; }
[ "function", "(", "element", ")", "{", "var", "self", "=", "this", ";", "var", "$el", "=", "self", ".", "$el", ";", "if", "(", "!", "self", ".", "get", "(", "'visible'", ")", "||", "!", "$el", ")", "{", "return", "false", ";", "}", "if", "(", "$el", "&&", "(", "$el", "[", "0", "]", "===", "element", "||", "$el", ".", "contains", "(", "element", ")", ")", ")", "{", "return", "true", ";", "}", "var", "children", "=", "self", ".", "get", "(", "'children'", ")", ";", "for", "(", "var", "i", "=", "0", ",", "count", "=", "children", ".", "length", ";", "i", "<", "count", ";", "i", "++", ")", "{", "var", "child", "=", "children", "[", "i", "]", ";", "if", "(", "child", ".", "containsElement", "&&", "child", ".", "containsElement", "(", "element", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Whether this menu contains specified html element. @param {KISSY.Node} element html Element to be tested. @return {Boolean} @protected
[ "Whether", "this", "menu", "contains", "specified", "html", "element", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/menu-debug.js#L207-L225
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/menu-debug.js
afterHighlightedItemChange
function afterHighlightedItemChange(e) { if (e.target.isMenu) { var el = this.el, menuItem = e.newVal; el.setAttribute('aria-activedescendant', menuItem && menuItem.el.id || ''); } }
javascript
function afterHighlightedItemChange(e) { if (e.target.isMenu) { var el = this.el, menuItem = e.newVal; el.setAttribute('aria-activedescendant', menuItem && menuItem.el.id || ''); } }
[ "function", "afterHighlightedItemChange", "(", "e", ")", "{", "if", "(", "e", ".", "target", ".", "isMenu", ")", "{", "var", "el", "=", "this", ".", "el", ",", "menuItem", "=", "e", ".", "newVal", ";", "el", ".", "setAttribute", "(", "'aria-activedescendant'", ",", "menuItem", "&&", "menuItem", ".", "el", ".", "id", "||", "''", ")", ";", "}", "}" ]
capture bubbling capture bubbling
[ "capture", "bubbling", "capture", "bubbling" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/menu-debug.js#L247-L252
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/menu-debug.js
function (v, e) { var self = this; self.callSuper(v, e); // sync // sync if (!e) { return; } if (e.fromMouse) { return; } if (v && !e.fromKeyboard) { showMenu.call(self); } else if (!v) { hideMenu.call(self); } }
javascript
function (v, e) { var self = this; self.callSuper(v, e); // sync // sync if (!e) { return; } if (e.fromMouse) { return; } if (v && !e.fromKeyboard) { showMenu.call(self); } else if (!v) { hideMenu.call(self); } }
[ "function", "(", "v", ",", "e", ")", "{", "var", "self", "=", "this", ";", "self", ".", "callSuper", "(", "v", ",", "e", ")", ";", "if", "(", "!", "e", ")", "{", "return", ";", "}", "if", "(", "e", ".", "fromMouse", ")", "{", "return", ";", "}", "if", "(", "v", "&&", "!", "e", ".", "fromKeyboard", ")", "{", "showMenu", ".", "call", "(", "self", ")", ";", "}", "else", "if", "(", "!", "v", ")", "{", "hideMenu", ".", "call", "(", "self", ")", ";", "}", "}" ]
Dismisses the submenu on a delay, with the result that the user needs less accuracy when moving to sub menus. @protected
[ "Dismisses", "the", "submenu", "on", "a", "delay", "with", "the", "result", "that", "the", "user", "needs", "less", "accuracy", "when", "moving", "to", "sub", "menus", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/menu-debug.js#L663-L678
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/menu-debug.js
function (e) { var self = this, menu = self.get('menu'), menuChildren, menuChild, hasKeyboardControl_ = menu.get('visible'), keyCode = e.keyCode; if (!hasKeyboardControl_) { // right if (keyCode === KeyCode.RIGHT) { showMenu.call(self); menuChildren = menu.get('children'); if (menuChild = menuChildren[0]) { menuChild.set('highlighted', true, { data: { fromKeyboard: 1 } }); } } else if (keyCode === KeyCode.ENTER) { // enter as click return self.handleClickInternal(e); } else { return undefined; } } else if (!menu.handleKeyDownInternal(e)) { // The menu has control and the key hasn't yet been handled, on left arrow // we turn off key control. // left if (keyCode === KeyCode.LEFT) { // refresh highlightedItem of parent menu self.set('highlighted', false); self.set('highlighted', true, { data: { fromKeyboard: 1 } }); } else { return undefined; } } return true; }
javascript
function (e) { var self = this, menu = self.get('menu'), menuChildren, menuChild, hasKeyboardControl_ = menu.get('visible'), keyCode = e.keyCode; if (!hasKeyboardControl_) { // right if (keyCode === KeyCode.RIGHT) { showMenu.call(self); menuChildren = menu.get('children'); if (menuChild = menuChildren[0]) { menuChild.set('highlighted', true, { data: { fromKeyboard: 1 } }); } } else if (keyCode === KeyCode.ENTER) { // enter as click return self.handleClickInternal(e); } else { return undefined; } } else if (!menu.handleKeyDownInternal(e)) { // The menu has control and the key hasn't yet been handled, on left arrow // we turn off key control. // left if (keyCode === KeyCode.LEFT) { // refresh highlightedItem of parent menu self.set('highlighted', false); self.set('highlighted', true, { data: { fromKeyboard: 1 } }); } else { return undefined; } } return true; }
[ "function", "(", "e", ")", "{", "var", "self", "=", "this", ",", "menu", "=", "self", ".", "get", "(", "'menu'", ")", ",", "menuChildren", ",", "menuChild", ",", "hasKeyboardControl_", "=", "menu", ".", "get", "(", "'visible'", ")", ",", "keyCode", "=", "e", ".", "keyCode", ";", "if", "(", "!", "hasKeyboardControl_", ")", "{", "if", "(", "keyCode", "===", "KeyCode", ".", "RIGHT", ")", "{", "showMenu", ".", "call", "(", "self", ")", ";", "menuChildren", "=", "menu", ".", "get", "(", "'children'", ")", ";", "if", "(", "menuChild", "=", "menuChildren", "[", "0", "]", ")", "{", "menuChild", ".", "set", "(", "'highlighted'", ",", "true", ",", "{", "data", ":", "{", "fromKeyboard", ":", "1", "}", "}", ")", ";", "}", "}", "else", "if", "(", "keyCode", "===", "KeyCode", ".", "ENTER", ")", "{", "return", "self", ".", "handleClickInternal", "(", "e", ")", ";", "}", "else", "{", "return", "undefined", ";", "}", "}", "else", "if", "(", "!", "menu", ".", "handleKeyDownInternal", "(", "e", ")", ")", "{", "if", "(", "keyCode", "===", "KeyCode", ".", "LEFT", ")", "{", "self", ".", "set", "(", "'highlighted'", ",", "false", ")", ";", "self", ".", "set", "(", "'highlighted'", ",", "true", ",", "{", "data", ":", "{", "fromKeyboard", ":", "1", "}", "}", ")", ";", "}", "else", "{", "return", "undefined", ";", "}", "}", "return", "true", ";", "}" ]
Handles a key event that is passed to the menu item from its parent because it is highlighted. If the right key is pressed the sub menu takes control and delegates further key events to its menu until it is dismissed OR the left key is pressed. Protected for subclass overridden. @param {KISSY.Event.DomEvent.Object} e key event. @protected @return {Boolean|undefined} Whether the event was handled.
[ "Handles", "a", "key", "event", "that", "is", "passed", "to", "the", "menu", "item", "from", "its", "parent", "because", "it", "is", "highlighted", ".", "If", "the", "right", "key", "is", "pressed", "the", "sub", "menu", "takes", "control", "and", "delegates", "further", "key", "events", "to", "its", "menu", "until", "it", "is", "dismissed", "OR", "the", "left", "key", "is", "pressed", ".", "Protected", "for", "subclass", "overridden", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/menu-debug.js#L695-L724
train
vsch/for-each-break
index.js
forEach
function forEach(callback, thisArg = UNDEFINED, defaultReturn = UNDEFINED) { const savedReturn = BREAK.clearDefault(defaultReturn); const iMax = this.length; let result = thisArg; for (let i = 0; i < iMax; i++) { const value = this[i]; const returned = callback.call(thisArg, value, i, this); if (returned === BREAK) { result = BREAK.returned; break; } } BREAK.restoreDefault(savedReturn); return result; }
javascript
function forEach(callback, thisArg = UNDEFINED, defaultReturn = UNDEFINED) { const savedReturn = BREAK.clearDefault(defaultReturn); const iMax = this.length; let result = thisArg; for (let i = 0; i < iMax; i++) { const value = this[i]; const returned = callback.call(thisArg, value, i, this); if (returned === BREAK) { result = BREAK.returned; break; } } BREAK.restoreDefault(savedReturn); return result; }
[ "function", "forEach", "(", "callback", ",", "thisArg", "=", "UNDEFINED", ",", "defaultReturn", "=", "UNDEFINED", ")", "{", "const", "savedReturn", "=", "BREAK", ".", "clearDefault", "(", "defaultReturn", ")", ";", "const", "iMax", "=", "this", ".", "length", ";", "let", "result", "=", "thisArg", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "iMax", ";", "i", "++", ")", "{", "const", "value", "=", "this", "[", "i", "]", ";", "const", "returned", "=", "callback", ".", "call", "(", "thisArg", ",", "value", ",", "i", ",", "this", ")", ";", "if", "(", "returned", "===", "BREAK", ")", "{", "result", "=", "BREAK", ".", "returned", ";", "break", ";", "}", "}", "BREAK", ".", "restoreDefault", "(", "savedReturn", ")", ";", "return", "result", ";", "}" ]
Execute forEach on array like object and return value using BREAK @this array like object over which to loop @param callback callback function (value, index, array) @param thisArg optional arg to use as this for the callback @param defaultReturn optional default return value @return {*}
[ "Execute", "forEach", "on", "array", "like", "object", "and", "return", "value", "using", "BREAK" ]
6d8e0babce28f2a03d395a64bad1ca1341a4f46d
https://github.com/vsch/for-each-break/blob/6d8e0babce28f2a03d395a64bad1ca1341a4f46d/index.js#L42-L56
train
Automattic/wpcom-unpublished
lib/site.wordads.tos.js
SiteWordAdsTOS
function SiteWordAdsTOS( sid, wpcom ) { if ( ! ( this instanceof SiteWordAdsTOS ) ) { return new SiteWordAdsTOS( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
javascript
function SiteWordAdsTOS( sid, wpcom ) { if ( ! ( this instanceof SiteWordAdsTOS ) ) { return new SiteWordAdsTOS( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
[ "function", "SiteWordAdsTOS", "(", "sid", ",", "wpcom", ")", "{", "if", "(", "!", "(", "this", "instanceof", "SiteWordAdsTOS", ")", ")", "{", "return", "new", "SiteWordAdsTOS", "(", "sid", ",", "wpcom", ")", ";", "}", "this", ".", "_sid", "=", "sid", ";", "this", ".", "wpcom", "=", "wpcom", ";", "}" ]
`SiteWordAdsTOS` constructor. *Example:* // Require `wpcom-unpublished` library var wpcomUnpublished = require( 'wpcom-unpublished' ); // Create a `wpcomUnpublished` instance var wpcom = wpcomUnpublished(); // Create a `SiteWordAdsTOS` instance var wordAds = wpcom .site( 'my-blog.wordpress.com' ) .wordAds() .tos(); @constructor @param {wpcomUnpublished} wpcom @public
[ "SiteWordAdsTOS", "constructor", "." ]
9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e
https://github.com/Automattic/wpcom-unpublished/blob/9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e/lib/site.wordads.tos.js#L23-L30
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/util-debug.js
function (a, override) { var b = a.slice(); if (override) { b.reverse(); } var i = 0, n, item; while (i < b.length) { item = b[i]; while ((n = util.lastIndexOf(item, b)) !== i) { b.splice(n, 1); } i += 1; } if (override) { b.reverse(); } return b; }
javascript
function (a, override) { var b = a.slice(); if (override) { b.reverse(); } var i = 0, n, item; while (i < b.length) { item = b[i]; while ((n = util.lastIndexOf(item, b)) !== i) { b.splice(n, 1); } i += 1; } if (override) { b.reverse(); } return b; }
[ "function", "(", "a", ",", "override", ")", "{", "var", "b", "=", "a", ".", "slice", "(", ")", ";", "if", "(", "override", ")", "{", "b", ".", "reverse", "(", ")", ";", "}", "var", "i", "=", "0", ",", "n", ",", "item", ";", "while", "(", "i", "<", "b", ".", "length", ")", "{", "item", "=", "b", "[", "i", "]", ";", "while", "(", "(", "n", "=", "util", ".", "lastIndexOf", "(", "item", ",", "b", ")", ")", "!==", "i", ")", "{", "b", ".", "splice", "(", "n", ",", "1", ")", ";", "}", "i", "+=", "1", ";", "}", "if", "(", "override", ")", "{", "b", ".", "reverse", "(", ")", ";", "}", "return", "b", ";", "}" ]
Returns a copy of the array with the duplicate entries removed @param a {Array} the array to find the subset of unique for @param [override] {Boolean} if override is TRUE, util.unique([a, b, a]) => [b, a]. if override is FALSE, util.unique([a, b, a]) => [a, b] @return {Array} a copy of the array with duplicate entries removed @member KISSY
[ "Returns", "a", "copy", "of", "the", "array", "with", "the", "duplicate", "entries", "removed" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/util-debug.js#L102-L119
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/util-debug.js
function (r, varArgs) { var args = util.makeArray(arguments), len = args.length - 2, i = 1, proto, arg, ov = args[len], wl = args[len + 1]; args[1] = varArgs; if (!util.isArray(wl)) { ov = wl; wl = undef; len++; } if (typeof ov !== 'boolean') { ov = undef; len++; } for (; i < len; i++) { arg = args[i]; if (proto = arg.prototype) { arg = util.mix({}, proto, true, removeConstructor); } util.mix(r.prototype, arg, ov, wl); } return r; }
javascript
function (r, varArgs) { var args = util.makeArray(arguments), len = args.length - 2, i = 1, proto, arg, ov = args[len], wl = args[len + 1]; args[1] = varArgs; if (!util.isArray(wl)) { ov = wl; wl = undef; len++; } if (typeof ov !== 'boolean') { ov = undef; len++; } for (; i < len; i++) { arg = args[i]; if (proto = arg.prototype) { arg = util.mix({}, proto, true, removeConstructor); } util.mix(r.prototype, arg, ov, wl); } return r; }
[ "function", "(", "r", ",", "varArgs", ")", "{", "var", "args", "=", "util", ".", "makeArray", "(", "arguments", ")", ",", "len", "=", "args", ".", "length", "-", "2", ",", "i", "=", "1", ",", "proto", ",", "arg", ",", "ov", "=", "args", "[", "len", "]", ",", "wl", "=", "args", "[", "len", "+", "1", "]", ";", "args", "[", "1", "]", "=", "varArgs", ";", "if", "(", "!", "util", ".", "isArray", "(", "wl", ")", ")", "{", "ov", "=", "wl", ";", "wl", "=", "undef", ";", "len", "++", ";", "}", "if", "(", "typeof", "ov", "!==", "'boolean'", ")", "{", "ov", "=", "undef", ";", "len", "++", ";", "}", "for", "(", ";", "i", "<", "len", ";", "i", "++", ")", "{", "arg", "=", "args", "[", "i", "]", ";", "if", "(", "proto", "=", "arg", ".", "prototype", ")", "{", "arg", "=", "util", ".", "mix", "(", "{", "}", ",", "proto", ",", "true", ",", "removeConstructor", ")", ";", "}", "util", ".", "mix", "(", "r", ".", "prototype", ",", "arg", ",", "ov", ",", "wl", ")", ";", "}", "return", "r", ";", "}" ]
Applies prototype properties from the supplier to the receiver. @param {Object} r received object @param {...Object} varArgs object need to augment {Boolean} [ov=true] whether overwrite existing property {String[]} [wl] array of white-list properties @return {Object} the augmented object @member KISSY
[ "Applies", "prototype", "properties", "from", "the", "supplier", "to", "the", "receiver", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/util-debug.js#L852-L872
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/util-debug.js
function (id, fn) { id = (id + EMPTY).match(RE_ID_STR)[1]; var retryCount = 1; var timer = util.later(function () { if (++retryCount > POLL_RETIRES) { timer.cancel(); return; } var node = doc.getElementById(id); if (node) { fn(node); timer.cancel(); } }, POLL_INTERVAL, true); }
javascript
function (id, fn) { id = (id + EMPTY).match(RE_ID_STR)[1]; var retryCount = 1; var timer = util.later(function () { if (++retryCount > POLL_RETIRES) { timer.cancel(); return; } var node = doc.getElementById(id); if (node) { fn(node); timer.cancel(); } }, POLL_INTERVAL, true); }
[ "function", "(", "id", ",", "fn", ")", "{", "id", "=", "(", "id", "+", "EMPTY", ")", ".", "match", "(", "RE_ID_STR", ")", "[", "1", "]", ";", "var", "retryCount", "=", "1", ";", "var", "timer", "=", "util", ".", "later", "(", "function", "(", ")", "{", "if", "(", "++", "retryCount", ">", "POLL_RETIRES", ")", "{", "timer", ".", "cancel", "(", ")", ";", "return", ";", "}", "var", "node", "=", "doc", ".", "getElementById", "(", "id", ")", ";", "if", "(", "node", ")", "{", "fn", "(", "node", ")", ";", "timer", ".", "cancel", "(", ")", ";", "}", "}", ",", "POLL_INTERVAL", ",", "true", ")", ";", "}" ]
Executes the supplied callback when the item with the supplied id is found. @param id {String} The id of the element, or an array of ids to look for. @param fn {Function} What to execute when the element is found. @member KISSY
[ "Executes", "the", "supplied", "callback", "when", "the", "item", "with", "the", "supplied", "id", "is", "found", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/util-debug.js#L1490-L1504
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/router-debug.js
getUrlForRouter
function getUrlForRouter(urlStr) { urlStr = urlStr || location.href; var uri = url.parse(urlStr); if (!globalConfig.useHash && supportHistoryPushState) { return uri.pathname.substr(globalConfig.urlRoot.length) + (uri.search || ''); } else { return utils.getHash(urlStr); } }
javascript
function getUrlForRouter(urlStr) { urlStr = urlStr || location.href; var uri = url.parse(urlStr); if (!globalConfig.useHash && supportHistoryPushState) { return uri.pathname.substr(globalConfig.urlRoot.length) + (uri.search || ''); } else { return utils.getHash(urlStr); } }
[ "function", "getUrlForRouter", "(", "urlStr", ")", "{", "urlStr", "=", "urlStr", "||", "location", ".", "href", ";", "var", "uri", "=", "url", ".", "parse", "(", "urlStr", ")", ";", "if", "(", "!", "globalConfig", ".", "useHash", "&&", "supportHistoryPushState", ")", "{", "return", "uri", ".", "pathname", ".", "substr", "(", "globalConfig", ".", "urlRoot", ".", "length", ")", "+", "(", "uri", ".", "search", "||", "''", ")", ";", "}", "else", "{", "return", "utils", ".", "getHash", "(", "urlStr", ")", ";", "}", "}" ]
get url path for router dispatch get url path for router dispatch
[ "get", "url", "path", "for", "router", "dispatch", "get", "url", "path", "for", "router", "dispatch" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/router-debug.js#L63-L71
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/router-debug.js
function (fragment, urlRoot) { return location.protocol + '//' + location.host + this.removeEndSlash(urlRoot) + this.addStartSlash(fragment); }
javascript
function (fragment, urlRoot) { return location.protocol + '//' + location.host + this.removeEndSlash(urlRoot) + this.addStartSlash(fragment); }
[ "function", "(", "fragment", ",", "urlRoot", ")", "{", "return", "location", ".", "protocol", "+", "'//'", "+", "location", ".", "host", "+", "this", ".", "removeEndSlash", "(", "urlRoot", ")", "+", "this", ".", "addStartSlash", "(", "fragment", ")", ";", "}" ]
get full path from fragment for html history
[ "get", "full", "path", "from", "fragment", "for", "html", "history" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/router-debug.js#L539-L541
train
vsch/boxed-state
index.js
saveBoxed
function saveBoxed(onDoneCallback = UNDEFINED) { const boxed = this.boxed; if (boxed) { const modified = boxed[boxedImmutable.BOXED_GET_THIS].valueOfModified(); if (modified !== UNDEFINED) { this.boxed = UNDEFINED; if (this.saveState) { return this.saveState(modified, boxed, onDoneCallback); } else { throw new TypeError("Save State Not Supported on this instance, saveState callback not provided"); } } } else if (onDoneCallback) { onDoneCallback(); } }
javascript
function saveBoxed(onDoneCallback = UNDEFINED) { const boxed = this.boxed; if (boxed) { const modified = boxed[boxedImmutable.BOXED_GET_THIS].valueOfModified(); if (modified !== UNDEFINED) { this.boxed = UNDEFINED; if (this.saveState) { return this.saveState(modified, boxed, onDoneCallback); } else { throw new TypeError("Save State Not Supported on this instance, saveState callback not provided"); } } } else if (onDoneCallback) { onDoneCallback(); } }
[ "function", "saveBoxed", "(", "onDoneCallback", "=", "UNDEFINED", ")", "{", "const", "boxed", "=", "this", ".", "boxed", ";", "if", "(", "boxed", ")", "{", "const", "modified", "=", "boxed", "[", "boxedImmutable", ".", "BOXED_GET_THIS", "]", ".", "valueOfModified", "(", ")", ";", "if", "(", "modified", "!==", "UNDEFINED", ")", "{", "this", ".", "boxed", "=", "UNDEFINED", ";", "if", "(", "this", ".", "saveState", ")", "{", "return", "this", ".", "saveState", "(", "modified", ",", "boxed", ",", "onDoneCallback", ")", ";", "}", "else", "{", "throw", "new", "TypeError", "(", "\"Save State Not Supported on this instance, saveState callback not provided\"", ")", ";", "}", "}", "}", "else", "if", "(", "onDoneCallback", ")", "{", "onDoneCallback", "(", ")", ";", "}", "}" ]
save modified state @param onDoneCallback function to call on save complete @return {*}
[ "save", "modified", "state" ]
b82885eb7de0aa52b4d31a54cb192c9247542c85
https://github.com/vsch/boxed-state/blob/b82885eb7de0aa52b4d31a54cb192c9247542c85/index.js#L32-L47
train
vsch/boxed-state
index.js
cancelBoxed
function cancelBoxed() { const boxed = this.boxed; this.boxed = UNDEFINED; return boxed && boxed[boxedImmutable.BOXED_GET_THIS].unboxedDelta(); }
javascript
function cancelBoxed() { const boxed = this.boxed; this.boxed = UNDEFINED; return boxed && boxed[boxedImmutable.BOXED_GET_THIS].unboxedDelta(); }
[ "function", "cancelBoxed", "(", ")", "{", "const", "boxed", "=", "this", ".", "boxed", ";", "this", ".", "boxed", "=", "UNDEFINED", ";", "return", "boxed", "&&", "boxed", "[", "boxedImmutable", ".", "BOXED_GET_THIS", "]", ".", "unboxedDelta", "(", ")", ";", "}" ]
Cancel changes and return modified so these could be applied later for delayed update. @return {*}
[ "Cancel", "changes", "and", "return", "modified", "so", "these", "could", "be", "applied", "later", "for", "delayed", "update", "." ]
b82885eb7de0aa52b4d31a54cb192c9247542c85
https://github.com/vsch/boxed-state/blob/b82885eb7de0aa52b4d31a54cb192c9247542c85/index.js#L55-L59
train
vsch/boxed-state
index.js
function (target, prop, receiver) { if (isBoxedState(target)) { if (prop === BOXED_GET_THIS) return target; if (prop === target.saveBoxedProp) return target.saveBoxed; if (prop === target.cancelBoxedProp) return target.cancelBoxed; if (prop === target.boxOptionsProp) return target.boxOptions; return target.getBoxed()[prop]; } throw new TypeError("BoxedStateHandler: IllegalArgument expected BoxedState target"); }
javascript
function (target, prop, receiver) { if (isBoxedState(target)) { if (prop === BOXED_GET_THIS) return target; if (prop === target.saveBoxedProp) return target.saveBoxed; if (prop === target.cancelBoxedProp) return target.cancelBoxed; if (prop === target.boxOptionsProp) return target.boxOptions; return target.getBoxed()[prop]; } throw new TypeError("BoxedStateHandler: IllegalArgument expected BoxedState target"); }
[ "function", "(", "target", ",", "prop", ",", "receiver", ")", "{", "if", "(", "isBoxedState", "(", "target", ")", ")", "{", "if", "(", "prop", "===", "BOXED_GET_THIS", ")", "return", "target", ";", "if", "(", "prop", "===", "target", ".", "saveBoxedProp", ")", "return", "target", ".", "saveBoxed", ";", "if", "(", "prop", "===", "target", ".", "cancelBoxedProp", ")", "return", "target", ".", "cancelBoxed", ";", "if", "(", "prop", "===", "target", ".", "boxOptionsProp", ")", "return", "target", ".", "boxOptions", ";", "return", "target", ".", "getBoxed", "(", ")", "[", "prop", "]", ";", "}", "throw", "new", "TypeError", "(", "\"BoxedStateHandler: IllegalArgument expected BoxedState target\"", ")", ";", "}" ]
target is the object with on demand boxed property
[ "target", "is", "the", "object", "with", "on", "demand", "boxed", "property" ]
b82885eb7de0aa52b4d31a54cb192c9247542c85
https://github.com/vsch/boxed-state/blob/b82885eb7de0aa52b4d31a54cb192c9247542c85/index.js#L134-L143
train
bigpipe/supply
index.js
Layer
function Layer(name, fn) { this.length = fn.length; this.name = name; this.fn = fn; }
javascript
function Layer(name, fn) { this.length = fn.length; this.name = name; this.fn = fn; }
[ "function", "Layer", "(", "name", ",", "fn", ")", "{", "this", ".", "length", "=", "fn", ".", "length", ";", "this", ".", "name", "=", "name", ";", "this", ".", "fn", "=", "fn", ";", "}" ]
Representation of a single middleware layer. @constructor @param {String} name Identification of the middleware. @param {Function} fn Middleware function. @param {Mixed} context Execution context of the function. @api private
[ "Representation", "of", "a", "single", "middleware", "layer", "." ]
e2d792af0c130ec937829a26b3dc58cb8a4bc534
https://github.com/bigpipe/supply/blob/e2d792af0c130ec937829a26b3dc58cb8a4bc534/index.js#L15-L19
train
bigpipe/supply
index.js
Supply
function Supply(provider, options) { if (!this) return new Supply(provider, options); options = options || {}; this.provider = provider || this; this.layers = []; this.length = 0; if ('function' === typeof this.initialize) { this.initialize(options); } }
javascript
function Supply(provider, options) { if (!this) return new Supply(provider, options); options = options || {}; this.provider = provider || this; this.layers = []; this.length = 0; if ('function' === typeof this.initialize) { this.initialize(options); } }
[ "function", "Supply", "(", "provider", ",", "options", ")", "{", "if", "(", "!", "this", ")", "return", "new", "Supply", "(", "provider", ",", "options", ")", ";", "options", "=", "options", "||", "{", "}", ";", "this", ".", "provider", "=", "provider", "||", "this", ";", "this", ".", "layers", "=", "[", "]", ";", "this", ".", "length", "=", "0", ";", "if", "(", "'function'", "===", "typeof", "this", ".", "initialize", ")", "{", "this", ".", "initialize", "(", "options", ")", ";", "}", "}" ]
A minimal middleware layer system. @constructor @param {EventEmitter} provider EventEmitter instance. @param {Object} options Optional options. @api public
[ "A", "minimal", "middleware", "layer", "system", "." ]
e2d792af0c130ec937829a26b3dc58cb8a4bc534
https://github.com/bigpipe/supply/blob/e2d792af0c130ec937829a26b3dc58cb8a4bc534/index.js#L29-L41
train
bigpipe/supply
index.js
next
function next(err, done) { var layer = supply.layers[i++]; if (err || done || !layer) { return fn(err, !!done); } if (layer.length > length) { return layer.fn.apply(supply.provider, args.concat(next)); } else { dollars.catch(function catching() { return layer.fn.apply(supply.provider, args); }, next); } }
javascript
function next(err, done) { var layer = supply.layers[i++]; if (err || done || !layer) { return fn(err, !!done); } if (layer.length > length) { return layer.fn.apply(supply.provider, args.concat(next)); } else { dollars.catch(function catching() { return layer.fn.apply(supply.provider, args); }, next); } }
[ "function", "next", "(", "err", ",", "done", ")", "{", "var", "layer", "=", "supply", ".", "layers", "[", "i", "++", "]", ";", "if", "(", "err", "||", "done", "||", "!", "layer", ")", "{", "return", "fn", "(", "err", ",", "!", "!", "done", ")", ";", "}", "if", "(", "layer", ".", "length", ">", "length", ")", "{", "return", "layer", ".", "fn", ".", "apply", "(", "supply", ".", "provider", ",", "args", ".", "concat", "(", "next", ")", ")", ";", "}", "else", "{", "dollars", ".", "catch", "(", "function", "catching", "(", ")", "{", "return", "layer", ".", "fn", ".", "apply", "(", "supply", ".", "provider", ",", "args", ")", ";", "}", ",", "next", ")", ";", "}", "}" ]
Simple middleware layer iterator. @param {Error} err A failed middleware iteration. @param {Boolean} done Stop iterating the layers as we are done. @api private
[ "Simple", "middleware", "layer", "iterator", "." ]
e2d792af0c130ec937829a26b3dc58cb8a4bc534
https://github.com/bigpipe/supply/blob/e2d792af0c130ec937829a26b3dc58cb8a4bc534/index.js#L168-L182
train
craterdog-bali/js-bali-component-framework
src/elements/Angle.js
Angle
function Angle(value, parameters) { abstractions.Element.call(this, utilities.types.ANGLE, parameters); // analyze the value if (value === undefined) value = 0; // default value if (!isFinite(value)) { throw new utilities.Exception({ $module: '/bali/elements/Angle', $procedure: '$Angle', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid angle value was passed to the constructor."' }); } if (parameters) { const units = parameters.getParameter('$units'); if (units && units.toString() === '$degrees') { // convert degrees to radians value = utilities.precision.quotient(utilities.precision.product(value, Math.PI), 180); } } // lock onto pi if appropriate value = utilities.precision.lockOnAngle(value); // normalize the value to the range (-pi..pi] const twoPi = utilities.precision.product(Math.PI, 2); if (value < -twoPi || value > twoPi) { value = utilities.precision.remainder(value, twoPi); // make in the range (-2pi..2pi) } if (value > Math.PI) { value = utilities.precision.difference(value, twoPi); // make in the range (-pi..pi] } else if (value <= -Math.PI) { value = utilities.precision.sum(value, twoPi); // make in the range (-pi..pi] } if (value === -0) value = 0; // normalize to positive zero // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Angle(value, parameters) { abstractions.Element.call(this, utilities.types.ANGLE, parameters); // analyze the value if (value === undefined) value = 0; // default value if (!isFinite(value)) { throw new utilities.Exception({ $module: '/bali/elements/Angle', $procedure: '$Angle', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid angle value was passed to the constructor."' }); } if (parameters) { const units = parameters.getParameter('$units'); if (units && units.toString() === '$degrees') { // convert degrees to radians value = utilities.precision.quotient(utilities.precision.product(value, Math.PI), 180); } } // lock onto pi if appropriate value = utilities.precision.lockOnAngle(value); // normalize the value to the range (-pi..pi] const twoPi = utilities.precision.product(Math.PI, 2); if (value < -twoPi || value > twoPi) { value = utilities.precision.remainder(value, twoPi); // make in the range (-2pi..2pi) } if (value > Math.PI) { value = utilities.precision.difference(value, twoPi); // make in the range (-pi..pi] } else if (value <= -Math.PI) { value = utilities.precision.sum(value, twoPi); // make in the range (-pi..pi] } if (value === -0) value = 0; // normalize to positive zero // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Angle", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "ANGLE", ",", "parameters", ")", ";", "if", "(", "value", "===", "undefined", ")", "value", "=", "0", ";", "if", "(", "!", "isFinite", "(", "value", ")", ")", "{", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/elements/Angle'", ",", "$procedure", ":", "'$Angle'", ",", "$exception", ":", "'$invalidParameter'", ",", "$parameter", ":", "value", ".", "toString", "(", ")", ",", "$text", ":", "'\"An invalid angle value was passed to the constructor.\"'", "}", ")", ";", "}", "if", "(", "parameters", ")", "{", "const", "units", "=", "parameters", ".", "getParameter", "(", "'$units'", ")", ";", "if", "(", "units", "&&", "units", ".", "toString", "(", ")", "===", "'$degrees'", ")", "{", "value", "=", "utilities", ".", "precision", ".", "quotient", "(", "utilities", ".", "precision", ".", "product", "(", "value", ",", "Math", ".", "PI", ")", ",", "180", ")", ";", "}", "}", "value", "=", "utilities", ".", "precision", ".", "lockOnAngle", "(", "value", ")", ";", "const", "twoPi", "=", "utilities", ".", "precision", ".", "product", "(", "Math", ".", "PI", ",", "2", ")", ";", "if", "(", "value", "<", "-", "twoPi", "||", "value", ">", "twoPi", ")", "{", "value", "=", "utilities", ".", "precision", ".", "remainder", "(", "value", ",", "twoPi", ")", ";", "}", "if", "(", "value", ">", "Math", ".", "PI", ")", "{", "value", "=", "utilities", ".", "precision", ".", "difference", "(", "value", ",", "twoPi", ")", ";", "}", "else", "if", "(", "value", "<=", "-", "Math", ".", "PI", ")", "{", "value", "=", "utilities", ".", "precision", ".", "sum", "(", "value", ",", "twoPi", ")", ";", "}", "if", "(", "value", "===", "-", "0", ")", "value", "=", "0", ";", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates an immutable instance of an angle using the specified value. @constructor @param {Number} value The value of the angle. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Angle} The new angle element.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "an", "immutable", "instance", "of", "an", "angle", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Angle.js#L30-L71
train
lyveminds/scamandrios
examples/bench_helenus.js
bench
function bench(callback){ conn.connect(function(err, keyspace){ if(err){ throw(err); } console.time('Helenus ' + times + ' writes'); function cb(err, results){ if(err){ console.log('Error encountered at: ' + completed); throw(err); } completed += 1; if(completed === times){ console.timeEnd('Helenus ' + times + ' writes') ; conn.close(); callback(); } } /** * lets run a test for writes */ for(; i < times; i += 1){ vals = ['Column'+i, i.toString(16), (i % 100).toString(16)]; conn.cql(cqlInsert, vals, { gzip:true }, cb); } }); }
javascript
function bench(callback){ conn.connect(function(err, keyspace){ if(err){ throw(err); } console.time('Helenus ' + times + ' writes'); function cb(err, results){ if(err){ console.log('Error encountered at: ' + completed); throw(err); } completed += 1; if(completed === times){ console.timeEnd('Helenus ' + times + ' writes') ; conn.close(); callback(); } } /** * lets run a test for writes */ for(; i < times; i += 1){ vals = ['Column'+i, i.toString(16), (i % 100).toString(16)]; conn.cql(cqlInsert, vals, { gzip:true }, cb); } }); }
[ "function", "bench", "(", "callback", ")", "{", "conn", ".", "connect", "(", "function", "(", "err", ",", "keyspace", ")", "{", "if", "(", "err", ")", "{", "throw", "(", "err", ")", ";", "}", "console", ".", "time", "(", "'Helenus '", "+", "times", "+", "' writes'", ")", ";", "function", "cb", "(", "err", ",", "results", ")", "{", "if", "(", "err", ")", "{", "console", ".", "log", "(", "'Error encountered at: '", "+", "completed", ")", ";", "throw", "(", "err", ")", ";", "}", "completed", "+=", "1", ";", "if", "(", "completed", "===", "times", ")", "{", "console", ".", "timeEnd", "(", "'Helenus '", "+", "times", "+", "' writes'", ")", ";", "conn", ".", "close", "(", ")", ";", "callback", "(", ")", ";", "}", "}", "for", "(", ";", "i", "<", "times", ";", "i", "+=", "1", ")", "{", "vals", "=", "[", "'Column'", "+", "i", ",", "i", ".", "toString", "(", "16", ")", ",", "(", "i", "%", "100", ")", ".", "toString", "(", "16", ")", "]", ";", "conn", ".", "cql", "(", "cqlInsert", ",", "vals", ",", "{", "gzip", ":", "true", "}", ",", "cb", ")", ";", "}", "}", ")", ";", "}" ]
First bench helenus
[ "First", "bench", "helenus" ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/examples/bench_helenus.js#L24-L54
train
craterdog-bali/js-bali-component-framework
src/elements/Pattern.js
Pattern
function Pattern(value, parameters) { abstractions.Element.call(this, utilities.types.PATTERN, parameters); value = value || '^none$'; // the default value matches nothing if (typeof value === 'string') value = new RegExp(value); // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Pattern(value, parameters) { abstractions.Element.call(this, utilities.types.PATTERN, parameters); value = value || '^none$'; // the default value matches nothing if (typeof value === 'string') value = new RegExp(value); // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Pattern", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "PATTERN", ",", "parameters", ")", ";", "value", "=", "value", "||", "'^none$'", ";", "if", "(", "typeof", "value", "===", "'string'", ")", "value", "=", "new", "RegExp", "(", "value", ")", ";", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new pattern element using the specified value. @constructor @param {String|RegExp} value A regular expression for the pattern element. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Pattern} The new pattern element.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "pattern", "element", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Pattern.js#L29-L38
train
unshiftio/demolish
index.js
run
function run(key, selfie) { if (!options[key]) return; if ('string' === typeof options[key]) options[key] = options[key].split(split); if ('function' === typeof options[key]) return options[key].call(selfie); for (var i = 0, type, what; i < options[key].length; i++) { what = options[key][i]; type = typeof what; if ('function' === type) { what.call(selfie); } else if ('string' === type && 'function' === typeof selfie[what]) { selfie[what](); } } }
javascript
function run(key, selfie) { if (!options[key]) return; if ('string' === typeof options[key]) options[key] = options[key].split(split); if ('function' === typeof options[key]) return options[key].call(selfie); for (var i = 0, type, what; i < options[key].length; i++) { what = options[key][i]; type = typeof what; if ('function' === type) { what.call(selfie); } else if ('string' === type && 'function' === typeof selfie[what]) { selfie[what](); } } }
[ "function", "run", "(", "key", ",", "selfie", ")", "{", "if", "(", "!", "options", "[", "key", "]", ")", "return", ";", "if", "(", "'string'", "===", "typeof", "options", "[", "key", "]", ")", "options", "[", "key", "]", "=", "options", "[", "key", "]", ".", "split", "(", "split", ")", ";", "if", "(", "'function'", "===", "typeof", "options", "[", "key", "]", ")", "return", "options", "[", "key", "]", ".", "call", "(", "selfie", ")", ";", "for", "(", "var", "i", "=", "0", ",", "type", ",", "what", ";", "i", "<", "options", "[", "key", "]", ".", "length", ";", "i", "++", ")", "{", "what", "=", "options", "[", "key", "]", "[", "i", "]", ";", "type", "=", "typeof", "what", ";", "if", "(", "'function'", "===", "type", ")", "{", "what", ".", "call", "(", "selfie", ")", ";", "}", "else", "if", "(", "'string'", "===", "type", "&&", "'function'", "===", "typeof", "selfie", "[", "what", "]", ")", "{", "selfie", "[", "what", "]", "(", ")", ";", "}", "}", "}" ]
Run addition cleanup hooks. @param {String} key Name of the clean up hook to run. @param {Mixed} selfie Reference to the instance we're cleaning up. @api private
[ "Run", "addition", "cleanup", "hooks", "." ]
c438fa2c755c35c910b610c51d8c1aeba5bc5ce3
https://github.com/unshiftio/demolish/blob/c438fa2c755c35c910b610c51d8c1aeba5bc5ce3/index.js#L26-L41
train
craterdog-bali/js-bali-component-framework
src/composites/Association.js
Association
function Association(key, value) { abstractions.Composite.call(this, utilities.types.ASSOCIATION); key = this.convert(key); value = this.convert(value); // access to this component's attributes is tightly controlled this.getKey = function() { return key; }; this.getValue = function() { return value; }; this.setValue = function(newValue) { newValue = this.convert(newValue); const oldValue = value; value = newValue; return oldValue; }; return this; }
javascript
function Association(key, value) { abstractions.Composite.call(this, utilities.types.ASSOCIATION); key = this.convert(key); value = this.convert(value); // access to this component's attributes is tightly controlled this.getKey = function() { return key; }; this.getValue = function() { return value; }; this.setValue = function(newValue) { newValue = this.convert(newValue); const oldValue = value; value = newValue; return oldValue; }; return this; }
[ "function", "Association", "(", "key", ",", "value", ")", "{", "abstractions", ".", "Composite", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "ASSOCIATION", ")", ";", "key", "=", "this", ".", "convert", "(", "key", ")", ";", "value", "=", "this", ".", "convert", "(", "value", ")", ";", "this", ".", "getKey", "=", "function", "(", ")", "{", "return", "key", ";", "}", ";", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "this", ".", "setValue", "=", "function", "(", "newValue", ")", "{", "newValue", "=", "this", ".", "convert", "(", "newValue", ")", ";", "const", "oldValue", "=", "value", ";", "value", "=", "newValue", ";", "return", "oldValue", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC FUNCTIONS This constructor creates a new key-value association. @param {String|Number|Boolean|Component} key The key of the association. @param {String|Number|Boolean|Component} value The value associated with the key. @returns {Association} A new association.
[ "PUBLIC", "FUNCTIONS", "This", "constructor", "creates", "a", "new", "key", "-", "value", "association", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/composites/Association.js#L29-L45
train
taskcluster/taskcluster-lib-testing
src/pulse.js
function(credentials, mocha) { var that = this; this._connection = new taskcluster.PulseConnection(credentials); this._listeners = null; this._promisedMessages = null; // **Note**, the before(), beforeEach(9, afterEach() and after() functions // below are mocha hooks. Ie. they are called by mocha, that is also the // reason that `PulseTestReceiver` only works in the context of a mocha test. if (!mocha) { mocha = require('mocha'); } // Before all tests we ask the pulseConnection to connect, why not it offers // slightly better performance, and we want tests to run fast mocha.before(function() { return that._connection.connect(); }); // Before each test we create list of listeners and mapping from "name" to // promised messages mocha.beforeEach(function() { that._listeners = []; that._promisedMessages = {}; }); // After each test we clean-up all the listeners created mocha.afterEach(function() { // Because listener is created with a PulseConnection they only have an // AMQP channel each, and not a full TCP connection, hence, .close() // should be pretty fast too. Also unnecessary as they get clean-up when // the PulseConnection closes eventually... But it's nice to keep things // clean, errors are more likely to surface at the right test this way. return Promise.all(that._listeners.map(function(listener) { listener.close(); })).then(function() { that._listeners = null; that._promisedMessages = null; }); }); // After all tests we close the PulseConnection, as we haven't named any of // the queues, they are all auto-delete queues and will be deleted if they // weren't cleaned up in `afterEach()` mocha.after(function() { return that._connection.close().then(function() { that._connection = null; }); }); }
javascript
function(credentials, mocha) { var that = this; this._connection = new taskcluster.PulseConnection(credentials); this._listeners = null; this._promisedMessages = null; // **Note**, the before(), beforeEach(9, afterEach() and after() functions // below are mocha hooks. Ie. they are called by mocha, that is also the // reason that `PulseTestReceiver` only works in the context of a mocha test. if (!mocha) { mocha = require('mocha'); } // Before all tests we ask the pulseConnection to connect, why not it offers // slightly better performance, and we want tests to run fast mocha.before(function() { return that._connection.connect(); }); // Before each test we create list of listeners and mapping from "name" to // promised messages mocha.beforeEach(function() { that._listeners = []; that._promisedMessages = {}; }); // After each test we clean-up all the listeners created mocha.afterEach(function() { // Because listener is created with a PulseConnection they only have an // AMQP channel each, and not a full TCP connection, hence, .close() // should be pretty fast too. Also unnecessary as they get clean-up when // the PulseConnection closes eventually... But it's nice to keep things // clean, errors are more likely to surface at the right test this way. return Promise.all(that._listeners.map(function(listener) { listener.close(); })).then(function() { that._listeners = null; that._promisedMessages = null; }); }); // After all tests we close the PulseConnection, as we haven't named any of // the queues, they are all auto-delete queues and will be deleted if they // weren't cleaned up in `afterEach()` mocha.after(function() { return that._connection.close().then(function() { that._connection = null; }); }); }
[ "function", "(", "credentials", ",", "mocha", ")", "{", "var", "that", "=", "this", ";", "this", ".", "_connection", "=", "new", "taskcluster", ".", "PulseConnection", "(", "credentials", ")", ";", "this", ".", "_listeners", "=", "null", ";", "this", ".", "_promisedMessages", "=", "null", ";", "if", "(", "!", "mocha", ")", "{", "mocha", "=", "require", "(", "'mocha'", ")", ";", "}", "mocha", ".", "before", "(", "function", "(", ")", "{", "return", "that", ".", "_connection", ".", "connect", "(", ")", ";", "}", ")", ";", "mocha", ".", "beforeEach", "(", "function", "(", ")", "{", "that", ".", "_listeners", "=", "[", "]", ";", "that", ".", "_promisedMessages", "=", "{", "}", ";", "}", ")", ";", "mocha", ".", "afterEach", "(", "function", "(", ")", "{", "return", "Promise", ".", "all", "(", "that", ".", "_listeners", ".", "map", "(", "function", "(", "listener", ")", "{", "listener", ".", "close", "(", ")", ";", "}", ")", ")", ".", "then", "(", "function", "(", ")", "{", "that", ".", "_listeners", "=", "null", ";", "that", ".", "_promisedMessages", "=", "null", ";", "}", ")", ";", "}", ")", ";", "mocha", ".", "after", "(", "function", "(", ")", "{", "return", "that", ".", "_connection", ".", "close", "(", ")", ".", "then", "(", "function", "(", ")", "{", "that", ".", "_connection", "=", "null", ";", "}", ")", ";", "}", ")", ";", "}" ]
A utility for test written in mocha, that makes very easy to listen for a specific message. credentials: { username: '...', // Pulse username password: '...' // Pulse password }
[ "A", "utility", "for", "test", "written", "in", "mocha", "that", "makes", "very", "easy", "to", "listen", "for", "a", "specific", "message", "." ]
ee2a3193f98edab0b5297eb1beeeea45a9706ca1
https://github.com/taskcluster/taskcluster-lib-testing/blob/ee2a3193f98edab0b5297eb1beeeea45a9706ca1/src/pulse.js#L16-L65
train
D780/valparams
lib/validators.js
vNumber
function vNumber(func, type, str, range) { let success = true; let checkType = true; let errmsg; // 先验证类型 if (!func(str)) { errmsg = localData.em_type({ desc, str, type, }); checkType = false; success = false; } // 再验证类型范围 // if (range && range.min === undefined) { // range.min = 0; // } if (range && (range.min === undefined || range.min < -NUMBER_MAX)) { range.min = -NUMBER_MAX; } if (range && (range.max === undefined || range.max > NUMBER_MAX)) { range.max = NUMBER_MAX; } if (success && checkType && range && (range.min !== undefined || range.max !== undefined)) { if (range && range.min !== undefined && range.min > Number(str)) { success = false; } if (success && range && range.max !== undefined && range.max < Number(str)) { success = false; } if (!success) { errmsg = localData.em_minmax({ desc, type, opDesc: 'value', minOp : '>=', min : range.min, maxOp : '<=', max : range.max, }); } } return { success, errmsg }; }
javascript
function vNumber(func, type, str, range) { let success = true; let checkType = true; let errmsg; // 先验证类型 if (!func(str)) { errmsg = localData.em_type({ desc, str, type, }); checkType = false; success = false; } // 再验证类型范围 // if (range && range.min === undefined) { // range.min = 0; // } if (range && (range.min === undefined || range.min < -NUMBER_MAX)) { range.min = -NUMBER_MAX; } if (range && (range.max === undefined || range.max > NUMBER_MAX)) { range.max = NUMBER_MAX; } if (success && checkType && range && (range.min !== undefined || range.max !== undefined)) { if (range && range.min !== undefined && range.min > Number(str)) { success = false; } if (success && range && range.max !== undefined && range.max < Number(str)) { success = false; } if (!success) { errmsg = localData.em_minmax({ desc, type, opDesc: 'value', minOp : '>=', min : range.min, maxOp : '<=', max : range.max, }); } } return { success, errmsg }; }
[ "function", "vNumber", "(", "func", ",", "type", ",", "str", ",", "range", ")", "{", "let", "success", "=", "true", ";", "let", "checkType", "=", "true", ";", "let", "errmsg", ";", "if", "(", "!", "func", "(", "str", ")", ")", "{", "errmsg", "=", "localData", ".", "em_type", "(", "{", "desc", ",", "str", ",", "type", ",", "}", ")", ";", "checkType", "=", "false", ";", "success", "=", "false", ";", "}", "if", "(", "range", "&&", "(", "range", ".", "min", "===", "undefined", "||", "range", ".", "min", "<", "-", "NUMBER_MAX", ")", ")", "{", "range", ".", "min", "=", "-", "NUMBER_MAX", ";", "}", "if", "(", "range", "&&", "(", "range", ".", "max", "===", "undefined", "||", "range", ".", "max", ">", "NUMBER_MAX", ")", ")", "{", "range", ".", "max", "=", "NUMBER_MAX", ";", "}", "if", "(", "success", "&&", "checkType", "&&", "range", "&&", "(", "range", ".", "min", "!==", "undefined", "||", "range", ".", "max", "!==", "undefined", ")", ")", "{", "if", "(", "range", "&&", "range", ".", "min", "!==", "undefined", "&&", "range", ".", "min", ">", "Number", "(", "str", ")", ")", "{", "success", "=", "false", ";", "}", "if", "(", "success", "&&", "range", "&&", "range", ".", "max", "!==", "undefined", "&&", "range", ".", "max", "<", "Number", "(", "str", ")", ")", "{", "success", "=", "false", ";", "}", "if", "(", "!", "success", ")", "{", "errmsg", "=", "localData", ".", "em_minmax", "(", "{", "desc", ",", "type", ",", "opDesc", ":", "'value'", ",", "minOp", ":", "'>='", ",", "min", ":", "range", ".", "min", ",", "maxOp", ":", "'<='", ",", "max", ":", "range", ".", "max", ",", "}", ")", ";", "}", "}", "return", "{", "success", ",", "errmsg", "}", ";", "}" ]
func to validator number @param {Function} func = {v.isInt,v.isFloat,v.isNumeric} @param {String} type = {int,float,number} @param {String} str @param {Object} range @returns {boolean} /* eslint-disable no-shadow
[ "func", "to", "validator", "number" ]
4877a15a41589b1023ea7dd047b27c966b6545e7
https://github.com/D780/valparams/blob/4877a15a41589b1023ea7dd047b27c966b6545e7/lib/validators.js#L357-L401
train
craterdog-bali/js-bali-component-framework
src/elements/Percent.js
Percent
function Percent(value, parameters) { abstractions.Element.call(this, utilities.types.PERCENT, parameters); value = value || 0; // the default value // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Percent(value, parameters) { abstractions.Element.call(this, utilities.types.PERCENT, parameters); value = value || 0; // the default value // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Percent", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "PERCENT", ",", "parameters", ")", ";", "value", "=", "value", "||", "0", ";", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new percent element using the specified value. @param {Number} value The value of the percent. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Percent} The new percent element.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "percent", "element", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Percent.js#L29-L37
train
lyveminds/scamandrios
lib/column.js
function(name, value, timestamp, ttl){ /** * The name of the column, can be any type, for composites use Array */ this.name = name; /** * The value of the column */ this.value = value; /** * The timestamp of the value * @default {Date} new Date(); */ this.timestamp = timestamp || new Date(); /** * The ttl for the column */ this.ttl = ttl; }
javascript
function(name, value, timestamp, ttl){ /** * The name of the column, can be any type, for composites use Array */ this.name = name; /** * The value of the column */ this.value = value; /** * The timestamp of the value * @default {Date} new Date(); */ this.timestamp = timestamp || new Date(); /** * The ttl for the column */ this.ttl = ttl; }
[ "function", "(", "name", ",", "value", ",", "timestamp", ",", "ttl", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "value", "=", "value", ";", "this", ".", "timestamp", "=", "timestamp", "||", "new", "Date", "(", ")", ";", "this", ".", "ttl", "=", "ttl", ";", "}" ]
Cassandra Column object representation @param {Object} name The name of the column, can be any type, for composites use Array @param {Object} value The value of the column @param {Date} timestamp The timestamp of the value @param {Number} ttl The ttl for the column @constructor
[ "Cassandra", "Column", "object", "representation" ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/lib/column.js#L12-L33
train
Runnable/hermes
lib/assert-opts.js
function (queueDef) { if (isString(queueDef)) { return true } if (isObject(queueDef) && isString(queueDef.name)) { return true } return false }
javascript
function (queueDef) { if (isString(queueDef)) { return true } if (isObject(queueDef) && isString(queueDef.name)) { return true } return false }
[ "function", "(", "queueDef", ")", "{", "if", "(", "isString", "(", "queueDef", ")", ")", "{", "return", "true", "}", "if", "(", "isObject", "(", "queueDef", ")", "&&", "isString", "(", "queueDef", ".", "name", ")", ")", "{", "return", "true", "}", "return", "false", "}" ]
Check if queueDef is string or definition object with `name` prop
[ "Check", "if", "queueDef", "is", "string", "or", "definition", "object", "with", "name", "prop" ]
af660962b3bc67ed39811e17a4362a725442ff81
https://github.com/Runnable/hermes/blob/af660962b3bc67ed39811e17a4362a725442ff81/lib/assert-opts.js#L14-L22
train
Runnable/hermes
lib/assert-opts.js
function (queues, name) { var result = queues.filter(function (queue) { return queue.name === name }) return result.length > 0 }
javascript
function (queues, name) { var result = queues.filter(function (queue) { return queue.name === name }) return result.length > 0 }
[ "function", "(", "queues", ",", "name", ")", "{", "var", "result", "=", "queues", ".", "filter", "(", "function", "(", "queue", ")", "{", "return", "queue", ".", "name", "===", "name", "}", ")", "return", "result", ".", "length", ">", "0", "}" ]
Check if queue with provided `name` exists in the array of queueDefs @param {Array} array of nromalized queueDefs @param {String} queueName to check for existence @param {Array} array of mixed queueNames or queueDefs @return {Boolean} true if queue with `name` exists in the array of queueDefs
[ "Check", "if", "queue", "with", "provided", "name", "exists", "in", "the", "array", "of", "queueDefs" ]
af660962b3bc67ed39811e17a4362a725442ff81
https://github.com/Runnable/hermes/blob/af660962b3bc67ed39811e17a4362a725442ff81/lib/assert-opts.js#L31-L36
train
craterdog-bali/js-bali-component-framework
src/utilities/Codex.js
formatLines
function formatLines(string, indentation) { indentation = indentation ? indentation : ''; var formatted = ''; const length = string.length; if (length > LINE_WIDTH) { for (var index = 0; index < length; index += LINE_WIDTH) { formatted += EOL + indentation; formatted += string.substring(index, index + LINE_WIDTH); } formatted += EOL; } else { formatted += string; } return formatted; }
javascript
function formatLines(string, indentation) { indentation = indentation ? indentation : ''; var formatted = ''; const length = string.length; if (length > LINE_WIDTH) { for (var index = 0; index < length; index += LINE_WIDTH) { formatted += EOL + indentation; formatted += string.substring(index, index + LINE_WIDTH); } formatted += EOL; } else { formatted += string; } return formatted; }
[ "function", "formatLines", "(", "string", ",", "indentation", ")", "{", "indentation", "=", "indentation", "?", "indentation", ":", "''", ";", "var", "formatted", "=", "''", ";", "const", "length", "=", "string", ".", "length", ";", "if", "(", "length", ">", "LINE_WIDTH", ")", "{", "for", "(", "var", "index", "=", "0", ";", "index", "<", "length", ";", "index", "+=", "LINE_WIDTH", ")", "{", "formatted", "+=", "EOL", "+", "indentation", ";", "formatted", "+=", "string", ".", "substring", "(", "index", ",", "index", "+", "LINE_WIDTH", ")", ";", "}", "formatted", "+=", "EOL", ";", "}", "else", "{", "formatted", "+=", "string", ";", "}", "return", "formatted", ";", "}" ]
This function returns a formatted version of a string with LINE_WIDTH characters per line. @param {String} string The string to be formatted. @param {String} indentation The string to be prepended to each line of the result. @returns {String} The formatted string.
[ "This", "function", "returns", "a", "formatted", "version", "of", "a", "string", "with", "LINE_WIDTH", "characters", "per", "line", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/utilities/Codex.js#L554-L568
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/promise-debug.js
function (progressListener) { var self = this, listeners = self[PROMISE_PROGRESS_LISTENERS]; if (listeners === false) { return self; } if (!listeners) { listeners = self[PROMISE_PROGRESS_LISTENERS] = []; } listeners.push(progressListener); return self; }
javascript
function (progressListener) { var self = this, listeners = self[PROMISE_PROGRESS_LISTENERS]; if (listeners === false) { return self; } if (!listeners) { listeners = self[PROMISE_PROGRESS_LISTENERS] = []; } listeners.push(progressListener); return self; }
[ "function", "(", "progressListener", ")", "{", "var", "self", "=", "this", ",", "listeners", "=", "self", "[", "PROMISE_PROGRESS_LISTENERS", "]", ";", "if", "(", "listeners", "===", "false", ")", "{", "return", "self", ";", "}", "if", "(", "!", "listeners", ")", "{", "listeners", "=", "self", "[", "PROMISE_PROGRESS_LISTENERS", "]", "=", "[", "]", ";", "}", "listeners", ".", "push", "(", "progressListener", ")", ";", "return", "self", ";", "}" ]
call progress listener when defer.notify is called @param {Function} [progressListener] progress listener
[ "call", "progress", "listener", "when", "defer", ".", "notify", "is", "called" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/promise-debug.js#L195-L205
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/promise-debug.js
function (callback) { return when(this, function (value) { return callback(value, true); }, function (reason) { return callback(reason, false); }); }
javascript
function (callback) { return when(this, function (value) { return callback(value, true); }, function (reason) { return callback(reason, false); }); }
[ "function", "(", "callback", ")", "{", "return", "when", "(", "this", ",", "function", "(", "value", ")", "{", "return", "callback", "(", "value", ",", "true", ")", ";", "}", ",", "function", "(", "reason", ")", "{", "return", "callback", "(", "reason", ",", "false", ")", ";", "}", ")", ";", "}" ]
call callback when this promise object is rejected or resolved @param {Function} callback the second parameter is true when resolved and false when rejected @@return {KISSY.Promise} a new promise object
[ "call", "callback", "when", "this", "promise", "object", "is", "rejected", "or", "resolved" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/promise-debug.js#L220-L226
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/promise-debug.js
when
function when(value, fulfilled, rejected) { var defer = new Defer(), done = 0; // wrap user's callback to catch exception // wrap user's callback to catch exception function _fulfilled(value) { try { return fulfilled ? fulfilled.call(this, value) : // propagate value; } catch (e) { // can not use logger.error // must expose to user // print stack info for firefox/chrome logError(e.stack || e); return new Reject(e); } } function _rejected(reason) { try { return rejected ? // error recovery rejected.call(this, reason) : // propagate new Reject(reason); } catch (e) { // print stack info for firefox/chrome logError(e.stack || e); return new Reject(e); } } function finalFulfill(value) { if (done) { logger.error('already done at fulfilled'); return; } if (value instanceof Promise) { logger.error('assert.not(value instanceof Promise) in when'); return; } done = 1; defer.resolve(_fulfilled.call(this, value)); } if (value instanceof Promise) { promiseWhen(value, finalFulfill, function (reason) { if (done) { logger.error('already done at rejected'); return; } done = 1; // _reject may return non-Reject object for error recovery // _reject may return non-Reject object for error recovery defer.resolve(_rejected.call(this, reason)); }); } else { finalFulfill(value); } // chained and leveled // wait for value's resolve // chained and leveled // wait for value's resolve return defer.promise; }
javascript
function when(value, fulfilled, rejected) { var defer = new Defer(), done = 0; // wrap user's callback to catch exception // wrap user's callback to catch exception function _fulfilled(value) { try { return fulfilled ? fulfilled.call(this, value) : // propagate value; } catch (e) { // can not use logger.error // must expose to user // print stack info for firefox/chrome logError(e.stack || e); return new Reject(e); } } function _rejected(reason) { try { return rejected ? // error recovery rejected.call(this, reason) : // propagate new Reject(reason); } catch (e) { // print stack info for firefox/chrome logError(e.stack || e); return new Reject(e); } } function finalFulfill(value) { if (done) { logger.error('already done at fulfilled'); return; } if (value instanceof Promise) { logger.error('assert.not(value instanceof Promise) in when'); return; } done = 1; defer.resolve(_fulfilled.call(this, value)); } if (value instanceof Promise) { promiseWhen(value, finalFulfill, function (reason) { if (done) { logger.error('already done at rejected'); return; } done = 1; // _reject may return non-Reject object for error recovery // _reject may return non-Reject object for error recovery defer.resolve(_rejected.call(this, reason)); }); } else { finalFulfill(value); } // chained and leveled // wait for value's resolve // chained and leveled // wait for value's resolve return defer.promise; }
[ "function", "when", "(", "value", ",", "fulfilled", ",", "rejected", ")", "{", "var", "defer", "=", "new", "Defer", "(", ")", ",", "done", "=", "0", ";", "function", "_fulfilled", "(", "value", ")", "{", "try", "{", "return", "fulfilled", "?", "fulfilled", ".", "call", "(", "this", ",", "value", ")", ":", "value", ";", "}", "catch", "(", "e", ")", "{", "logError", "(", "e", ".", "stack", "||", "e", ")", ";", "return", "new", "Reject", "(", "e", ")", ";", "}", "}", "function", "_rejected", "(", "reason", ")", "{", "try", "{", "return", "rejected", "?", "rejected", ".", "call", "(", "this", ",", "reason", ")", ":", "new", "Reject", "(", "reason", ")", ";", "}", "catch", "(", "e", ")", "{", "logError", "(", "e", ".", "stack", "||", "e", ")", ";", "return", "new", "Reject", "(", "e", ")", ";", "}", "}", "function", "finalFulfill", "(", "value", ")", "{", "if", "(", "done", ")", "{", "logger", ".", "error", "(", "'already done at fulfilled'", ")", ";", "return", ";", "}", "if", "(", "value", "instanceof", "Promise", ")", "{", "logger", ".", "error", "(", "'assert.not(value instanceof Promise) in when'", ")", ";", "return", ";", "}", "done", "=", "1", ";", "defer", ".", "resolve", "(", "_fulfilled", ".", "call", "(", "this", ",", "value", ")", ")", ";", "}", "if", "(", "value", "instanceof", "Promise", ")", "{", "promiseWhen", "(", "value", ",", "finalFulfill", ",", "function", "(", "reason", ")", "{", "if", "(", "done", ")", "{", "logger", ".", "error", "(", "'already done at rejected'", ")", ";", "return", ";", "}", "done", "=", "1", ";", "defer", ".", "resolve", "(", "_rejected", ".", "call", "(", "this", ",", "reason", ")", ")", ";", "}", ")", ";", "}", "else", "{", "finalFulfill", "(", "value", ")", ";", "}", "return", "defer", ".", "promise", ";", "}" ]
wrap for promiseWhen wrap for promiseWhen
[ "wrap", "for", "promiseWhen", "wrap", "for", "promiseWhen" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/promise-debug.js#L303-L358
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/promise-debug.js
_fulfilled
function _fulfilled(value) { try { return fulfilled ? fulfilled.call(this, value) : // propagate value; } catch (e) { // can not use logger.error // must expose to user // print stack info for firefox/chrome logError(e.stack || e); return new Reject(e); } }
javascript
function _fulfilled(value) { try { return fulfilled ? fulfilled.call(this, value) : // propagate value; } catch (e) { // can not use logger.error // must expose to user // print stack info for firefox/chrome logError(e.stack || e); return new Reject(e); } }
[ "function", "_fulfilled", "(", "value", ")", "{", "try", "{", "return", "fulfilled", "?", "fulfilled", ".", "call", "(", "this", ",", "value", ")", ":", "value", ";", "}", "catch", "(", "e", ")", "{", "logError", "(", "e", ".", "stack", "||", "e", ")", ";", "return", "new", "Reject", "(", "e", ")", ";", "}", "}" ]
wrap user's callback to catch exception wrap user's callback to catch exception
[ "wrap", "user", "s", "callback", "to", "catch", "exception", "wrap", "user", "s", "callback", "to", "catch", "exception" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/promise-debug.js#L306-L317
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/promise-debug.js
function (promises) { var count = promises.length; if (!count) { return null; } var defer = new Defer(); for (var i = 0; i < promises.length; i++) { /*jshint loopfunc:true*/ (function (promise, i) { when(promise, function (value) { promises[i] = value; if (--count === 0) { // if all is resolved // then resolve final returned promise with all value defer.resolve(promises); } }, function (r) { // if any one is rejected // then reject final return promise with first reason defer.reject(r); }); }(promises[i], i)); } return defer.promise; }
javascript
function (promises) { var count = promises.length; if (!count) { return null; } var defer = new Defer(); for (var i = 0; i < promises.length; i++) { /*jshint loopfunc:true*/ (function (promise, i) { when(promise, function (value) { promises[i] = value; if (--count === 0) { // if all is resolved // then resolve final returned promise with all value defer.resolve(promises); } }, function (r) { // if any one is rejected // then reject final return promise with first reason defer.reject(r); }); }(promises[i], i)); } return defer.promise; }
[ "function", "(", "promises", ")", "{", "var", "count", "=", "promises", ".", "length", ";", "if", "(", "!", "count", ")", "{", "return", "null", ";", "}", "var", "defer", "=", "new", "Defer", "(", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "promises", ".", "length", ";", "i", "++", ")", "{", "(", "function", "(", "promise", ",", "i", ")", "{", "when", "(", "promise", ",", "function", "(", "value", ")", "{", "promises", "[", "i", "]", "=", "value", ";", "if", "(", "--", "count", "===", "0", ")", "{", "defer", ".", "resolve", "(", "promises", ")", ";", "}", "}", ",", "function", "(", "r", ")", "{", "defer", ".", "reject", "(", "r", ")", ";", "}", ")", ";", "}", "(", "promises", "[", "i", "]", ",", "i", ")", ")", ";", "}", "return", "defer", ".", "promise", ";", "}" ]
return a new promise which is resolved when all promises is resolved and rejected when any one of promises is rejected @param {KISSY.Promise[]} promises list of promises @static @return {KISSY.Promise} @member KISSY.Promise
[ "return", "a", "new", "promise", "which", "is", "resolved", "when", "all", "promises", "is", "resolved", "and", "rejected", "when", "any", "one", "of", "promises", "is", "rejected" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/promise-debug.js#L470-L494
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/promise-debug.js
function (generatorFunc) { return function () { var generator = generatorFunc.apply(this, arguments); function doAction(action, arg) { var result; // in case error on first // in case error on first try { result = generator[action](arg); } catch (e) { return new Reject(e); } if (result.done) { return result.value; } return when(result.value, next, throwEx); } function next(v) { return doAction('next', v); } function throwEx(e) { return doAction('throw', e); } return next(); }; }
javascript
function (generatorFunc) { return function () { var generator = generatorFunc.apply(this, arguments); function doAction(action, arg) { var result; // in case error on first // in case error on first try { result = generator[action](arg); } catch (e) { return new Reject(e); } if (result.done) { return result.value; } return when(result.value, next, throwEx); } function next(v) { return doAction('next', v); } function throwEx(e) { return doAction('throw', e); } return next(); }; }
[ "function", "(", "generatorFunc", ")", "{", "return", "function", "(", ")", "{", "var", "generator", "=", "generatorFunc", ".", "apply", "(", "this", ",", "arguments", ")", ";", "function", "doAction", "(", "action", ",", "arg", ")", "{", "var", "result", ";", "try", "{", "result", "=", "generator", "[", "action", "]", "(", "arg", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "new", "Reject", "(", "e", ")", ";", "}", "if", "(", "result", ".", "done", ")", "{", "return", "result", ".", "value", ";", "}", "return", "when", "(", "result", ".", "value", ",", "next", ",", "throwEx", ")", ";", "}", "function", "next", "(", "v", ")", "{", "return", "doAction", "(", "'next'", ",", "v", ")", ";", "}", "function", "throwEx", "(", "e", ")", "{", "return", "doAction", "(", "'throw'", ",", "e", ")", ";", "}", "return", "next", "(", ")", ";", "}", ";", "}" ]
provide es6 generator @param generatorFunc es6 generator function which has yielded promise
[ "provide", "es6", "generator" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/promise-debug.js#L499-L523
train
craterdog-bali/js-bali-component-framework
src/elements/Version.js
Version
function Version(value, parameters) { abstractions.Element.call(this, utilities.types.VERSION, parameters); value = value || [1]; // the default value if (value.indexOf(0) >= 0) { throw new utilities.Exception({ $module: '/bali/elements/Version', $procedure: '$Version', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid version value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Version(value, parameters) { abstractions.Element.call(this, utilities.types.VERSION, parameters); value = value || [1]; // the default value if (value.indexOf(0) >= 0) { throw new utilities.Exception({ $module: '/bali/elements/Version', $procedure: '$Version', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid version value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Version", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "VERSION", ",", "parameters", ")", ";", "value", "=", "value", "||", "[", "1", "]", ";", "if", "(", "value", ".", "indexOf", "(", "0", ")", ">=", "0", ")", "{", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/elements/Version'", ",", "$procedure", ":", "'$Version'", ",", "$exception", ":", "'$invalidParameter'", ",", "$parameter", ":", "value", ".", "toString", "(", ")", ",", "$text", ":", "'\"An invalid version value was passed to the constructor.\"'", "}", ")", ";", "}", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new version element using the specified value. @param {Array} value An array containing the version levels for the version string. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Symbol} The new version string element.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "version", "element", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Version.js#L30-L47
train
craterdog-bali/js-bali-component-framework
src/elements/Tag.js
Tag
function Tag(value, parameters) { abstractions.Element.call(this, utilities.types.TAG, parameters); value = value || 20; // the default number of bytes var bytes, numberOfBytes, hash; switch (typeof value) { case 'number': numberOfBytes = value; bytes = utilities.random.bytes(value); value = utilities.codex.base32Encode(bytes); break; case 'string': bytes = utilities.codex.base32Decode(value); numberOfBytes = bytes.length; break; } hash = utilities.codex.bytesToInteger(bytes); // the first four bytes work perfectly // since this element is immutable the attributes must be read-only this.getSize = function() { return numberOfBytes; }; this.getValue = function() { return value; }; this.getHash = function() { return hash; }; return this; }
javascript
function Tag(value, parameters) { abstractions.Element.call(this, utilities.types.TAG, parameters); value = value || 20; // the default number of bytes var bytes, numberOfBytes, hash; switch (typeof value) { case 'number': numberOfBytes = value; bytes = utilities.random.bytes(value); value = utilities.codex.base32Encode(bytes); break; case 'string': bytes = utilities.codex.base32Decode(value); numberOfBytes = bytes.length; break; } hash = utilities.codex.bytesToInteger(bytes); // the first four bytes work perfectly // since this element is immutable the attributes must be read-only this.getSize = function() { return numberOfBytes; }; this.getValue = function() { return value; }; this.getHash = function() { return hash; }; return this; }
[ "function", "Tag", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "TAG", ",", "parameters", ")", ";", "value", "=", "value", "||", "20", ";", "var", "bytes", ",", "numberOfBytes", ",", "hash", ";", "switch", "(", "typeof", "value", ")", "{", "case", "'number'", ":", "numberOfBytes", "=", "value", ";", "bytes", "=", "utilities", ".", "random", ".", "bytes", "(", "value", ")", ";", "value", "=", "utilities", ".", "codex", ".", "base32Encode", "(", "bytes", ")", ";", "break", ";", "case", "'string'", ":", "bytes", "=", "utilities", ".", "codex", ".", "base32Decode", "(", "value", ")", ";", "numberOfBytes", "=", "bytes", ".", "length", ";", "break", ";", "}", "hash", "=", "utilities", ".", "codex", ".", "bytesToInteger", "(", "bytes", ")", ";", "this", ".", "getSize", "=", "function", "(", ")", "{", "return", "numberOfBytes", ";", "}", ";", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "this", ".", "getHash", "=", "function", "(", ")", "{", "return", "hash", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new tag element using the specified value. @param {Number|String} value An optional parameter defining the size of a new random tag or the value it should represent. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Tag} The new tag element.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "tag", "element", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Tag.js#L30-L53
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/loader.js
function (msg, cat, logger) { if ('@DEBUG@') { var matched = 1; if (logger) { var list, i, l, level, minLevel, maxLevel, reg; cat = cat || 'debug'; level = loggerLevel[cat] || loggerLevel.debug; if ((list = config.includes)) { matched = 0; for (i = 0; i < list.length; i++) { l = list[i]; reg = l.logger; maxLevel = loggerLevel[l.maxLevel] || loggerLevel.error; minLevel = loggerLevel[l.minLevel] || loggerLevel.debug; if (minLevel <= level && maxLevel >= level && logger.match(reg)) { matched = 1; break; } } } else if ((list = config.excludes)) { matched = 1; for (i = 0; i < list.length; i++) { l = list[i]; reg = l.logger; maxLevel = loggerLevel[l.maxLevel] || loggerLevel.error; minLevel = loggerLevel[l.minLevel] || loggerLevel.debug; if (minLevel <= level && maxLevel >= level && logger.match(reg)) { matched = 0; break; } } } if (matched) { msg = logger + ': ' + msg; } } /*global console*/ if (matched) { if (typeof console !== 'undefined' && console.log) { console[cat && console[cat] ? cat : 'log'](msg); } return msg; } } return undefined; }
javascript
function (msg, cat, logger) { if ('@DEBUG@') { var matched = 1; if (logger) { var list, i, l, level, minLevel, maxLevel, reg; cat = cat || 'debug'; level = loggerLevel[cat] || loggerLevel.debug; if ((list = config.includes)) { matched = 0; for (i = 0; i < list.length; i++) { l = list[i]; reg = l.logger; maxLevel = loggerLevel[l.maxLevel] || loggerLevel.error; minLevel = loggerLevel[l.minLevel] || loggerLevel.debug; if (minLevel <= level && maxLevel >= level && logger.match(reg)) { matched = 1; break; } } } else if ((list = config.excludes)) { matched = 1; for (i = 0; i < list.length; i++) { l = list[i]; reg = l.logger; maxLevel = loggerLevel[l.maxLevel] || loggerLevel.error; minLevel = loggerLevel[l.minLevel] || loggerLevel.debug; if (minLevel <= level && maxLevel >= level && logger.match(reg)) { matched = 0; break; } } } if (matched) { msg = logger + ': ' + msg; } } /*global console*/ if (matched) { if (typeof console !== 'undefined' && console.log) { console[cat && console[cat] ? cat : 'log'](msg); } return msg; } } return undefined; }
[ "function", "(", "msg", ",", "cat", ",", "logger", ")", "{", "if", "(", "'@DEBUG@'", ")", "{", "var", "matched", "=", "1", ";", "if", "(", "logger", ")", "{", "var", "list", ",", "i", ",", "l", ",", "level", ",", "minLevel", ",", "maxLevel", ",", "reg", ";", "cat", "=", "cat", "||", "'debug'", ";", "level", "=", "loggerLevel", "[", "cat", "]", "||", "loggerLevel", ".", "debug", ";", "if", "(", "(", "list", "=", "config", ".", "includes", ")", ")", "{", "matched", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "list", ".", "length", ";", "i", "++", ")", "{", "l", "=", "list", "[", "i", "]", ";", "reg", "=", "l", ".", "logger", ";", "maxLevel", "=", "loggerLevel", "[", "l", ".", "maxLevel", "]", "||", "loggerLevel", ".", "error", ";", "minLevel", "=", "loggerLevel", "[", "l", ".", "minLevel", "]", "||", "loggerLevel", ".", "debug", ";", "if", "(", "minLevel", "<=", "level", "&&", "maxLevel", ">=", "level", "&&", "logger", ".", "match", "(", "reg", ")", ")", "{", "matched", "=", "1", ";", "break", ";", "}", "}", "}", "else", "if", "(", "(", "list", "=", "config", ".", "excludes", ")", ")", "{", "matched", "=", "1", ";", "for", "(", "i", "=", "0", ";", "i", "<", "list", ".", "length", ";", "i", "++", ")", "{", "l", "=", "list", "[", "i", "]", ";", "reg", "=", "l", ".", "logger", ";", "maxLevel", "=", "loggerLevel", "[", "l", ".", "maxLevel", "]", "||", "loggerLevel", ".", "error", ";", "minLevel", "=", "loggerLevel", "[", "l", ".", "minLevel", "]", "||", "loggerLevel", ".", "debug", ";", "if", "(", "minLevel", "<=", "level", "&&", "maxLevel", ">=", "level", "&&", "logger", ".", "match", "(", "reg", ")", ")", "{", "matched", "=", "0", ";", "break", ";", "}", "}", "}", "if", "(", "matched", ")", "{", "msg", "=", "logger", "+", "': '", "+", "msg", ";", "}", "}", "if", "(", "matched", ")", "{", "if", "(", "typeof", "console", "!==", "'undefined'", "&&", "console", ".", "log", ")", "{", "console", "[", "cat", "&&", "console", "[", "cat", "]", "?", "cat", ":", "'log'", "]", "(", "msg", ")", ";", "}", "return", "msg", ";", "}", "}", "return", "undefined", ";", "}" ]
Prints debug info. @param msg {String} the message to log. @param {String} [cat] the log category for the message. Default categories are 'info', 'warn', 'error', 'time' etc. @param {String} [logger] the logger of the the message (opt)
[ "Prints", "debug", "info", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/loader.js#L235-L280
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/loader.js
function (name, cfg) { var module = mods[name]; if (!module) { name = normalizeName(name); module = mods[name]; } if (module) { mix(module, cfg); // module definition changes requires if (cfg && cfg.requires) { module.setRequiresModules(cfg.requires); } return module; } // 防止 cfg 里有 tag,构建 fullpath 需要 mods[name] = module = new Loader.Module(mix({ name: name }, cfg)); return module; }
javascript
function (name, cfg) { var module = mods[name]; if (!module) { name = normalizeName(name); module = mods[name]; } if (module) { mix(module, cfg); // module definition changes requires if (cfg && cfg.requires) { module.setRequiresModules(cfg.requires); } return module; } // 防止 cfg 里有 tag,构建 fullpath 需要 mods[name] = module = new Loader.Module(mix({ name: name }, cfg)); return module; }
[ "function", "(", "name", ",", "cfg", ")", "{", "var", "module", "=", "mods", "[", "name", "]", ";", "if", "(", "!", "module", ")", "{", "name", "=", "normalizeName", "(", "name", ")", ";", "module", "=", "mods", "[", "name", "]", ";", "}", "if", "(", "module", ")", "{", "mix", "(", "module", ",", "cfg", ")", ";", "if", "(", "cfg", "&&", "cfg", ".", "requires", ")", "{", "module", ".", "setRequiresModules", "(", "cfg", ".", "requires", ")", ";", "}", "return", "module", ";", "}", "mods", "[", "name", "]", "=", "module", "=", "new", "Loader", ".", "Module", "(", "mix", "(", "{", "name", ":", "name", "}", ",", "cfg", ")", ")", ";", "return", "module", ";", "}" ]
get a module from cache or create a module instance
[ "get", "a", "module", "from", "cache", "or", "create", "a", "module", "instance" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/loader.js#L589-L612
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/loader.js
function () { var self = this; if (!self.url) { self.url = Utils.normalizeSlash(S.Config.resolveModFn(self)); } return self.url; }
javascript
function () { var self = this; if (!self.url) { self.url = Utils.normalizeSlash(S.Config.resolveModFn(self)); } return self.url; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "self", ".", "url", ")", "{", "self", ".", "url", "=", "Utils", ".", "normalizeSlash", "(", "S", ".", "Config", ".", "resolveModFn", "(", "self", ")", ")", ";", "}", "return", "self", ".", "url", ";", "}" ]
Get the path url of current module if load dynamically @return {String}
[ "Get", "the", "path", "url", "of", "current", "module", "if", "load", "dynamically" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/loader.js#L939-L945
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/loader.js
cssPoll
function cssPoll() { for (var url in monitors) { var callbackObj = monitors[url], node = callbackObj.node; if (isCssLoaded(node, url)) { if (callbackObj.callback) { callbackObj.callback.call(node); } delete monitors[url]; } } if (Utils.isEmptyObject(monitors)) { logger.debug('clear css poll timer'); timer = 0; } else { timer = setTimeout(cssPoll, CSS_POLL_INTERVAL); } }
javascript
function cssPoll() { for (var url in monitors) { var callbackObj = monitors[url], node = callbackObj.node; if (isCssLoaded(node, url)) { if (callbackObj.callback) { callbackObj.callback.call(node); } delete monitors[url]; } } if (Utils.isEmptyObject(monitors)) { logger.debug('clear css poll timer'); timer = 0; } else { timer = setTimeout(cssPoll, CSS_POLL_INTERVAL); } }
[ "function", "cssPoll", "(", ")", "{", "for", "(", "var", "url", "in", "monitors", ")", "{", "var", "callbackObj", "=", "monitors", "[", "url", "]", ",", "node", "=", "callbackObj", ".", "node", ";", "if", "(", "isCssLoaded", "(", "node", ",", "url", ")", ")", "{", "if", "(", "callbackObj", ".", "callback", ")", "{", "callbackObj", ".", "callback", ".", "call", "(", "node", ")", ";", "}", "delete", "monitors", "[", "url", "]", ";", "}", "}", "if", "(", "Utils", ".", "isEmptyObject", "(", "monitors", ")", ")", "{", "logger", ".", "debug", "(", "'clear css poll timer'", ")", ";", "timer", "=", "0", ";", "}", "else", "{", "timer", "=", "setTimeout", "(", "cssPoll", ",", "CSS_POLL_INTERVAL", ")", ";", "}", "}" ]
single thread is ok
[ "single", "thread", "is", "ok" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/loader.js#L1193-L1211
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/loader.js
function (moduleName) { var requiresModule = createModule(moduleName); var mods = requiresModule.getNormalizedModules(); Utils.each(mods, function (m) { m.undef(); }); }
javascript
function (moduleName) { var requiresModule = createModule(moduleName); var mods = requiresModule.getNormalizedModules(); Utils.each(mods, function (m) { m.undef(); }); }
[ "function", "(", "moduleName", ")", "{", "var", "requiresModule", "=", "createModule", "(", "moduleName", ")", ";", "var", "mods", "=", "requiresModule", ".", "getNormalizedModules", "(", ")", ";", "Utils", ".", "each", "(", "mods", ",", "function", "(", "m", ")", "{", "m", ".", "undef", "(", ")", ";", "}", ")", ";", "}" ]
undefine a module @param {String} moduleName module name @member KISSY
[ "undefine", "a", "module" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/loader.js#L2365-L2371
train
Automattic/wpcom-unpublished
lib/site.wordads.earnings.js
SiteWordAdsEarnings
function SiteWordAdsEarnings( sid, wpcom ) { if ( ! ( this instanceof SiteWordAdsEarnings ) ) { return new SiteWordAdsEarnings( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
javascript
function SiteWordAdsEarnings( sid, wpcom ) { if ( ! ( this instanceof SiteWordAdsEarnings ) ) { return new SiteWordAdsEarnings( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
[ "function", "SiteWordAdsEarnings", "(", "sid", ",", "wpcom", ")", "{", "if", "(", "!", "(", "this", "instanceof", "SiteWordAdsEarnings", ")", ")", "{", "return", "new", "SiteWordAdsEarnings", "(", "sid", ",", "wpcom", ")", ";", "}", "this", ".", "_sid", "=", "sid", ";", "this", ".", "wpcom", "=", "wpcom", ";", "}" ]
`SiteWordAdsEarnings` constructor. *Example:* // Require `wpcom-unpublished` library var wpcomUnpublished = require( 'wpcom-unpublished' ); // Create a `wpcomUnpublished` instance var wpcom = wpcomUnpublished(); // Create a `SiteWordAdsEarnings` instance var wordAds = wpcom .site( 'my-blog.wordpress.com' ) .wordAds() .earnings(); @constructor @param {wpcomUnpublished} wpcom @public
[ "SiteWordAdsEarnings", "constructor", "." ]
9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e
https://github.com/Automattic/wpcom-unpublished/blob/9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e/lib/site.wordads.earnings.js#L23-L30
train
cshum/raco
index.js
_raco
function _raco (iter, args, callback, opts) { var self = this var trycatch = true var isYieldable = true var yielded = false var nothrow = !!opts.nothrow /** * internal callback stepper * * @param {object} err - callback error object * @param {...*} val - callback value(s) */ function step (err, val) { if (iter) { // generator step yielded = false isYieldable = false var state if (trycatch) { try { if (nothrow) state = iter.next(slice.call(arguments)) else state = err ? iter.throw(err) : iter.next(val) } catch (err) { iter = null // catch err, break iteration return step(err) } } else { if (nothrow) state = iter.next(slice.call(arguments)) else state = err ? iter.throw(err) : iter.next(val) } if (state && state.done) iter = null yielded = true isYieldable = yieldable.call(self, state.value, step, opts) if (!isYieldable && opts.yieldable) { isYieldable = opts.yieldable.call(self, state.value, step) } // next if generator returned non-yieldable if (!isYieldable && !iter) next(null, state.value) } else if (callback) { callback.apply(self, arguments) callback = null } } /** * next, callback stepper with nextTick * * @param {object} err - callback error object * @param {...*} val - callback value(s) */ function next () { var args = slice.call(arguments) if (!isYieldable) { // only handle callback if not yieldable if (iter && yielded) { // no need defer when yielded step.apply(self, args) } else { // need next tick if not defered process.nextTick(function () { step.apply(self, args) }) } } else { step(new Error('Callback on yieldable is prohibited')) } } // prepend or append next arg if (args) opts.prepend ? args.unshift(next) : args.push(next) else args = [next] if (!isGenerator(iter)) iter = iter.apply(self, args) if (callback) { // callback mode step() } else if (opts.Promise) { // return promise if callback not exists return new opts.Promise(function (resolve, reject) { callback = function (err, val) { if (err) reject(err) else resolve(val) } step() }) } else { // callback and promise not exists, // no try catch wrap trycatch = false callback = noop step() } }
javascript
function _raco (iter, args, callback, opts) { var self = this var trycatch = true var isYieldable = true var yielded = false var nothrow = !!opts.nothrow /** * internal callback stepper * * @param {object} err - callback error object * @param {...*} val - callback value(s) */ function step (err, val) { if (iter) { // generator step yielded = false isYieldable = false var state if (trycatch) { try { if (nothrow) state = iter.next(slice.call(arguments)) else state = err ? iter.throw(err) : iter.next(val) } catch (err) { iter = null // catch err, break iteration return step(err) } } else { if (nothrow) state = iter.next(slice.call(arguments)) else state = err ? iter.throw(err) : iter.next(val) } if (state && state.done) iter = null yielded = true isYieldable = yieldable.call(self, state.value, step, opts) if (!isYieldable && opts.yieldable) { isYieldable = opts.yieldable.call(self, state.value, step) } // next if generator returned non-yieldable if (!isYieldable && !iter) next(null, state.value) } else if (callback) { callback.apply(self, arguments) callback = null } } /** * next, callback stepper with nextTick * * @param {object} err - callback error object * @param {...*} val - callback value(s) */ function next () { var args = slice.call(arguments) if (!isYieldable) { // only handle callback if not yieldable if (iter && yielded) { // no need defer when yielded step.apply(self, args) } else { // need next tick if not defered process.nextTick(function () { step.apply(self, args) }) } } else { step(new Error('Callback on yieldable is prohibited')) } } // prepend or append next arg if (args) opts.prepend ? args.unshift(next) : args.push(next) else args = [next] if (!isGenerator(iter)) iter = iter.apply(self, args) if (callback) { // callback mode step() } else if (opts.Promise) { // return promise if callback not exists return new opts.Promise(function (resolve, reject) { callback = function (err, val) { if (err) reject(err) else resolve(val) } step() }) } else { // callback and promise not exists, // no try catch wrap trycatch = false callback = noop step() } }
[ "function", "_raco", "(", "iter", ",", "args", ",", "callback", ",", "opts", ")", "{", "var", "self", "=", "this", "var", "trycatch", "=", "true", "var", "isYieldable", "=", "true", "var", "yielded", "=", "false", "var", "nothrow", "=", "!", "!", "opts", ".", "nothrow", "function", "step", "(", "err", ",", "val", ")", "{", "if", "(", "iter", ")", "{", "yielded", "=", "false", "isYieldable", "=", "false", "var", "state", "if", "(", "trycatch", ")", "{", "try", "{", "if", "(", "nothrow", ")", "state", "=", "iter", ".", "next", "(", "slice", ".", "call", "(", "arguments", ")", ")", "else", "state", "=", "err", "?", "iter", ".", "throw", "(", "err", ")", ":", "iter", ".", "next", "(", "val", ")", "}", "catch", "(", "err", ")", "{", "iter", "=", "null", "return", "step", "(", "err", ")", "}", "}", "else", "{", "if", "(", "nothrow", ")", "state", "=", "iter", ".", "next", "(", "slice", ".", "call", "(", "arguments", ")", ")", "else", "state", "=", "err", "?", "iter", ".", "throw", "(", "err", ")", ":", "iter", ".", "next", "(", "val", ")", "}", "if", "(", "state", "&&", "state", ".", "done", ")", "iter", "=", "null", "yielded", "=", "true", "isYieldable", "=", "yieldable", ".", "call", "(", "self", ",", "state", ".", "value", ",", "step", ",", "opts", ")", "if", "(", "!", "isYieldable", "&&", "opts", ".", "yieldable", ")", "{", "isYieldable", "=", "opts", ".", "yieldable", ".", "call", "(", "self", ",", "state", ".", "value", ",", "step", ")", "}", "if", "(", "!", "isYieldable", "&&", "!", "iter", ")", "next", "(", "null", ",", "state", ".", "value", ")", "}", "else", "if", "(", "callback", ")", "{", "callback", ".", "apply", "(", "self", ",", "arguments", ")", "callback", "=", "null", "}", "}", "function", "next", "(", ")", "{", "var", "args", "=", "slice", ".", "call", "(", "arguments", ")", "if", "(", "!", "isYieldable", ")", "{", "if", "(", "iter", "&&", "yielded", ")", "{", "step", ".", "apply", "(", "self", ",", "args", ")", "}", "else", "{", "process", ".", "nextTick", "(", "function", "(", ")", "{", "step", ".", "apply", "(", "self", ",", "args", ")", "}", ")", "}", "}", "else", "{", "step", "(", "new", "Error", "(", "'Callback on yieldable is prohibited'", ")", ")", "}", "}", "if", "(", "args", ")", "opts", ".", "prepend", "?", "args", ".", "unshift", "(", "next", ")", ":", "args", ".", "push", "(", "next", ")", "else", "args", "=", "[", "next", "]", "if", "(", "!", "isGenerator", "(", "iter", ")", ")", "iter", "=", "iter", ".", "apply", "(", "self", ",", "args", ")", "if", "(", "callback", ")", "{", "step", "(", ")", "}", "else", "if", "(", "opts", ".", "Promise", ")", "{", "return", "new", "opts", ".", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "callback", "=", "function", "(", "err", ",", "val", ")", "{", "if", "(", "err", ")", "reject", "(", "err", ")", "else", "resolve", "(", "val", ")", "}", "step", "(", ")", "}", ")", "}", "else", "{", "trycatch", "=", "false", "callback", "=", "noop", "step", "(", ")", "}", "}" ]
internal raco resolver @param {function} genFn - generator function @param {array} args - arguments in real array form @returns {promise} if no callback provided
[ "internal", "raco", "resolver" ]
33909b489c1696492253c90f49d24c27e18a4ed6
https://github.com/cshum/raco/blob/33909b489c1696492253c90f49d24c27e18a4ed6/index.js#L62-L154
train
cshum/raco
index.js
step
function step (err, val) { if (iter) { // generator step yielded = false isYieldable = false var state if (trycatch) { try { if (nothrow) state = iter.next(slice.call(arguments)) else state = err ? iter.throw(err) : iter.next(val) } catch (err) { iter = null // catch err, break iteration return step(err) } } else { if (nothrow) state = iter.next(slice.call(arguments)) else state = err ? iter.throw(err) : iter.next(val) } if (state && state.done) iter = null yielded = true isYieldable = yieldable.call(self, state.value, step, opts) if (!isYieldable && opts.yieldable) { isYieldable = opts.yieldable.call(self, state.value, step) } // next if generator returned non-yieldable if (!isYieldable && !iter) next(null, state.value) } else if (callback) { callback.apply(self, arguments) callback = null } }
javascript
function step (err, val) { if (iter) { // generator step yielded = false isYieldable = false var state if (trycatch) { try { if (nothrow) state = iter.next(slice.call(arguments)) else state = err ? iter.throw(err) : iter.next(val) } catch (err) { iter = null // catch err, break iteration return step(err) } } else { if (nothrow) state = iter.next(slice.call(arguments)) else state = err ? iter.throw(err) : iter.next(val) } if (state && state.done) iter = null yielded = true isYieldable = yieldable.call(self, state.value, step, opts) if (!isYieldable && opts.yieldable) { isYieldable = opts.yieldable.call(self, state.value, step) } // next if generator returned non-yieldable if (!isYieldable && !iter) next(null, state.value) } else if (callback) { callback.apply(self, arguments) callback = null } }
[ "function", "step", "(", "err", ",", "val", ")", "{", "if", "(", "iter", ")", "{", "yielded", "=", "false", "isYieldable", "=", "false", "var", "state", "if", "(", "trycatch", ")", "{", "try", "{", "if", "(", "nothrow", ")", "state", "=", "iter", ".", "next", "(", "slice", ".", "call", "(", "arguments", ")", ")", "else", "state", "=", "err", "?", "iter", ".", "throw", "(", "err", ")", ":", "iter", ".", "next", "(", "val", ")", "}", "catch", "(", "err", ")", "{", "iter", "=", "null", "return", "step", "(", "err", ")", "}", "}", "else", "{", "if", "(", "nothrow", ")", "state", "=", "iter", ".", "next", "(", "slice", ".", "call", "(", "arguments", ")", ")", "else", "state", "=", "err", "?", "iter", ".", "throw", "(", "err", ")", ":", "iter", ".", "next", "(", "val", ")", "}", "if", "(", "state", "&&", "state", ".", "done", ")", "iter", "=", "null", "yielded", "=", "true", "isYieldable", "=", "yieldable", ".", "call", "(", "self", ",", "state", ".", "value", ",", "step", ",", "opts", ")", "if", "(", "!", "isYieldable", "&&", "opts", ".", "yieldable", ")", "{", "isYieldable", "=", "opts", ".", "yieldable", ".", "call", "(", "self", ",", "state", ".", "value", ",", "step", ")", "}", "if", "(", "!", "isYieldable", "&&", "!", "iter", ")", "next", "(", "null", ",", "state", ".", "value", ")", "}", "else", "if", "(", "callback", ")", "{", "callback", ".", "apply", "(", "self", ",", "arguments", ")", "callback", "=", "null", "}", "}" ]
internal callback stepper @param {object} err - callback error object @param {...*} val - callback value(s)
[ "internal", "callback", "stepper" ]
33909b489c1696492253c90f49d24c27e18a4ed6
https://github.com/cshum/raco/blob/33909b489c1696492253c90f49d24c27e18a4ed6/index.js#L74-L104
train
cshum/raco
index.js
next
function next () { var args = slice.call(arguments) if (!isYieldable) { // only handle callback if not yieldable if (iter && yielded) { // no need defer when yielded step.apply(self, args) } else { // need next tick if not defered process.nextTick(function () { step.apply(self, args) }) } } else { step(new Error('Callback on yieldable is prohibited')) } }
javascript
function next () { var args = slice.call(arguments) if (!isYieldable) { // only handle callback if not yieldable if (iter && yielded) { // no need defer when yielded step.apply(self, args) } else { // need next tick if not defered process.nextTick(function () { step.apply(self, args) }) } } else { step(new Error('Callback on yieldable is prohibited')) } }
[ "function", "next", "(", ")", "{", "var", "args", "=", "slice", ".", "call", "(", "arguments", ")", "if", "(", "!", "isYieldable", ")", "{", "if", "(", "iter", "&&", "yielded", ")", "{", "step", ".", "apply", "(", "self", ",", "args", ")", "}", "else", "{", "process", ".", "nextTick", "(", "function", "(", ")", "{", "step", ".", "apply", "(", "self", ",", "args", ")", "}", ")", "}", "}", "else", "{", "step", "(", "new", "Error", "(", "'Callback on yieldable is prohibited'", ")", ")", "}", "}" ]
next, callback stepper with nextTick @param {object} err - callback error object @param {...*} val - callback value(s)
[ "next", "callback", "stepper", "with", "nextTick" ]
33909b489c1696492253c90f49d24c27e18a4ed6
https://github.com/cshum/raco/blob/33909b489c1696492253c90f49d24c27e18a4ed6/index.js#L111-L127
train
cshum/raco
index.js
raco
function raco (genFn, opts) { if (!isGeneratorFunction(genFn)) { if (isFunction(genFn)) throw new Error('Generator function required') else if (!isGenerator(genFn)) return factory(genFn) } opts = Object.assign({}, _opts, opts) opts.Promise = null return _raco.call(this, genFn, null, null, opts) }
javascript
function raco (genFn, opts) { if (!isGeneratorFunction(genFn)) { if (isFunction(genFn)) throw new Error('Generator function required') else if (!isGenerator(genFn)) return factory(genFn) } opts = Object.assign({}, _opts, opts) opts.Promise = null return _raco.call(this, genFn, null, null, opts) }
[ "function", "raco", "(", "genFn", ",", "opts", ")", "{", "if", "(", "!", "isGeneratorFunction", "(", "genFn", ")", ")", "{", "if", "(", "isFunction", "(", "genFn", ")", ")", "throw", "new", "Error", "(", "'Generator function required'", ")", "else", "if", "(", "!", "isGenerator", "(", "genFn", ")", ")", "return", "factory", "(", "genFn", ")", "}", "opts", "=", "Object", ".", "assign", "(", "{", "}", ",", "_opts", ",", "opts", ")", "opts", ".", "Promise", "=", "null", "return", "_raco", ".", "call", "(", "this", ",", "genFn", ",", "null", ",", "null", ",", "opts", ")", "}" ]
raco resolver returns factory if no arguments @param {function} genFn - generator function or factory options @param {object} [opts] - options object @returns {promise} if no callback provided
[ "raco", "resolver", "returns", "factory", "if", "no", "arguments" ]
33909b489c1696492253c90f49d24c27e18a4ed6
https://github.com/cshum/raco/blob/33909b489c1696492253c90f49d24c27e18a4ed6/index.js#L171-L179
train
lyveminds/scamandrios
lib/column_family.js
columnParent
function columnParent(cf, column) { var args = { column_family: cf.name }; if (cf.isSuper && column) args.super_column = cf.columnMarshaller.serialize(column); return new ttype.ColumnParent(args); }
javascript
function columnParent(cf, column) { var args = { column_family: cf.name }; if (cf.isSuper && column) args.super_column = cf.columnMarshaller.serialize(column); return new ttype.ColumnParent(args); }
[ "function", "columnParent", "(", "cf", ",", "column", ")", "{", "var", "args", "=", "{", "column_family", ":", "cf", ".", "name", "}", ";", "if", "(", "cf", ".", "isSuper", "&&", "column", ")", "args", ".", "super_column", "=", "cf", ".", "columnMarshaller", ".", "serialize", "(", "column", ")", ";", "return", "new", "ttype", ".", "ColumnParent", "(", "args", ")", ";", "}" ]
Returns a column parent When calculating the column parent of a standard column family, the parent is simply the column family name. When dealing with super columns on the other hand, an optional name parameter may be provided. @param {Object} cf A reference to the ColumnFamily @param {Object} name The name of the column (optional) @private @memberOf ColumnFamily @returns {Object} a Thrift ColumnParent object
[ "Returns", "a", "column", "parent", "When", "calculating", "the", "column", "parent", "of", "a", "standard", "column", "family", "the", "parent", "is", "simply", "the", "column", "family", "name", ".", "When", "dealing", "with", "super", "columns", "on", "the", "other", "hand", "an", "optional", "name", "parameter", "may", "be", "provided", "." ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/lib/column_family.js#L28-L34
train
lyveminds/scamandrios
lib/column_family.js
columnPath
function columnPath(cf, column, subcolumn) { var args = { column_family: cf.name }; if (column) args.column = cf.columnMarshaller.serialize(column); if (cf.isSuper && subcolumn) args.subcolumn = cf.subcolumnMarshaller.serialize(subcolumn); return new ttype.ColumnPath(args); }
javascript
function columnPath(cf, column, subcolumn) { var args = { column_family: cf.name }; if (column) args.column = cf.columnMarshaller.serialize(column); if (cf.isSuper && subcolumn) args.subcolumn = cf.subcolumnMarshaller.serialize(subcolumn); return new ttype.ColumnPath(args); }
[ "function", "columnPath", "(", "cf", ",", "column", ",", "subcolumn", ")", "{", "var", "args", "=", "{", "column_family", ":", "cf", ".", "name", "}", ";", "if", "(", "column", ")", "args", ".", "column", "=", "cf", ".", "columnMarshaller", ".", "serialize", "(", "column", ")", ";", "if", "(", "cf", ".", "isSuper", "&&", "subcolumn", ")", "args", ".", "subcolumn", "=", "cf", ".", "subcolumnMarshaller", ".", "serialize", "(", "subcolumn", ")", ";", "return", "new", "ttype", ".", "ColumnPath", "(", "args", ")", ";", "}" ]
Returns a column path As with the ColumnParent, the value of the ColumnPath depends on whether this is a standard or super column family. Both must specify the column family name. A standard column family may provide an optional column name parameter. In addition to the column name, a super column family may also use a subcolumn parameter. @param {Object} cf A reference to the ColumnFamily @param {Object} column The name of the column (optional) @param {Object} subcolumn The name of the subcolumn (optional) @private @memberOf ColumnFamily a Thrift ColumnPath object
[ "Returns", "a", "column", "path", "As", "with", "the", "ColumnParent", "the", "value", "of", "the", "ColumnPath", "depends", "on", "whether", "this", "is", "a", "standard", "or", "super", "column", "family", ".", "Both", "must", "specify", "the", "column", "family", "name", ".", "A", "standard", "column", "family", "may", "provide", "an", "optional", "column", "name", "parameter", ".", "In", "addition", "to", "the", "column", "name", "a", "super", "column", "family", "may", "also", "use", "a", "subcolumn", "parameter", "." ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/lib/column_family.js#L50-L61
train
lyveminds/scamandrios
lib/column_family.js
normalizeParameters
function normalizeParameters(list) { list = _.toArray(list); return _.reduce(list, function(args, value, index) { if (_.isObject(value) && !Array.isArray(value)) { var options = args.options, timestamp = value.timestamp, consistency = value.consistency || value.consistencyLevel; if (_.isDate(timestamp)) options.timestamp = timestamp; if (consistency) options.consistency = consistency; _.defaults(options, value); } else if (index < 2) args[index ? 'subcolumn' : 'column'] = value; return args; }, { key: list.shift(), options: { timestamp: new Date(), consistency: DEFAULT_WRITE_CONSISTENCY } }); }
javascript
function normalizeParameters(list) { list = _.toArray(list); return _.reduce(list, function(args, value, index) { if (_.isObject(value) && !Array.isArray(value)) { var options = args.options, timestamp = value.timestamp, consistency = value.consistency || value.consistencyLevel; if (_.isDate(timestamp)) options.timestamp = timestamp; if (consistency) options.consistency = consistency; _.defaults(options, value); } else if (index < 2) args[index ? 'subcolumn' : 'column'] = value; return args; }, { key: list.shift(), options: { timestamp: new Date(), consistency: DEFAULT_WRITE_CONSISTENCY } }); }
[ "function", "normalizeParameters", "(", "list", ")", "{", "list", "=", "_", ".", "toArray", "(", "list", ")", ";", "return", "_", ".", "reduce", "(", "list", ",", "function", "(", "args", ",", "value", ",", "index", ")", "{", "if", "(", "_", ".", "isObject", "(", "value", ")", "&&", "!", "Array", ".", "isArray", "(", "value", ")", ")", "{", "var", "options", "=", "args", ".", "options", ",", "timestamp", "=", "value", ".", "timestamp", ",", "consistency", "=", "value", ".", "consistency", "||", "value", ".", "consistencyLevel", ";", "if", "(", "_", ".", "isDate", "(", "timestamp", ")", ")", "options", ".", "timestamp", "=", "timestamp", ";", "if", "(", "consistency", ")", "options", ".", "consistency", "=", "consistency", ";", "_", ".", "defaults", "(", "options", ",", "value", ")", ";", "}", "else", "if", "(", "index", "<", "2", ")", "args", "[", "index", "?", "'subcolumn'", ":", "'column'", "]", "=", "value", ";", "return", "args", ";", "}", ",", "{", "key", ":", "list", ".", "shift", "(", ")", ",", "options", ":", "{", "timestamp", ":", "new", "Date", "(", ")", ",", "consistency", ":", "DEFAULT_WRITE_CONSISTENCY", "}", "}", ")", ";", "}" ]
A convenience method to normalize the standard parameters used by a thrift operation. The parameter list must contain a `key` parameter as its first item. The `column`, `subcolumn`, `options`, and `callback` parameters are optional. @param {Array} list The list of parameters @private @memberOf ColumnFamily @returns {Object} a normalized version of the provided parameter values
[ "A", "convenience", "method", "to", "normalize", "the", "standard", "parameters", "used", "by", "a", "thrift", "operation", ".", "The", "parameter", "list", "must", "contain", "a", "key", "parameter", "as", "its", "first", "item", ".", "The", "column", "subcolumn", "options", "and", "callback", "parameters", "are", "optional", "." ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/lib/column_family.js#L116-L145
train
DennisSchwartz/multilayerlayout3d
lib/multilayerlayout3d.js
function() { var stable = []; for (var i=0;i<physicsSimulators.length; i++) { stable.push(physicsSimulators[i].step()); } // Check if all simulators are stable //console.log(stable); for (i=0;i<stable.length;i++) { if (!stable[i]) { return false } } return true; }
javascript
function() { var stable = []; for (var i=0;i<physicsSimulators.length; i++) { stable.push(physicsSimulators[i].step()); } // Check if all simulators are stable //console.log(stable); for (i=0;i<stable.length;i++) { if (!stable[i]) { return false } } return true; }
[ "function", "(", ")", "{", "var", "stable", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "physicsSimulators", ".", "length", ";", "i", "++", ")", "{", "stable", ".", "push", "(", "physicsSimulators", "[", "i", "]", ".", "step", "(", ")", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "stable", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "stable", "[", "i", "]", ")", "{", "return", "false", "}", "}", "return", "true", ";", "}" ]
Do one step of iterative layout calculation Return true is the current layout is stable
[ "Do", "one", "step", "of", "iterative", "layout", "calculation", "Return", "true", "is", "the", "current", "layout", "is", "stable" ]
772259e5cc46961df2d042c2866d52e039c91bc0
https://github.com/DennisSchwartz/multilayerlayout3d/blob/772259e5cc46961df2d042c2866d52e039c91bc0/lib/multilayerlayout3d.js#L69-L82
train
DennisSchwartz/multilayerlayout3d
lib/multilayerlayout3d.js
function (nodeId) { var layer = getLayer(nodeId); var body = getInitializedBody(nodeId); body.pos.z = layer * interLayerDistance; return body.pos; }
javascript
function (nodeId) { var layer = getLayer(nodeId); var body = getInitializedBody(nodeId); body.pos.z = layer * interLayerDistance; return body.pos; }
[ "function", "(", "nodeId", ")", "{", "var", "layer", "=", "getLayer", "(", "nodeId", ")", ";", "var", "body", "=", "getInitializedBody", "(", "nodeId", ")", ";", "body", ".", "pos", ".", "z", "=", "layer", "*", "interLayerDistance", ";", "return", "body", ".", "pos", ";", "}" ]
This will return the current position for each node @param nodeId @returns {Vector3d}
[ "This", "will", "return", "the", "current", "position", "for", "each", "node" ]
772259e5cc46961df2d042c2866d52e039c91bc0
https://github.com/DennisSchwartz/multilayerlayout3d/blob/772259e5cc46961df2d042c2866d52e039c91bc0/lib/multilayerlayout3d.js#L89-L94
train
DennisSchwartz/multilayerlayout3d
lib/multilayerlayout3d.js
function() { graph.off('changed', onGraphChanged); for (var i=0;i<physicsSimulators.length; i++) { physicsSimulators[i].off('stable', onStableChanged); } }
javascript
function() { graph.off('changed', onGraphChanged); for (var i=0;i<physicsSimulators.length; i++) { physicsSimulators[i].off('stable', onStableChanged); } }
[ "function", "(", ")", "{", "graph", ".", "off", "(", "'changed'", ",", "onGraphChanged", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "physicsSimulators", ".", "length", ";", "i", "++", ")", "{", "physicsSimulators", "[", "i", "]", ".", "off", "(", "'stable'", ",", "onStableChanged", ")", ";", "}", "}" ]
Request to release all resources
[ "Request", "to", "release", "all", "resources" ]
772259e5cc46961df2d042c2866d52e039c91bc0
https://github.com/DennisSchwartz/multilayerlayout3d/blob/772259e5cc46961df2d042c2866d52e039c91bc0/lib/multilayerlayout3d.js#L173-L178
train
kissyteam/kissy-xtemplate
lib/kg/kg-4.2.0/compiler.js
function (tplContent, name) { if (tplContent) { var ret; try { ret = parser.parse(tplContent, name); } catch (err) { var e; if (err instanceof Error) { e = err; } else { e = new Error(err); } var errorStr = 'XTemplate error '; e.stack = errorStr + e.stack; e.message = errorStr + e.message; throw e; } return ret; } else { return { statements: [] }; } }
javascript
function (tplContent, name) { if (tplContent) { var ret; try { ret = parser.parse(tplContent, name); } catch (err) { var e; if (err instanceof Error) { e = err; } else { e = new Error(err); } var errorStr = 'XTemplate error '; e.stack = errorStr + e.stack; e.message = errorStr + e.message; throw e; } return ret; } else { return { statements: [] }; } }
[ "function", "(", "tplContent", ",", "name", ")", "{", "if", "(", "tplContent", ")", "{", "var", "ret", ";", "try", "{", "ret", "=", "parser", ".", "parse", "(", "tplContent", ",", "name", ")", ";", "}", "catch", "(", "err", ")", "{", "var", "e", ";", "if", "(", "err", "instanceof", "Error", ")", "{", "e", "=", "err", ";", "}", "else", "{", "e", "=", "new", "Error", "(", "err", ")", ";", "}", "var", "errorStr", "=", "'XTemplate error '", ";", "e", ".", "stack", "=", "errorStr", "+", "e", ".", "stack", ";", "e", ".", "message", "=", "errorStr", "+", "e", ".", "message", ";", "throw", "e", ";", "}", "return", "ret", ";", "}", "else", "{", "return", "{", "statements", ":", "[", "]", "}", ";", "}", "}" ]
get ast of template @param {String} [name] xtemplate name @param {String} tplContent @return {Object}
[ "get", "ast", "of", "template" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kg/kg-4.2.0/compiler.js#L635-L658
train
craterdog-bali/js-bali-component-framework
src/collections/Queue.js
Queue
function Queue(parameters) { parameters = parameters || new composites.Parameters(new Catalog()); if (!parameters.getParameter('$type')) parameters.setParameter('$type', '/bali/collections/Queue/v1'); abstractions.Collection.call(this, utilities.types.QUEUE, parameters); // the capacity and array are private attributes so methods that use it are // defined in the constructor var capacity = 1024; // default capacity if (parameters) { const value = parameters.getParameter('$capacity', 2); if (value) capacity = value.toNumber(); } const array = []; this.acceptVisitor = function(visitor) { visitor.visitQueue(this); }; this.toArray = function() { return array.slice(); // copy the array }; this.getSize = function() { return array.length; }; this.addItem = function(item) { if (array.length < capacity) { item = this.convert(item); array.push(item); return true; } throw new utilities.Exception({ $module: '/bali/collections/Queue', $procedure: '$addItem', $exception: '$resourceLimit', $capacity: capacity, $text: '"The queue has reached its maximum capacity."' }); }; this.removeItem = function() { if (array.length > 0) return array.splice(0, 1)[0]; // remove the first item in the array }; this.getHead = function() { return array[0]; }; this.deleteAll = function() { array.splice(0); }; return this; }
javascript
function Queue(parameters) { parameters = parameters || new composites.Parameters(new Catalog()); if (!parameters.getParameter('$type')) parameters.setParameter('$type', '/bali/collections/Queue/v1'); abstractions.Collection.call(this, utilities.types.QUEUE, parameters); // the capacity and array are private attributes so methods that use it are // defined in the constructor var capacity = 1024; // default capacity if (parameters) { const value = parameters.getParameter('$capacity', 2); if (value) capacity = value.toNumber(); } const array = []; this.acceptVisitor = function(visitor) { visitor.visitQueue(this); }; this.toArray = function() { return array.slice(); // copy the array }; this.getSize = function() { return array.length; }; this.addItem = function(item) { if (array.length < capacity) { item = this.convert(item); array.push(item); return true; } throw new utilities.Exception({ $module: '/bali/collections/Queue', $procedure: '$addItem', $exception: '$resourceLimit', $capacity: capacity, $text: '"The queue has reached its maximum capacity."' }); }; this.removeItem = function() { if (array.length > 0) return array.splice(0, 1)[0]; // remove the first item in the array }; this.getHead = function() { return array[0]; }; this.deleteAll = function() { array.splice(0); }; return this; }
[ "function", "Queue", "(", "parameters", ")", "{", "parameters", "=", "parameters", "||", "new", "composites", ".", "Parameters", "(", "new", "Catalog", "(", ")", ")", ";", "if", "(", "!", "parameters", ".", "getParameter", "(", "'$type'", ")", ")", "parameters", ".", "setParameter", "(", "'$type'", ",", "'/bali/collections/Queue/v1'", ")", ";", "abstractions", ".", "Collection", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "QUEUE", ",", "parameters", ")", ";", "var", "capacity", "=", "1024", ";", "if", "(", "parameters", ")", "{", "const", "value", "=", "parameters", ".", "getParameter", "(", "'$capacity'", ",", "2", ")", ";", "if", "(", "value", ")", "capacity", "=", "value", ".", "toNumber", "(", ")", ";", "}", "const", "array", "=", "[", "]", ";", "this", ".", "acceptVisitor", "=", "function", "(", "visitor", ")", "{", "visitor", ".", "visitQueue", "(", "this", ")", ";", "}", ";", "this", ".", "toArray", "=", "function", "(", ")", "{", "return", "array", ".", "slice", "(", ")", ";", "}", ";", "this", ".", "getSize", "=", "function", "(", ")", "{", "return", "array", ".", "length", ";", "}", ";", "this", ".", "addItem", "=", "function", "(", "item", ")", "{", "if", "(", "array", ".", "length", "<", "capacity", ")", "{", "item", "=", "this", ".", "convert", "(", "item", ")", ";", "array", ".", "push", "(", "item", ")", ";", "return", "true", ";", "}", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/collections/Queue'", ",", "$procedure", ":", "'$addItem'", ",", "$exception", ":", "'$resourceLimit'", ",", "$capacity", ":", "capacity", ",", "$text", ":", "'\"The queue has reached its maximum capacity.\"'", "}", ")", ";", "}", ";", "this", ".", "removeItem", "=", "function", "(", ")", "{", "if", "(", "array", ".", "length", ">", "0", ")", "return", "array", ".", "splice", "(", "0", ",", "1", ")", "[", "0", "]", ";", "}", ";", "this", ".", "getHead", "=", "function", "(", ")", "{", "return", "array", "[", "0", "]", ";", "}", ";", "this", ".", "deleteAll", "=", "function", "(", ")", "{", "array", ".", "splice", "(", "0", ")", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTORS This constructor creates a new queue component with optional parameters that are used to parameterize its type. @param {Parameters} parameters Optional parameters used to parameterize this collection. @returns {Queue} The new queue.
[ "PUBLIC", "CONSTRUCTORS", "This", "constructor", "creates", "a", "new", "queue", "component", "with", "optional", "parameters", "that", "are", "used", "to", "parameterize", "its", "type", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/collections/Queue.js#L40-L94
train
electric-eloquence/fepper-ui
scripts/code-viewer.js
function (type, code) { $sgCodeTitles.removeClass('sg-code-title-active'); switch (type) { case 'e': $sgCodeTitleHtml.addClass('sg-code-title-active'); break; case 'm': $sgCodeTitleMustache.addClass('sg-code-title-active'); break; } $sgCodeFill.removeClass().addClass('language-markup'); $sgCodeFill.html(code); window.Prism.highlightElement($sgCodeFill[0]); if (codeViewer.copyOnInit) { codeViewer.selectCode(); codeViewer.copyOnInit = false; } }
javascript
function (type, code) { $sgCodeTitles.removeClass('sg-code-title-active'); switch (type) { case 'e': $sgCodeTitleHtml.addClass('sg-code-title-active'); break; case 'm': $sgCodeTitleMustache.addClass('sg-code-title-active'); break; } $sgCodeFill.removeClass().addClass('language-markup'); $sgCodeFill.html(code); window.Prism.highlightElement($sgCodeFill[0]); if (codeViewer.copyOnInit) { codeViewer.selectCode(); codeViewer.copyOnInit = false; } }
[ "function", "(", "type", ",", "code", ")", "{", "$sgCodeTitles", ".", "removeClass", "(", "'sg-code-title-active'", ")", ";", "switch", "(", "type", ")", "{", "case", "'e'", ":", "$sgCodeTitleHtml", ".", "addClass", "(", "'sg-code-title-active'", ")", ";", "break", ";", "case", "'m'", ":", "$sgCodeTitleMustache", ".", "addClass", "(", "'sg-code-title-active'", ")", ";", "break", ";", "}", "$sgCodeFill", ".", "removeClass", "(", ")", ".", "addClass", "(", "'language-markup'", ")", ";", "$sgCodeFill", ".", "html", "(", "code", ")", ";", "window", ".", "Prism", ".", "highlightElement", "(", "$sgCodeFill", "[", "0", "]", ")", ";", "if", "(", "codeViewer", ".", "copyOnInit", ")", "{", "codeViewer", ".", "selectCode", "(", ")", ";", "codeViewer", ".", "copyOnInit", "=", "false", ";", "}", "}" ]
When loading the code view make sure the active tab is highlighted and filled in appropriately. @param {string} type - Single letter that refers to classes and types. @param {string} code - Code to appear in code view.
[ "When", "loading", "the", "code", "view", "make", "sure", "the", "active", "tab", "is", "highlighted", "and", "filled", "in", "appropriately", "." ]
58281efcb426c137881937956c7383cd4a30c878
https://github.com/electric-eloquence/fepper-ui/blob/58281efcb426c137881937956c7383cd4a30c878/scripts/code-viewer.js#L40-L63
train