id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
35,700
bq/corbel-js
dist/corbel.with-polyfills.js
function(params) { var that = this; return corbel.request.send(params, that.driver).then(function(response) { that.driver.config.set(corbel.Services._FORCE_UPDATE_STATUS, 0); that.driver.config.set(corbel.Services._UNAUTHORIZED_NUM_RETRIES, 0); return response; }).catch(function(response) { // Force update if (response.status === corbel.Services._FORCE_UPDATE_STATUS_CODE && response.textStatus === corbel.Services._FORCE_UPDATE_TEXT) { var retries = that.driver.config.get(corbel.Services._FORCE_UPDATE_STATUS, 0); if (retries < corbel.Services._FORCE_UPDATE_MAX_RETRIES) { retries++; that.driver.config.set(corbel.Services._FORCE_UPDATE_STATUS, retries); that.driver.trigger('force:update', response); throw response; } else { throw response; } } else { throw response; } }); }
javascript
function(params) { var that = this; return corbel.request.send(params, that.driver).then(function(response) { that.driver.config.set(corbel.Services._FORCE_UPDATE_STATUS, 0); that.driver.config.set(corbel.Services._UNAUTHORIZED_NUM_RETRIES, 0); return response; }).catch(function(response) { // Force update if (response.status === corbel.Services._FORCE_UPDATE_STATUS_CODE && response.textStatus === corbel.Services._FORCE_UPDATE_TEXT) { var retries = that.driver.config.get(corbel.Services._FORCE_UPDATE_STATUS, 0); if (retries < corbel.Services._FORCE_UPDATE_MAX_RETRIES) { retries++; that.driver.config.set(corbel.Services._FORCE_UPDATE_STATUS, retries); that.driver.trigger('force:update', response); throw response; } else { throw response; } } else { throw response; } }); }
[ "function", "(", "params", ")", "{", "var", "that", "=", "this", ";", "return", "corbel", ".", "request", ".", "send", "(", "params", ",", "that", ".", "driver", ")", ".", "then", "(", "function", "(", "response", ")", "{", "that", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Services", ".", "_FORCE_UPDATE_STATUS", ",", "0", ")", ";", "that", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Services", ".", "_UNAUTHORIZED_NUM_RETRIES", ",", "0", ")", ";", "return", "response", ";", "}", ")", ".", "catch", "(", "function", "(", "response", ")", "{", "// Force update", "if", "(", "response", ".", "status", "===", "corbel", ".", "Services", ".", "_FORCE_UPDATE_STATUS_CODE", "&&", "response", ".", "textStatus", "===", "corbel", ".", "Services", ".", "_FORCE_UPDATE_TEXT", ")", "{", "var", "retries", "=", "that", ".", "driver", ".", "config", ".", "get", "(", "corbel", ".", "Services", ".", "_FORCE_UPDATE_STATUS", ",", "0", ")", ";", "if", "(", "retries", "<", "corbel", ".", "Services", ".", "_FORCE_UPDATE_MAX_RETRIES", ")", "{", "retries", "++", ";", "that", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Services", ".", "_FORCE_UPDATE_STATUS", ",", "retries", ")", ";", "that", ".", "driver", ".", "trigger", "(", "'force:update'", ",", "response", ")", ";", "throw", "response", ";", "}", "else", "{", "throw", "response", ";", "}", "}", "else", "{", "throw", "response", ";", "}", "}", ")", ";", "}" ]
Internal request method. Has force update behavior @param {object} params @return {Promise}
[ "Internal", "request", "method", ".", "Has", "force", "update", "behavior" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L2918-L2948
35,701
bq/corbel-js
dist/corbel.with-polyfills.js
function(tokenObject) { var that = this; if (this.driver._refreshHandlerPromise) { return this.driver._refreshHandlerPromise; } if (tokenObject.refreshToken) { console.log('corbeljs:services:token:refresh'); this.driver._refreshHandlerPromise = this.driver.iam.token().refresh( tokenObject.refreshToken, this.driver.config.get(corbel.Iam.IAM_TOKEN_SCOPES, '') ); } else { console.log('corbeljs:services:token:create'); this.driver._refreshHandlerPromise = this.driver.iam.token().create(); } return this.driver._refreshHandlerPromise .then(function(response) { that.driver.trigger('token:refresh', response.data); that.driver._refreshHandlerPromise = null; return response; }).catch(function(err) { that.driver._refreshHandlerPromise = null; throw err; }); }
javascript
function(tokenObject) { var that = this; if (this.driver._refreshHandlerPromise) { return this.driver._refreshHandlerPromise; } if (tokenObject.refreshToken) { console.log('corbeljs:services:token:refresh'); this.driver._refreshHandlerPromise = this.driver.iam.token().refresh( tokenObject.refreshToken, this.driver.config.get(corbel.Iam.IAM_TOKEN_SCOPES, '') ); } else { console.log('corbeljs:services:token:create'); this.driver._refreshHandlerPromise = this.driver.iam.token().create(); } return this.driver._refreshHandlerPromise .then(function(response) { that.driver.trigger('token:refresh', response.data); that.driver._refreshHandlerPromise = null; return response; }).catch(function(err) { that.driver._refreshHandlerPromise = null; throw err; }); }
[ "function", "(", "tokenObject", ")", "{", "var", "that", "=", "this", ";", "if", "(", "this", ".", "driver", ".", "_refreshHandlerPromise", ")", "{", "return", "this", ".", "driver", ".", "_refreshHandlerPromise", ";", "}", "if", "(", "tokenObject", ".", "refreshToken", ")", "{", "console", ".", "log", "(", "'corbeljs:services:token:refresh'", ")", ";", "this", ".", "driver", ".", "_refreshHandlerPromise", "=", "this", ".", "driver", ".", "iam", ".", "token", "(", ")", ".", "refresh", "(", "tokenObject", ".", "refreshToken", ",", "this", ".", "driver", ".", "config", ".", "get", "(", "corbel", ".", "Iam", ".", "IAM_TOKEN_SCOPES", ",", "''", ")", ")", ";", "}", "else", "{", "console", ".", "log", "(", "'corbeljs:services:token:create'", ")", ";", "this", ".", "driver", ".", "_refreshHandlerPromise", "=", "this", ".", "driver", ".", "iam", ".", "token", "(", ")", ".", "create", "(", ")", ";", "}", "return", "this", ".", "driver", ".", "_refreshHandlerPromise", ".", "then", "(", "function", "(", "response", ")", "{", "that", ".", "driver", ".", "trigger", "(", "'token:refresh'", ",", "response", ".", "data", ")", ";", "that", ".", "driver", ".", "_refreshHandlerPromise", "=", "null", ";", "return", "response", ";", "}", ")", ".", "catch", "(", "function", "(", "err", ")", "{", "that", ".", "driver", ".", "_refreshHandlerPromise", "=", "null", ";", "throw", "err", ";", "}", ")", ";", "}" ]
Default token refresh handler Only requested once at the same time @return {Promise}
[ "Default", "token", "refresh", "handler", "Only", "requested", "once", "at", "the", "same", "time" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L2961-L2989
35,702
bq/corbel-js
dist/corbel.with-polyfills.js
function(params) { var accessToken = params.accessToken ? params.accessToken : this.driver.config .get(corbel.Iam.IAM_TOKEN, {}).accessToken; if (accessToken && !params.headers.Authorization) { params.headers.Authorization = 'Bearer ' + accessToken; params.withCredentials = true; } else if (params.headers.Authorization) { params.withCredentials = true; } return params; }
javascript
function(params) { var accessToken = params.accessToken ? params.accessToken : this.driver.config .get(corbel.Iam.IAM_TOKEN, {}).accessToken; if (accessToken && !params.headers.Authorization) { params.headers.Authorization = 'Bearer ' + accessToken; params.withCredentials = true; } else if (params.headers.Authorization) { params.withCredentials = true; } return params; }
[ "function", "(", "params", ")", "{", "var", "accessToken", "=", "params", ".", "accessToken", "?", "params", ".", "accessToken", ":", "this", ".", "driver", ".", "config", ".", "get", "(", "corbel", ".", "Iam", ".", "IAM_TOKEN", ",", "{", "}", ")", ".", "accessToken", ";", "if", "(", "accessToken", "&&", "!", "params", ".", "headers", ".", "Authorization", ")", "{", "params", ".", "headers", ".", "Authorization", "=", "'Bearer '", "+", "accessToken", ";", "params", ".", "withCredentials", "=", "true", ";", "}", "else", "if", "(", "params", ".", "headers", ".", "Authorization", ")", "{", "params", ".", "withCredentials", "=", "true", ";", "}", "return", "params", ";", "}" ]
Add Authorization header with default tokenObject @param {object} params request builded params
[ "Add", "Authorization", "header", "with", "default", "tokenObject" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L2995-L3007
35,703
bq/corbel-js
dist/corbel.with-polyfills.js
function(responseObject) { var location = this._getLocationHeader(responseObject); return location ? location.substr(location.lastIndexOf('/') + 1) : undefined; }
javascript
function(responseObject) { var location = this._getLocationHeader(responseObject); return location ? location.substr(location.lastIndexOf('/') + 1) : undefined; }
[ "function", "(", "responseObject", ")", "{", "var", "location", "=", "this", ".", "_getLocationHeader", "(", "responseObject", ")", ";", "return", "location", "?", "location", ".", "substr", "(", "location", ".", "lastIndexOf", "(", "'/'", ")", "+", "1", ")", ":", "undefined", ";", "}" ]
Extract a id from the location header of a requestXHR @memberof corbel.Services @param {Promise} responseObject response from a requestXHR @return {String} id from the Location
[ "Extract", "a", "id", "from", "the", "location", "header", "of", "a", "requestXHR" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L3161-L3164
35,704
bq/corbel-js
dist/corbel.with-polyfills.js
function(responseObject) { responseObject = responseObject || {}; if (responseObject.xhr) { return responseObject.xhr.getResponseHeader('Location'); } else if (responseObject.response && responseObject.response.headers.location) { return responseObject.response.headers.location; } }
javascript
function(responseObject) { responseObject = responseObject || {}; if (responseObject.xhr) { return responseObject.xhr.getResponseHeader('Location'); } else if (responseObject.response && responseObject.response.headers.location) { return responseObject.response.headers.location; } }
[ "function", "(", "responseObject", ")", "{", "responseObject", "=", "responseObject", "||", "{", "}", ";", "if", "(", "responseObject", ".", "xhr", ")", "{", "return", "responseObject", ".", "xhr", ".", "getResponseHeader", "(", "'Location'", ")", ";", "}", "else", "if", "(", "responseObject", ".", "response", "&&", "responseObject", ".", "response", ".", "headers", ".", "location", ")", "{", "return", "responseObject", ".", "response", ".", "headers", ".", "location", ";", "}", "}" ]
Extracts the location header @param {Promise} responseObject response from a requestXHR @returns {String} location header content @private
[ "Extracts", "the", "location", "header" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L3179-L3187
35,705
bq/corbel-js
dist/corbel.with-polyfills.js
function(client) { console.log('iamInterface.client.create', client); return this.request({ url: this._buildUriWithDomain(this.uri), method: corbel.request.method.POST, data: client }).then(function(res) { return corbel.Services.getLocationId(res); }); }
javascript
function(client) { console.log('iamInterface.client.create', client); return this.request({ url: this._buildUriWithDomain(this.uri), method: corbel.request.method.POST, data: client }).then(function(res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "client", ")", "{", "console", ".", "log", "(", "'iamInterface.client.create'", ",", "client", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "data", ":", "client", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Adds a new client. @method @memberOf corbel.Iam.ClientBuilder @param {Object} client The client data. @param {String} client.id Client id. @param {String} client.name Client domain (obligatory). @param {String} client.key Client key (obligatory). @param {String} client.version Client version. @param {String} client.signatureAlghorithm Signature alghorithm. @param {Object} client.scopes Scopes of the client. @param {String} client.clientSideAuthentication Option for client side authentication. @param {String} client.resetUrl Reset password url. @param {String} client.resetNotificationId Reset password notification id. @return {Promise} A promise with the id of the created client or fails with a {@link corbelError}.
[ "Adds", "a", "new", "client", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L3448-L3457
35,706
bq/corbel-js
dist/corbel.with-polyfills.js
function(client) { console.log('iamInterface.client.update', client); corbel.validate.value('clientId', this.clientId); return this.request({ url: this._buildUriWithDomain(this.uri + '/' + this.clientId), method: corbel.request.method.PUT, data: client }); }
javascript
function(client) { console.log('iamInterface.client.update', client); corbel.validate.value('clientId', this.clientId); return this.request({ url: this._buildUriWithDomain(this.uri + '/' + this.clientId), method: corbel.request.method.PUT, data: client }); }
[ "function", "(", "client", ")", "{", "console", ".", "log", "(", "'iamInterface.client.update'", ",", "client", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'clientId'", ",", "this", ".", "clientId", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", "+", "'/'", "+", "this", ".", "clientId", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "data", ":", "client", "}", ")", ";", "}" ]
Updates a client. @method @memberOf corbel.Iam.ClientBuilder @param {Object} client The client data. @param {String} client.name Client domain (obligatory). @param {String} client.key Client key (obligatory). @param {String} client.version Client version. @param {String} client.signatureAlghorithm Signature alghorithm. @param {Object} client.scopes Scopes of the client. @param {String} client.clientSideAuthentication Option for client side authentication. @param {String} client.resetUrl Reset password url. @param {String} client.resetNotificationId Reset password notification id. @return {Promise} A promise or fails with a {@link corbelError}.
[ "Updates", "a", "client", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L3515-L3523
35,707
bq/corbel-js
dist/corbel.with-polyfills.js
function(domain) { console.log('iamInterface.domain.update', domain); return this.request({ url: this._buildUriWithDomain(this.uri), method: corbel.request.method.PUT, data: domain }); }
javascript
function(domain) { console.log('iamInterface.domain.update', domain); return this.request({ url: this._buildUriWithDomain(this.uri), method: corbel.request.method.PUT, data: domain }); }
[ "function", "(", "domain", ")", "{", "console", ".", "log", "(", "'iamInterface.domain.update'", ",", "domain", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "data", ":", "domain", "}", ")", ";", "}" ]
Updates a domain. @method @memberOf corbel.Iam.DomainBuilder @param {Object} domain The domain data. @param {String} domain.description Description of the domain. @param {String} domain.authUrl Authentication url. @param {String} domain.allowedDomains Allowed domains. @param {String} domain.scopes Scopes of the domain. @param {String} domain.defaultScopes Default copes of the domain. @param {Object} domain.authConfigurations Authentication configuration. @param {Object} domain.userProfileFields User profile fields. @return {Promise} A promise or fails with a {@link corbelError}.
[ "Updates", "a", "domain", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L3657-L3664
35,708
bq/corbel-js
dist/corbel.with-polyfills.js
function(scope) { corbel.validate.failIfIsDefined(this.id, 'This function not allowed scope identifier'); console.log('iamInterface.scope.create', scope); return this.request({ url: this._buildUriWithDomain(this.uri), method: corbel.request.method.POST, data: scope }).then(function(res) { return corbel.Services.getLocationId(res); }); }
javascript
function(scope) { corbel.validate.failIfIsDefined(this.id, 'This function not allowed scope identifier'); console.log('iamInterface.scope.create', scope); return this.request({ url: this._buildUriWithDomain(this.uri), method: corbel.request.method.POST, data: scope }).then(function(res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "scope", ")", "{", "corbel", ".", "validate", ".", "failIfIsDefined", "(", "this", ".", "id", ",", "'This function not allowed scope identifier'", ")", ";", "console", ".", "log", "(", "'iamInterface.scope.create'", ",", "scope", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "POST", ",", "data", ":", "scope", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
Creates a new scope. @method @memberOf corbel.Iam.ScopeBuilder @param {Object} scope The scope. @param {Object} scope.rules Scope rules. @param {String} scope.type Scope type. @param {Object} scope.scopes Scopes for a composite scope. @return {Promise} A promise with the id of the created scope or fails with a {@link corbelError}.
[ "Creates", "a", "new", "scope", "." ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L3732-L3742
35,709
bq/corbel-js
dist/corbel.with-polyfills.js
function(params) { params = params || {}; params.claims = params.claims || {}; if (params.jwt) { return params.jwt; } var secret = params.secret || this.driver.config.get('clientSecret'); params.claims.iss = params.claims.iss || this.driver.config.get('clientId'); params.claims.aud = params.claims.aud || this.driver.config.get('audience', corbel.Iam.AUD); params.claims.scope = params.claims.scope || this.driver.config.get('scopes', ''); return corbel.jwt.generate(params.claims, secret); }
javascript
function(params) { params = params || {}; params.claims = params.claims || {}; if (params.jwt) { return params.jwt; } var secret = params.secret || this.driver.config.get('clientSecret'); params.claims.iss = params.claims.iss || this.driver.config.get('clientId'); params.claims.aud = params.claims.aud || this.driver.config.get('audience', corbel.Iam.AUD); params.claims.scope = params.claims.scope || this.driver.config.get('scopes', ''); return corbel.jwt.generate(params.claims, secret); }
[ "function", "(", "params", ")", "{", "params", "=", "params", "||", "{", "}", ";", "params", ".", "claims", "=", "params", ".", "claims", "||", "{", "}", ";", "if", "(", "params", ".", "jwt", ")", "{", "return", "params", ".", "jwt", ";", "}", "var", "secret", "=", "params", ".", "secret", "||", "this", ".", "driver", ".", "config", ".", "get", "(", "'clientSecret'", ")", ";", "params", ".", "claims", ".", "iss", "=", "params", ".", "claims", ".", "iss", "||", "this", ".", "driver", ".", "config", ".", "get", "(", "'clientId'", ")", ";", "params", ".", "claims", ".", "aud", "=", "params", ".", "claims", ".", "aud", "||", "this", ".", "driver", ".", "config", ".", "get", "(", "'audience'", ",", "corbel", ".", "Iam", ".", "AUD", ")", ";", "params", ".", "claims", ".", "scope", "=", "params", ".", "claims", ".", "scope", "||", "this", ".", "driver", ".", "config", ".", "get", "(", "'scopes'", ",", "''", ")", ";", "return", "corbel", ".", "jwt", ".", "generate", "(", "params", ".", "claims", ",", "secret", ")", ";", "}" ]
Build a JWT with default driver config @param {Object} params @param {String} [params.secret] @param {Object} [params.claims] @param {String} [params.claims.iss] @param {String} [params.claims.aud] @param {String} [params.claims.scope] @return {String} JWT assertion
[ "Build", "a", "JWT", "with", "default", "driver", "config" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L3818-L3831
35,710
bq/corbel-js
dist/corbel.with-polyfills.js
function(refreshToken, scopes) { // console.log('iamInterface.token.refresh', refreshToken); // we need refresh token to refresh access token corbel.validate.isValue(refreshToken, 'Refresh access token request must contains refresh token'); // we need create default claims to refresh access token var params = { claims: { 'scope': scopes, 'refresh_token': refreshToken } }; var that = this; try { return this._doPostTokenRequest(this.uri, params) .then(function(response) { that.driver.config.set(corbel.Iam.IAM_TOKEN, response.data); return response; }); } catch (e) { console.log('error', e); return Promise.reject(e); } }
javascript
function(refreshToken, scopes) { // console.log('iamInterface.token.refresh', refreshToken); // we need refresh token to refresh access token corbel.validate.isValue(refreshToken, 'Refresh access token request must contains refresh token'); // we need create default claims to refresh access token var params = { claims: { 'scope': scopes, 'refresh_token': refreshToken } }; var that = this; try { return this._doPostTokenRequest(this.uri, params) .then(function(response) { that.driver.config.set(corbel.Iam.IAM_TOKEN, response.data); return response; }); } catch (e) { console.log('error', e); return Promise.reject(e); } }
[ "function", "(", "refreshToken", ",", "scopes", ")", "{", "// console.log('iamInterface.token.refresh', refreshToken);", "// we need refresh token to refresh access token", "corbel", ".", "validate", ".", "isValue", "(", "refreshToken", ",", "'Refresh access token request must contains refresh token'", ")", ";", "// we need create default claims to refresh access token", "var", "params", "=", "{", "claims", ":", "{", "'scope'", ":", "scopes", ",", "'refresh_token'", ":", "refreshToken", "}", "}", ";", "var", "that", "=", "this", ";", "try", "{", "return", "this", ".", "_doPostTokenRequest", "(", "this", ".", "uri", ",", "params", ")", ".", "then", "(", "function", "(", "response", ")", "{", "that", ".", "driver", ".", "config", ".", "set", "(", "corbel", ".", "Iam", ".", "IAM_TOKEN", ",", "response", ".", "data", ")", ";", "return", "response", ";", "}", ")", ";", "}", "catch", "(", "e", ")", "{", "console", ".", "log", "(", "'error'", ",", "e", ")", ";", "return", "Promise", ".", "reject", "(", "e", ")", ";", "}", "}" ]
Refresh a token to connect with iam @method @memberOf corbel.Iam.TokenBuilder @param {String} [refresh_token] Token to refresh an AccessToken @param {String} [scopes] Scopes to the AccessToken @return {Promise} Q promise that resolves to an AccesToken {Object} or rejects with a {@link corbelError}
[ "Refresh", "a", "token", "to", "connect", "with", "iam" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L3934-L3957
35,711
bq/corbel-js
dist/corbel.with-polyfills.js
function() { console.log('iamInterface.user.get'); corbel.validate.value('id', this.id); return this._getUser(corbel.request.method.GET, this.uri, this.id); }
javascript
function() { console.log('iamInterface.user.get'); corbel.validate.value('id', this.id); return this._getUser(corbel.request.method.GET, this.uri, this.id); }
[ "function", "(", ")", "{", "console", ".", "log", "(", "'iamInterface.user.get'", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'id'", ",", "this", ".", "id", ")", ";", "return", "this", ".", "_getUser", "(", "corbel", ".", "request", ".", "method", ".", "GET", ",", "this", ".", "uri", ",", "this", ".", "id", ")", ";", "}" ]
Gets the user @method @memberOf corbel.Iam.UserBuilder @return {Promise} Q promise that resolves to a User {Object} or rejects with a {@link corbelError}
[ "Gets", "the", "user" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L4102-L4106
35,712
bq/corbel-js
dist/corbel.with-polyfills.js
function(data, options) { console.log('iamInterface.user.update', data); corbel.validate.value('id', this.id); var args = corbel.utils.extend(options || {}, { url: this._buildUriWithDomain(this.uri, this.id), method: corbel.request.method.PUT, data: data }); return this.request(args); }
javascript
function(data, options) { console.log('iamInterface.user.update', data); corbel.validate.value('id', this.id); var args = corbel.utils.extend(options || {}, { url: this._buildUriWithDomain(this.uri, this.id), method: corbel.request.method.PUT, data: data }); return this.request(args); }
[ "function", "(", "data", ",", "options", ")", "{", "console", ".", "log", "(", "'iamInterface.user.update'", ",", "data", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'id'", ",", "this", ".", "id", ")", ";", "var", "args", "=", "corbel", ".", "utils", ".", "extend", "(", "options", "||", "{", "}", ",", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", ",", "this", ".", "id", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "data", ":", "data", "}", ")", ";", "return", "this", ".", "request", "(", "args", ")", ";", "}" ]
Updates the user @method @memberOf corbel.Iam.UserBuilder @param {Object} options Request options (e.g accessToken) - Optional @return {Promise} Q promise that resolves to undefined (void) or rejects with a {@link corbelError}
[ "Updates", "the", "user" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L4115-L4124
35,713
bq/corbel-js
dist/corbel.with-polyfills.js
function(options) { var queryParams = ''; if (options && options.avoidNotification) { queryParams = '?avoidnotification=true'; } console.log('iamInterface.user.delete'); corbel.validate.value('id', this.id); return this.request({ url: this._buildUriWithDomain(this.uri, this.id) + queryParams, method: corbel.request.method.DELETE }); }
javascript
function(options) { var queryParams = ''; if (options && options.avoidNotification) { queryParams = '?avoidnotification=true'; } console.log('iamInterface.user.delete'); corbel.validate.value('id', this.id); return this.request({ url: this._buildUriWithDomain(this.uri, this.id) + queryParams, method: corbel.request.method.DELETE }); }
[ "function", "(", "options", ")", "{", "var", "queryParams", "=", "''", ";", "if", "(", "options", "&&", "options", ".", "avoidNotification", ")", "{", "queryParams", "=", "'?avoidnotification=true'", ";", "}", "console", ".", "log", "(", "'iamInterface.user.delete'", ")", ";", "corbel", ".", "validate", ".", "value", "(", "'id'", ",", "this", ".", "id", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", ",", "this", ".", "id", ")", "+", "queryParams", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "DELETE", "}", ")", ";", "}" ]
Deletes the user @method @memberOf corbel.Iam.UserBuilder @return {Promise} Q promise that resolves to undefined (void) or rejects with a {@link corbelError}
[ "Deletes", "the", "user" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L4132-L4143
35,714
bq/corbel-js
dist/corbel.with-polyfills.js
function(deviceId, data) { console.log('iamInterface.user.registerDevice'); corbel.validate.values(['id', 'deviceId'], { 'id': this.id, 'deviceId': deviceId }); return this.request({ url: this._buildUriWithDomain(this.uri, this.id) + '/device/' + deviceId, method: corbel.request.method.PUT, data: data }).then(function(res) { return corbel.Services.getLocationId(res); }); }
javascript
function(deviceId, data) { console.log('iamInterface.user.registerDevice'); corbel.validate.values(['id', 'deviceId'], { 'id': this.id, 'deviceId': deviceId }); return this.request({ url: this._buildUriWithDomain(this.uri, this.id) + '/device/' + deviceId, method: corbel.request.method.PUT, data: data }).then(function(res) { return corbel.Services.getLocationId(res); }); }
[ "function", "(", "deviceId", ",", "data", ")", "{", "console", ".", "log", "(", "'iamInterface.user.registerDevice'", ")", ";", "corbel", ".", "validate", ".", "values", "(", "[", "'id'", ",", "'deviceId'", "]", ",", "{", "'id'", ":", "this", ".", "id", ",", "'deviceId'", ":", "deviceId", "}", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", ",", "this", ".", "id", ")", "+", "'/device/'", "+", "deviceId", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "PUT", ",", "data", ":", "data", "}", ")", ".", "then", "(", "function", "(", "res", ")", "{", "return", "corbel", ".", "Services", ".", "getLocationId", "(", "res", ")", ";", "}", ")", ";", "}" ]
User device register @method @memberOf corbel.Iam.UserBuilder @param {string} deviceId The device id @param {Object} data The device data @param {Object} data.URI The device token @param {Object} data.name The device name @param {Object} data.type The device type (ANDROID, APPLE, WEB) @return {Promise} Q promise that resolves to a User {Object} or rejects with a {@link corbelError}
[ "User", "device", "register" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L4254-L4267
35,715
bq/corbel-js
dist/corbel.with-polyfills.js
function(group) { console.log('iamInterface.user.deleteGroup'); corbel.validate.values(['id', 'group'], { 'id': this.id, 'group': group }); return this.request({ url: this._buildUriWithDomain(this.uri, this.id) + '/group/' + group, method: corbel.request.method.DELETE }); }
javascript
function(group) { console.log('iamInterface.user.deleteGroup'); corbel.validate.values(['id', 'group'], { 'id': this.id, 'group': group }); return this.request({ url: this._buildUriWithDomain(this.uri, this.id) + '/group/' + group, method: corbel.request.method.DELETE }); }
[ "function", "(", "group", ")", "{", "console", ".", "log", "(", "'iamInterface.user.deleteGroup'", ")", ";", "corbel", ".", "validate", ".", "values", "(", "[", "'id'", ",", "'group'", "]", ",", "{", "'id'", ":", "this", ".", "id", ",", "'group'", ":", "group", "}", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUriWithDomain", "(", "this", ".", "uri", ",", "this", ".", "id", ")", "+", "'/group/'", "+", "group", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "DELETE", "}", ")", ";", "}" ]
Delete group to user @method @memberOf iam.UserBuilder @param {Object} groups The data of the groups @return {Promise} Q promise that resolves to undefined (void) or rejects with a {@link SilkRoadError}
[ "Delete", "group", "to", "user" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/dist/corbel.with-polyfills.js#L4362-L4372
35,716
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
35,717
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
35,718
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
35,719
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
35,720
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
35,721
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
35,722
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
35,723
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
35,724
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
35,725
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
35,726
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", ";", "// 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", ";", "}", "}", ")", ";", "}" ]
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
35,727
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
35,728
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
35,729
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
35,730
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
35,731
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
35,732
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
35,733
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
35,734
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
35,735
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
35,736
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
35,737
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
35,738
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
35,739
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
35,740
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
35,741
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
35,742
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
35,743
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
35,744
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
35,745
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
35,746
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
35,747
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", ")", "{", "// no known ext, add .js", "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
35,748
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", "=>", "{", "// 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", "(", "`", "${", "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", "}", "`", ")", ";", "// eslint-disable-line no-console", "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
35,749
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", ")", ";", "// 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", "(", "`", "${", "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
35,750
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", ")", ";", "// 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", "(", "`", "${", "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
35,751
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", ";", "// 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", "]", ";", "}" ]
return a promise
[ "return", "a", "promise" ]
e585f483624717ff64ff16dbf6eb3e2bd4d80273
https://github.com/dumberjs/dumber-module-loader/blob/e585f483624717ff64ff16dbf6eb3e2bd4d80273/src/index.js#L380-L447
35,752
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", ")", "{", "// 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", ")", ";", "}", "}" ]
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
35,753
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
35,754
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", ",", "/*importObject*/", ")", ")", ".", "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
35,755
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
35,756
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
35,757
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", ";", "// 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'", ")", ";", "}", "}", "}" ]
Validate component definition
[ "Validate", "component", "definition" ]
b68f0a8f7b495a51d51b9a438a5bb1516608b359
https://github.com/taskcluster/taskcluster-lib-loader/blob/b68f0a8f7b495a51d51b9a438a5bb1516608b359/src/loader.js#L16-L36
35,758
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
35,759
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", "]", ";", "// 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", "(", "`", "${", "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
35,760
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
35,761
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
35,762
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", ")", ";", "// sync", "// sync", "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
35,763
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_", ")", "{", "// 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", ";", "}" ]
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
35,764
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
35,765
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
35,766
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
35,767
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
35,768
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
35,769
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
35,770
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
35,771
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
35,772
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
35,773
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
35,774
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
35,775
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
35,776
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
35,777
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", ")", ";", "// 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", ";", "}" ]
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
35,778
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", "(", ")", ";", "}", "}", "/**\n * lets run a test for writes\n */", "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
35,779
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$'", ";", "// 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", ";", "}" ]
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
35,780
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
35,781
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", ")", ";", "// 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", ";", "}" ]
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
35,782
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", ";", "// **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", ";", "}", ")", ";", "}", ")", ";", "}" ]
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
35,783
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 = 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", "}", ";", "}" ]
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
35,784
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", ";", "// the default value", "// since this element is immutable the value must be read-only", "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
35,785
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", ")", "{", "/**\n * The name of the column, can be any type, for composites use Array\n */", "this", ".", "name", "=", "name", ";", "/**\n * The value of the column\n */", "this", ".", "value", "=", "value", ";", "/**\n * The timestamp of the value\n * @default {Date} new Date();\n */", "this", ".", "timestamp", "=", "timestamp", "||", "new", "Date", "(", ")", ";", "/**\n * The ttl for the column\n */", "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
35,786
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
35,787
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
35,788
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
35,789
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
35,790
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
35,791
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", ";", "// 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", ";", "}" ]
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
35,792
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", ")", ":", "// 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", ")", ";", "}", "}" ]
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
35,793
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", "++", ")", "{", "/*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", ";", "}" ]
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
35,794
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", ";", "// 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", "(", ")", ";", "}", ";", "}" ]
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
35,795
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", "]", ";", "// 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", ";", "}" ]
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
35,796
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", ";", "// 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", ";", "}" ]
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
35,797
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", ";", "}", "}", "/*global console*/", "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
35,798
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", ")", ";", "// 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", ";", "}" ]
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
35,799
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