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
9,000
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
DocumentTransform
function DocumentTransform(properties) { this.fieldTransforms = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function DocumentTransform(properties) { this.fieldTransforms = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "DocumentTransform", "(", "properties", ")", "{", "this", ".", "fieldTransforms", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i...
Properties of a DocumentTransform. @memberof google.firestore.v1 @interface IDocumentTransform @property {string|null} [document] DocumentTransform document @property {Array.<google.firestore.v1.DocumentTransform.IFieldTransform>|null} [fieldTransforms] DocumentTransform fieldTransforms Constructs a new DocumentTransform. @memberof google.firestore.v1 @classdesc Represents a DocumentTransform. @implements IDocumentTransform @constructor @param {google.firestore.v1.IDocumentTransform=} [properties] Properties to set
[ "Properties", "of", "a", "DocumentTransform", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L5860-L5866
9,001
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
FieldTransform
function FieldTransform(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function FieldTransform(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "FieldTransform", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", ...
Properties of a FieldTransform. @memberof google.firestore.v1.DocumentTransform @interface IFieldTransform @property {string|null} [fieldPath] FieldTransform fieldPath @property {google.firestore.v1.DocumentTransform.FieldTransform.ServerValue|null} [setToServerValue] FieldTransform setToServerValue @property {google.firestore.v1.IValue|null} [increment] FieldTransform increment @property {google.firestore.v1.IValue|null} [maximum] FieldTransform maximum @property {google.firestore.v1.IValue|null} [minimum] FieldTransform minimum @property {google.firestore.v1.IArrayValue|null} [appendMissingElements] FieldTransform appendMissingElements @property {google.firestore.v1.IArrayValue|null} [removeAllFromArray] FieldTransform removeAllFromArray Constructs a new FieldTransform. @memberof google.firestore.v1.DocumentTransform @classdesc Represents a FieldTransform. @implements IFieldTransform @constructor @param {google.firestore.v1.DocumentTransform.IFieldTransform=} [properties] Properties to set
[ "Properties", "of", "a", "FieldTransform", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L5907-L5912
9,002
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
WriteResult
function WriteResult(properties) { this.transformResults = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function WriteResult(properties) { this.transformResults = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "WriteResult", "(", "properties", ")", "{", "this", ".", "transformResults", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", ...
Properties of a WriteResult. @memberof google.firestore.v1 @interface IWriteResult @property {google.protobuf.ITimestamp|null} [updateTime] WriteResult updateTime @property {Array.<google.firestore.v1.IValue>|null} [transformResults] WriteResult transformResults Constructs a new WriteResult. @memberof google.firestore.v1 @classdesc Represents a WriteResult. @implements IWriteResult @constructor @param {google.firestore.v1.IWriteResult=} [properties] Properties to set
[ "Properties", "of", "a", "WriteResult", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6022-L6028
9,003
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
DocumentChange
function DocumentChange(properties) { this.targetIds = []; this.removedTargetIds = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function DocumentChange(properties) { this.targetIds = []; this.removedTargetIds = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "DocumentChange", "(", "properties", ")", "{", "this", ".", "targetIds", "=", "[", "]", ";", "this", ".", "removedTargetIds", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "p...
Properties of a DocumentChange. @memberof google.firestore.v1 @interface IDocumentChange @property {google.firestore.v1.IDocument|null} [document] DocumentChange document @property {Array.<number>|null} [targetIds] DocumentChange targetIds @property {Array.<number>|null} [removedTargetIds] DocumentChange removedTargetIds Constructs a new DocumentChange. @memberof google.firestore.v1 @classdesc Represents a DocumentChange. @implements IDocumentChange @constructor @param {google.firestore.v1.IDocumentChange=} [properties] Properties to set
[ "Properties", "of", "a", "DocumentChange", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6068-L6075
9,004
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
DocumentDelete
function DocumentDelete(properties) { this.removedTargetIds = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function DocumentDelete(properties) { this.removedTargetIds = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "DocumentDelete", "(", "properties", ")", "{", "this", ".", "removedTargetIds", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i",...
Properties of a DocumentDelete. @memberof google.firestore.v1 @interface IDocumentDelete @property {string|null} [document] DocumentDelete document @property {Array.<number>|null} [removedTargetIds] DocumentDelete removedTargetIds @property {google.protobuf.ITimestamp|null} [readTime] DocumentDelete readTime Constructs a new DocumentDelete. @memberof google.firestore.v1 @classdesc Represents a DocumentDelete. @implements IDocumentDelete @constructor @param {google.firestore.v1.IDocumentDelete=} [properties] Properties to set
[ "Properties", "of", "a", "DocumentDelete", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6123-L6129
9,005
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
DocumentRemove
function DocumentRemove(properties) { this.removedTargetIds = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function DocumentRemove(properties) { this.removedTargetIds = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "DocumentRemove", "(", "properties", ")", "{", "this", ".", "removedTargetIds", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i",...
Properties of a DocumentRemove. @memberof google.firestore.v1 @interface IDocumentRemove @property {string|null} [document] DocumentRemove document @property {Array.<number>|null} [removedTargetIds] DocumentRemove removedTargetIds @property {google.protobuf.ITimestamp|null} [readTime] DocumentRemove readTime Constructs a new DocumentRemove. @memberof google.firestore.v1 @classdesc Represents a DocumentRemove. @implements IDocumentRemove @constructor @param {google.firestore.v1.IDocumentRemove=} [properties] Properties to set
[ "Properties", "of", "a", "DocumentRemove", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6177-L6183
9,006
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
ExistenceFilter
function ExistenceFilter(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function ExistenceFilter(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "ExistenceFilter", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", ...
Properties of an ExistenceFilter. @memberof google.firestore.v1 @interface IExistenceFilter @property {number|null} [targetId] ExistenceFilter targetId @property {number|null} [count] ExistenceFilter count Constructs a new ExistenceFilter. @memberof google.firestore.v1 @classdesc Represents an ExistenceFilter. @implements IExistenceFilter @constructor @param {google.firestore.v1.IExistenceFilter=} [properties] Properties to set
[ "Properties", "of", "an", "ExistenceFilter", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6230-L6235
9,007
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
Http
function Http(properties) { this.rules = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function Http(properties) { this.rules = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "Http", "(", "properties", ")", "{", "this", ".", "rules", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", "...
Properties of a Http. @memberof google.api @interface IHttp @property {Array.<google.api.IHttpRule>|null} [rules] Http rules Constructs a new Http. @memberof google.api @classdesc Represents a Http. @implements IHttp @constructor @param {google.api.IHttp=} [properties] Properties to set
[ "Properties", "of", "a", "Http", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6288-L6294
9,008
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
HttpRule
function HttpRule(properties) { this.additionalBindings = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function HttpRule(properties) { this.additionalBindings = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "HttpRule", "(", "properties", ")", "{", "this", ".", "additionalBindings", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "...
Properties of a HttpRule. @memberof google.api @interface IHttpRule @property {string|null} [get] HttpRule get @property {string|null} [put] HttpRule put @property {string|null} [post] HttpRule post @property {string|null} ["delete"] HttpRule delete @property {string|null} [patch] HttpRule patch @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom @property {string|null} [selector] HttpRule selector @property {string|null} [body] HttpRule body @property {Array.<google.api.IHttpRule>|null} [additionalBindings] HttpRule additionalBindings Constructs a new HttpRule. @memberof google.api @classdesc Represents a HttpRule. @implements IHttpRule @constructor @param {google.api.IHttpRule=} [properties] Properties to set
[ "Properties", "of", "a", "HttpRule", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6332-L6338
9,009
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
CustomHttpPattern
function CustomHttpPattern(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function CustomHttpPattern(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "CustomHttpPattern", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")"...
Properties of a CustomHttpPattern. @memberof google.api @interface ICustomHttpPattern @property {string|null} [kind] CustomHttpPattern kind @property {string|null} [path] CustomHttpPattern path Constructs a new CustomHttpPattern. @memberof google.api @classdesc Represents a CustomHttpPattern. @implements ICustomHttpPattern @constructor @param {google.api.ICustomHttpPattern=} [properties] Properties to set
[ "Properties", "of", "a", "CustomHttpPattern", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6447-L6452
9,010
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
LatLng
function LatLng(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function LatLng(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "LatLng", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", "if", ...
Properties of a LatLng. @memberof google.type @interface ILatLng @property {number|null} [latitude] LatLng latitude @property {number|null} [longitude] LatLng longitude Constructs a new LatLng. @memberof google.type @classdesc Represents a LatLng. @implements ILatLng @constructor @param {google.type.ILatLng=} [properties] Properties to set
[ "Properties", "of", "a", "LatLng", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6503-L6508
9,011
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
Status
function Status(properties) { this.details = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function Status(properties) { this.details = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "Status", "(", "properties", ")", "{", "this", ".", "details", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys",...
Properties of a Status. @memberof google.rpc @interface IStatus @property {number|null} [code] Status code @property {string|null} [message] Status message @property {Array.<google.protobuf.IAny>|null} [details] Status details Constructs a new Status. @memberof google.rpc @classdesc Represents a Status. @implements IStatus @constructor @param {google.rpc.IStatus=} [properties] Properties to set
[ "Properties", "of", "a", "Status", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6560-L6566
9,012
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
Operation
function Operation(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function Operation(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "Operation", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", "if"...
Properties of an Operation. @memberof google.longrunning @interface IOperation @property {string|null} [name] Operation name @property {google.protobuf.IAny|null} [metadata] Operation metadata @property {boolean|null} [done] Operation done @property {google.rpc.IStatus|null} [error] Operation error @property {google.protobuf.IAny|null} [response] Operation response Constructs a new Operation. @memberof google.longrunning @classdesc Represents an Operation. @implements IOperation @constructor @param {google.longrunning.IOperation=} [properties] Properties to set
[ "Properties", "of", "an", "Operation", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6814-L6819
9,013
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
GetOperationRequest
function GetOperationRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function GetOperationRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "GetOperationRequest", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", "...
Properties of a GetOperationRequest. @memberof google.longrunning @interface IGetOperationRequest @property {string|null} [name] GetOperationRequest name Constructs a new GetOperationRequest. @memberof google.longrunning @classdesc Represents a GetOperationRequest. @implements IGetOperationRequest @constructor @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set
[ "Properties", "of", "a", "GetOperationRequest", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6895-L6900
9,014
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
ListOperationsRequest
function ListOperationsRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function ListOperationsRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "ListOperationsRequest", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ...
Properties of a ListOperationsRequest. @memberof google.longrunning @interface IListOperationsRequest @property {string|null} [name] ListOperationsRequest name @property {string|null} [filter] ListOperationsRequest filter @property {number|null} [pageSize] ListOperationsRequest pageSize @property {string|null} [pageToken] ListOperationsRequest pageToken Constructs a new ListOperationsRequest. @memberof google.longrunning @classdesc Represents a ListOperationsRequest. @implements IListOperationsRequest @constructor @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set
[ "Properties", "of", "a", "ListOperationsRequest", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6933-L6938
9,015
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
ListOperationsResponse
function ListOperationsResponse(properties) { this.operations = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function ListOperationsResponse(properties) { this.operations = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "ListOperationsResponse", "(", "properties", ")", "{", "this", ".", "operations", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i...
Properties of a ListOperationsResponse. @memberof google.longrunning @interface IListOperationsResponse @property {Array.<google.longrunning.IOperation>|null} [operations] ListOperationsResponse operations @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken Constructs a new ListOperationsResponse. @memberof google.longrunning @classdesc Represents a ListOperationsResponse. @implements IListOperationsResponse @constructor @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set
[ "Properties", "of", "a", "ListOperationsResponse", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L6993-L6999
9,016
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
CancelOperationRequest
function CancelOperationRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function CancelOperationRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "CancelOperationRequest", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ...
Properties of a CancelOperationRequest. @memberof google.longrunning @interface ICancelOperationRequest @property {string|null} [name] CancelOperationRequest name Constructs a new CancelOperationRequest. @memberof google.longrunning @classdesc Represents a CancelOperationRequest. @implements ICancelOperationRequest @constructor @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set
[ "Properties", "of", "a", "CancelOperationRequest", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L7037-L7042
9,017
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
DeleteOperationRequest
function DeleteOperationRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function DeleteOperationRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "DeleteOperationRequest", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ...
Properties of a DeleteOperationRequest. @memberof google.longrunning @interface IDeleteOperationRequest @property {string|null} [name] DeleteOperationRequest name Constructs a new DeleteOperationRequest. @memberof google.longrunning @classdesc Represents a DeleteOperationRequest. @implements IDeleteOperationRequest @constructor @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set
[ "Properties", "of", "a", "DeleteOperationRequest", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L7072-L7077
9,018
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
WaitOperationRequest
function WaitOperationRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function WaitOperationRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "WaitOperationRequest", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ...
Properties of a WaitOperationRequest. @memberof google.longrunning @interface IWaitOperationRequest @property {string|null} [name] WaitOperationRequest name @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout Constructs a new WaitOperationRequest. @memberof google.longrunning @classdesc Represents a WaitOperationRequest. @implements IWaitOperationRequest @constructor @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set
[ "Properties", "of", "a", "WaitOperationRequest", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L7108-L7113
9,019
googleapis/nodejs-firestore
dev/protos/firestore_proto_api.js
OperationInfo
function OperationInfo(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function OperationInfo(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "OperationInfo", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", ...
Properties of an OperationInfo. @memberof google.longrunning @interface IOperationInfo @property {string|null} [responseType] OperationInfo responseType @property {string|null} [metadataType] OperationInfo metadataType Constructs a new OperationInfo. @memberof google.longrunning @classdesc Represents an OperationInfo. @implements IOperationInfo @constructor @param {google.longrunning.IOperationInfo=} [properties] Properties to set
[ "Properties", "of", "an", "OperationInfo", "." ]
c1192504e2d2ebe505aaf952227f377017f43bdc
https://github.com/googleapis/nodejs-firestore/blob/c1192504e2d2ebe505aaf952227f377017f43bdc/dev/protos/firestore_proto_api.js#L7152-L7157
9,020
mapbox/mapbox-gl-leaflet
leaflet-mapbox-gl.js
function (fn, time, context) { var lock, args, wrapperFn, later; later = function () { // reset lock and call if queued lock = false; if (args) { wrapperFn.apply(context, args); args = false; } }; wrapperFn = function () { if (lock) { // called too soon, queue to call later args = arguments; } else { // call and lock until later fn.apply(context, arguments); setTimeout(later, time); lock = true; } }; return wrapperFn; }
javascript
function (fn, time, context) { var lock, args, wrapperFn, later; later = function () { // reset lock and call if queued lock = false; if (args) { wrapperFn.apply(context, args); args = false; } }; wrapperFn = function () { if (lock) { // called too soon, queue to call later args = arguments; } else { // call and lock until later fn.apply(context, arguments); setTimeout(later, time); lock = true; } }; return wrapperFn; }
[ "function", "(", "fn", ",", "time", ",", "context", ")", "{", "var", "lock", ",", "args", ",", "wrapperFn", ",", "later", ";", "later", "=", "function", "(", ")", "{", "// reset lock and call if queued", "lock", "=", "false", ";", "if", "(", "args", ")...
Create a version of `fn` that only fires once every `time` millseconds. @param {Function} fn the function to be throttled @param {number} time millseconds required between function calls @param {*} context the value of `this` with which the function is called @returns {Function} debounced function @private
[ "Create", "a", "version", "of", "fn", "that", "only", "fires", "once", "every", "time", "millseconds", "." ]
8920b4b7c30682bec372581b878e21ec4edd4d33
https://github.com/mapbox/mapbox-gl-leaflet/blob/8920b4b7c30682bec372581b878e21ec4edd4d33/leaflet-mapbox-gl.js#L36-L62
9,021
kelvinhokk/cordova-plugin-localization-strings
scripts/create_android_strings.js
processResult
function processResult(context, lang, langJson, stringXmlJson) { var path = require('path'); var q = require('q'); var deferred = q.defer(); var mapObj = {}; // create a map to the actual string _.forEach(stringXmlJson.resources.string, function (val) { if (_.has(val, "$") && _.has(val["$"], "name")) { mapObj[val["$"].name] = val; } }); var langJsonToProcess = _.assignIn(langJson.config_android, langJson.app, langJson.app_android); //now iterate through langJsonToProcess _.forEach(langJsonToProcess, function (val, key) { // positional string format is in Mac OS X format. change to android format val = val.replace(/\$@/gi, "$s"); val = val.replace(/\'/gi, "\\'"); if (_.has(mapObj, key)) { // mapObj contains key. replace key mapObj[key]["_"] = val; } else { // add by inserting stringXmlJson.resources.string.push({ _: val, '$': {name: key} }); } }); //save to disk var langDir = getLocalizationDir(context, lang); var filePath = getLocalStringXmlPath(context, lang); fs.ensureDir(langDir, function (err) { if (err) { throw err; } fs.writeFile(filePath, buildXML(stringXmlJson), {encoding: 'utf8'}, function (err) { if (err) throw err; console.log('Saved:' + filePath); return deferred.resolve(); }); }); function buildXML(obj) { var builder = new xml2js.Builder(); builder.options.renderOpts.indent = '\t'; var x = builder.buildObject(obj); return x.toString(); } return deferred.promise; }
javascript
function processResult(context, lang, langJson, stringXmlJson) { var path = require('path'); var q = require('q'); var deferred = q.defer(); var mapObj = {}; // create a map to the actual string _.forEach(stringXmlJson.resources.string, function (val) { if (_.has(val, "$") && _.has(val["$"], "name")) { mapObj[val["$"].name] = val; } }); var langJsonToProcess = _.assignIn(langJson.config_android, langJson.app, langJson.app_android); //now iterate through langJsonToProcess _.forEach(langJsonToProcess, function (val, key) { // positional string format is in Mac OS X format. change to android format val = val.replace(/\$@/gi, "$s"); val = val.replace(/\'/gi, "\\'"); if (_.has(mapObj, key)) { // mapObj contains key. replace key mapObj[key]["_"] = val; } else { // add by inserting stringXmlJson.resources.string.push({ _: val, '$': {name: key} }); } }); //save to disk var langDir = getLocalizationDir(context, lang); var filePath = getLocalStringXmlPath(context, lang); fs.ensureDir(langDir, function (err) { if (err) { throw err; } fs.writeFile(filePath, buildXML(stringXmlJson), {encoding: 'utf8'}, function (err) { if (err) throw err; console.log('Saved:' + filePath); return deferred.resolve(); }); }); function buildXML(obj) { var builder = new xml2js.Builder(); builder.options.renderOpts.indent = '\t'; var x = builder.buildObject(obj); return x.toString(); } return deferred.promise; }
[ "function", "processResult", "(", "context", ",", "lang", ",", "langJson", ",", "stringXmlJson", ")", "{", "var", "path", "=", "require", "(", "'path'", ")", ";", "var", "q", "=", "require", "(", "'q'", ")", ";", "var", "deferred", "=", "q", ".", "de...
process the modified xml and put write to file
[ "process", "the", "modified", "xml", "and", "put", "write", "to", "file" ]
c545daf8142e871fbcb311fdf2ad27ce5c94aadf
https://github.com/kelvinhokk/cordova-plugin-localization-strings/blob/c545daf8142e871fbcb311fdf2ad27ce5c94aadf/scripts/create_android_strings.js#L202-L260
9,022
99xt/serverless-dynamodb-local
src/seeder.js
writeSeedBatch
function writeSeedBatch(dynamodbWriteFunction, tableName, seeds) { const params = { RequestItems: { [tableName]: seeds.map((seed) => ({ PutRequest: { Item: seed, }, })), }, }; return new BbPromise((resolve, reject) => { // interval lets us know how much time we have burnt so far. This lets us have a backoff mechanism to try // again a few times in case the Database resources are in the middle of provisioning. let interval = 0; function execute(interval) { setTimeout(() => dynamodbWriteFunction(params, (err) => { if (err) { if (err.code === "ResourceNotFoundException" && interval <= 5000) { execute(interval + 1000); } else { reject(err); } } else { resolve(); } }), interval); } execute(interval); }); }
javascript
function writeSeedBatch(dynamodbWriteFunction, tableName, seeds) { const params = { RequestItems: { [tableName]: seeds.map((seed) => ({ PutRequest: { Item: seed, }, })), }, }; return new BbPromise((resolve, reject) => { // interval lets us know how much time we have burnt so far. This lets us have a backoff mechanism to try // again a few times in case the Database resources are in the middle of provisioning. let interval = 0; function execute(interval) { setTimeout(() => dynamodbWriteFunction(params, (err) => { if (err) { if (err.code === "ResourceNotFoundException" && interval <= 5000) { execute(interval + 1000); } else { reject(err); } } else { resolve(); } }), interval); } execute(interval); }); }
[ "function", "writeSeedBatch", "(", "dynamodbWriteFunction", ",", "tableName", ",", "seeds", ")", "{", "const", "params", "=", "{", "RequestItems", ":", "{", "[", "tableName", "]", ":", "seeds", ".", "map", "(", "(", "seed", ")", "=>", "(", "{", "PutReque...
Writes a batch chunk of migration seeds to DynamoDB. DynamoDB has a limit on the number of items that may be written in a batch operation. @param {function} dynamodbWriteFunction The DynamoDB DocumentClient.batchWrite or DynamoDB.batchWriteItem function @param {string} tableName The table name being written to @param {any[]} seeds The migration seeds being written to the table
[ "Writes", "a", "batch", "chunk", "of", "migration", "seeds", "to", "DynamoDB", ".", "DynamoDB", "has", "a", "limit", "on", "the", "number", "of", "items", "that", "may", "be", "written", "in", "a", "batch", "operation", "." ]
8278a7ea86d809bdc9857194269bf0747b27a956
https://github.com/99xt/serverless-dynamodb-local/blob/8278a7ea86d809bdc9857194269bf0747b27a956/src/seeder.js#L22-L51
9,023
99xt/serverless-dynamodb-local
src/seeder.js
writeSeeds
function writeSeeds(dynamodbWriteFunction, tableName, seeds) { if (!dynamodbWriteFunction) { throw new Error("dynamodbWriteFunction argument must be provided"); } if (!tableName) { throw new Error("table name argument must be provided"); } if (!seeds) { throw new Error("seeds argument must be provided"); } if (seeds.length > 0) { const seedChunks = _.chunk(seeds, MAX_MIGRATION_CHUNK); return BbPromise.map( seedChunks, (chunk) => writeSeedBatch(dynamodbWriteFunction, tableName, chunk), { concurrency: MIGRATION_SEED_CONCURRENCY } ) .then(() => console.log("Seed running complete for table: " + tableName)); } }
javascript
function writeSeeds(dynamodbWriteFunction, tableName, seeds) { if (!dynamodbWriteFunction) { throw new Error("dynamodbWriteFunction argument must be provided"); } if (!tableName) { throw new Error("table name argument must be provided"); } if (!seeds) { throw new Error("seeds argument must be provided"); } if (seeds.length > 0) { const seedChunks = _.chunk(seeds, MAX_MIGRATION_CHUNK); return BbPromise.map( seedChunks, (chunk) => writeSeedBatch(dynamodbWriteFunction, tableName, chunk), { concurrency: MIGRATION_SEED_CONCURRENCY } ) .then(() => console.log("Seed running complete for table: " + tableName)); } }
[ "function", "writeSeeds", "(", "dynamodbWriteFunction", ",", "tableName", ",", "seeds", ")", "{", "if", "(", "!", "dynamodbWriteFunction", ")", "{", "throw", "new", "Error", "(", "\"dynamodbWriteFunction argument must be provided\"", ")", ";", "}", "if", "(", "!",...
Writes a seed corpus to the given database table @param {function} dynamodbWriteFunction The DynamoDB DocumentClient.batchWrite or DynamoDB.batchWriteItem function @param {string} tableName The table name @param {any[]} seeds The seed values
[ "Writes", "a", "seed", "corpus", "to", "the", "given", "database", "table" ]
8278a7ea86d809bdc9857194269bf0747b27a956
https://github.com/99xt/serverless-dynamodb-local/blob/8278a7ea86d809bdc9857194269bf0747b27a956/src/seeder.js#L59-L79
9,024
99xt/serverless-dynamodb-local
src/seeder.js
fileExists
function fileExists(fileName) { return new BbPromise((resolve) => { fs.exists(fileName, (exists) => resolve(exists)); }); }
javascript
function fileExists(fileName) { return new BbPromise((resolve) => { fs.exists(fileName, (exists) => resolve(exists)); }); }
[ "function", "fileExists", "(", "fileName", ")", "{", "return", "new", "BbPromise", "(", "(", "resolve", ")", "=>", "{", "fs", ".", "exists", "(", "fileName", ",", "(", "exists", ")", "=>", "resolve", "(", "exists", ")", ")", ";", "}", ")", ";", "}"...
A promise-based function that determines if a file exists @param {string} fileName The path to the file
[ "A", "promise", "-", "based", "function", "that", "determines", "if", "a", "file", "exists" ]
8278a7ea86d809bdc9857194269bf0747b27a956
https://github.com/99xt/serverless-dynamodb-local/blob/8278a7ea86d809bdc9857194269bf0747b27a956/src/seeder.js#L85-L89
9,025
99xt/serverless-dynamodb-local
src/seeder.js
unmarshalBuffer
function unmarshalBuffer(json) { _.forEach(json, function(value, key) { // Null check to prevent creation of Buffer when value is null if (value !== null && value.type==="Buffer") { json[key]= new Buffer(value.data); } }); return json; }
javascript
function unmarshalBuffer(json) { _.forEach(json, function(value, key) { // Null check to prevent creation of Buffer when value is null if (value !== null && value.type==="Buffer") { json[key]= new Buffer(value.data); } }); return json; }
[ "function", "unmarshalBuffer", "(", "json", ")", "{", "_", ".", "forEach", "(", "json", ",", "function", "(", "value", ",", "key", ")", "{", "// Null check to prevent creation of Buffer when value is null", "if", "(", "value", "!==", "null", "&&", "value", ".", ...
Transform all selerialized Buffer value in a Buffer value inside a json object @param {json} json with serialized Buffer value. @return {json} json with Buffer object.
[ "Transform", "all", "selerialized", "Buffer", "value", "in", "a", "Buffer", "value", "inside", "a", "json", "object" ]
8278a7ea86d809bdc9857194269bf0747b27a956
https://github.com/99xt/serverless-dynamodb-local/blob/8278a7ea86d809bdc9857194269bf0747b27a956/src/seeder.js#L97-L105
9,026
99xt/serverless-dynamodb-local
src/seeder.js
getSeedsAtLocation
function getSeedsAtLocation(location) { // load the file as JSON const result = require(location); // Ensure the output is an array if (Array.isArray(result)) { return _.forEach(result, unmarshalBuffer); } else { return [ unmarshalBuffer(result) ]; } }
javascript
function getSeedsAtLocation(location) { // load the file as JSON const result = require(location); // Ensure the output is an array if (Array.isArray(result)) { return _.forEach(result, unmarshalBuffer); } else { return [ unmarshalBuffer(result) ]; } }
[ "function", "getSeedsAtLocation", "(", "location", ")", "{", "// load the file as JSON", "const", "result", "=", "require", "(", "location", ")", ";", "// Ensure the output is an array", "if", "(", "Array", ".", "isArray", "(", "result", ")", ")", "{", "return", ...
Scrapes seed files out of a given location. This file may contain either a simple json object, or an array of simple json objects. An array of json objects is returned. @param {any} location the filename to read seeds from.
[ "Scrapes", "seed", "files", "out", "of", "a", "given", "location", ".", "This", "file", "may", "contain", "either", "a", "simple", "json", "object", "or", "an", "array", "of", "simple", "json", "objects", ".", "An", "array", "of", "json", "objects", "is"...
8278a7ea86d809bdc9857194269bf0747b27a956
https://github.com/99xt/serverless-dynamodb-local/blob/8278a7ea86d809bdc9857194269bf0747b27a956/src/seeder.js#L114-L124
9,027
99xt/serverless-dynamodb-local
src/seeder.js
locateSeeds
function locateSeeds(sources, cwd) { sources = sources || []; cwd = cwd || process.cwd(); const locations = sources.map((source) => path.join(cwd, source)); return BbPromise.map(locations, (location) => { return fileExists(location).then((exists) => { if(!exists) { throw new Error("source file " + location + " does not exist"); } return getSeedsAtLocation(location); }); // Smash the arrays together }).then((seedArrays) => [].concat.apply([], seedArrays)); }
javascript
function locateSeeds(sources, cwd) { sources = sources || []; cwd = cwd || process.cwd(); const locations = sources.map((source) => path.join(cwd, source)); return BbPromise.map(locations, (location) => { return fileExists(location).then((exists) => { if(!exists) { throw new Error("source file " + location + " does not exist"); } return getSeedsAtLocation(location); }); // Smash the arrays together }).then((seedArrays) => [].concat.apply([], seedArrays)); }
[ "function", "locateSeeds", "(", "sources", ",", "cwd", ")", "{", "sources", "=", "sources", "||", "[", "]", ";", "cwd", "=", "cwd", "||", "process", ".", "cwd", "(", ")", ";", "const", "locations", "=", "sources", ".", "map", "(", "(", "source", ")...
Locates seeds given a set of files to scrape @param {string[]} sources The filenames to scrape for seeds
[ "Locates", "seeds", "given", "a", "set", "of", "files", "to", "scrape" ]
8278a7ea86d809bdc9857194269bf0747b27a956
https://github.com/99xt/serverless-dynamodb-local/blob/8278a7ea86d809bdc9857194269bf0747b27a956/src/seeder.js#L130-L144
9,028
ipfs/interface-js-ipfs-core
src/utils/spawn.js
spawnNodeWithId
function spawnNodeWithId (factory, callback) { waterfall([(cb) => factory.spawnNode(cb), identify], callback) }
javascript
function spawnNodeWithId (factory, callback) { waterfall([(cb) => factory.spawnNode(cb), identify], callback) }
[ "function", "spawnNodeWithId", "(", "factory", ",", "callback", ")", "{", "waterfall", "(", "[", "(", "cb", ")", "=>", "factory", ".", "spawnNode", "(", "cb", ")", ",", "identify", "]", ",", "callback", ")", "}" ]
Spawn a node, get it's id and set it as `peerId` on the node
[ "Spawn", "a", "node", "get", "it", "s", "id", "and", "set", "it", "as", "peerId", "on", "the", "node" ]
b90d6352ad88ea7c388f2b2c32e8ff562724f14f
https://github.com/ipfs/interface-js-ipfs-core/blob/b90d6352ad88ea7c388f2b2c32e8ff562724f14f/src/utils/spawn.js#L16-L18
9,029
ipfs/interface-js-ipfs-core
src/utils/spawn.js
spawnNodes
function spawnNodes (n, factory, callback) { timesSeries(n, (_, cb) => factory.spawnNode(cb), callback) }
javascript
function spawnNodes (n, factory, callback) { timesSeries(n, (_, cb) => factory.spawnNode(cb), callback) }
[ "function", "spawnNodes", "(", "n", ",", "factory", ",", "callback", ")", "{", "timesSeries", "(", "n", ",", "(", "_", ",", "cb", ")", "=>", "factory", ".", "spawnNode", "(", "cb", ")", ",", "callback", ")", "}" ]
Spawn n nodes
[ "Spawn", "n", "nodes" ]
b90d6352ad88ea7c388f2b2c32e8ff562724f14f
https://github.com/ipfs/interface-js-ipfs-core/blob/b90d6352ad88ea7c388f2b2c32e8ff562724f14f/src/utils/spawn.js#L23-L25
9,030
ipfs/interface-js-ipfs-core
src/utils/spawn.js
spawnNodesWithId
function spawnNodesWithId (n, factory, callback) { spawnNodes(n, factory, (err, nodes) => { if (err) return callback(err) map(nodes, identify, callback) }) }
javascript
function spawnNodesWithId (n, factory, callback) { spawnNodes(n, factory, (err, nodes) => { if (err) return callback(err) map(nodes, identify, callback) }) }
[ "function", "spawnNodesWithId", "(", "n", ",", "factory", ",", "callback", ")", "{", "spawnNodes", "(", "n", ",", "factory", ",", "(", "err", ",", "nodes", ")", "=>", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ")", "map", "(", "n...
Spawn n nodes, getting their id's and setting them as `peerId` on the nodes
[ "Spawn", "n", "nodes", "getting", "their", "id", "s", "and", "setting", "them", "as", "peerId", "on", "the", "nodes" ]
b90d6352ad88ea7c388f2b2c32e8ff562724f14f
https://github.com/ipfs/interface-js-ipfs-core/blob/b90d6352ad88ea7c388f2b2c32e8ff562724f14f/src/utils/spawn.js#L30-L35
9,031
mourner/rbush
index.js
function (insertPath, level) { var node = insertPath[level], M = node.children.length, m = this._minEntries; this._chooseSplitAxis(node, m, M); var splitIndex = this._chooseSplitIndex(node, m, M); var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); newNode.height = node.height; newNode.leaf = node.leaf; calcBBox(node, this.toBBox); calcBBox(newNode, this.toBBox); if (level) insertPath[level - 1].children.push(newNode); else this._splitRoot(node, newNode); }
javascript
function (insertPath, level) { var node = insertPath[level], M = node.children.length, m = this._minEntries; this._chooseSplitAxis(node, m, M); var splitIndex = this._chooseSplitIndex(node, m, M); var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); newNode.height = node.height; newNode.leaf = node.leaf; calcBBox(node, this.toBBox); calcBBox(newNode, this.toBBox); if (level) insertPath[level - 1].children.push(newNode); else this._splitRoot(node, newNode); }
[ "function", "(", "insertPath", ",", "level", ")", "{", "var", "node", "=", "insertPath", "[", "level", "]", ",", "M", "=", "node", ".", "children", ".", "length", ",", "m", "=", "this", ".", "_minEntries", ";", "this", ".", "_chooseSplitAxis", "(", "...
split overflowed node into two
[ "split", "overflowed", "node", "into", "two" ]
175cb6a0201eda595d485d2ce38a3199a1b9ed7b
https://github.com/mourner/rbush/blob/175cb6a0201eda595d485d2ce38a3199a1b9ed7b/index.js#L318-L337
9,032
mourner/rbush
index.js
function (node, m, M) { var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, xMargin = this._allDistMargin(node, m, M, compareMinX), yMargin = this._allDistMargin(node, m, M, compareMinY); // if total distributions margin value is minimal for x, sort by minX, // otherwise it's already sorted by minY if (xMargin < yMargin) node.children.sort(compareMinX); }
javascript
function (node, m, M) { var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, xMargin = this._allDistMargin(node, m, M, compareMinX), yMargin = this._allDistMargin(node, m, M, compareMinY); // if total distributions margin value is minimal for x, sort by minX, // otherwise it's already sorted by minY if (xMargin < yMargin) node.children.sort(compareMinX); }
[ "function", "(", "node", ",", "m", ",", "M", ")", "{", "var", "compareMinX", "=", "node", ".", "leaf", "?", "this", ".", "compareMinX", ":", "compareNodeMinX", ",", "compareMinY", "=", "node", ".", "leaf", "?", "this", ".", "compareMinY", ":", "compare...
sorts node children by the best axis for split
[ "sorts", "node", "children", "by", "the", "best", "axis", "for", "split" ]
175cb6a0201eda595d485d2ce38a3199a1b9ed7b
https://github.com/mourner/rbush/blob/175cb6a0201eda595d485d2ce38a3199a1b9ed7b/index.js#L380-L390
9,033
mourner/rbush
index.js
function (node, m, M, compare) { node.children.sort(compare); var toBBox = this.toBBox, leftBBox = distBBox(node, 0, m, toBBox), rightBBox = distBBox(node, M - m, M, toBBox), margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), i, child; for (i = m; i < M - m; i++) { child = node.children[i]; extend(leftBBox, node.leaf ? toBBox(child) : child); margin += bboxMargin(leftBBox); } for (i = M - m - 1; i >= m; i--) { child = node.children[i]; extend(rightBBox, node.leaf ? toBBox(child) : child); margin += bboxMargin(rightBBox); } return margin; }
javascript
function (node, m, M, compare) { node.children.sort(compare); var toBBox = this.toBBox, leftBBox = distBBox(node, 0, m, toBBox), rightBBox = distBBox(node, M - m, M, toBBox), margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), i, child; for (i = m; i < M - m; i++) { child = node.children[i]; extend(leftBBox, node.leaf ? toBBox(child) : child); margin += bboxMargin(leftBBox); } for (i = M - m - 1; i >= m; i--) { child = node.children[i]; extend(rightBBox, node.leaf ? toBBox(child) : child); margin += bboxMargin(rightBBox); } return margin; }
[ "function", "(", "node", ",", "m", ",", "M", ",", "compare", ")", "{", "node", ".", "children", ".", "sort", "(", "compare", ")", ";", "var", "toBBox", "=", "this", ".", "toBBox", ",", "leftBBox", "=", "distBBox", "(", "node", ",", "0", ",", "m",...
total margin of all possible split distributions where each node is at least m full
[ "total", "margin", "of", "all", "possible", "split", "distributions", "where", "each", "node", "is", "at", "least", "m", "full" ]
175cb6a0201eda595d485d2ce38a3199a1b9ed7b
https://github.com/mourner/rbush/blob/175cb6a0201eda595d485d2ce38a3199a1b9ed7b/index.js#L393-L416
9,034
mourner/rbush
index.js
calcBBox
function calcBBox(node, toBBox) { distBBox(node, 0, node.children.length, toBBox, node); }
javascript
function calcBBox(node, toBBox) { distBBox(node, 0, node.children.length, toBBox, node); }
[ "function", "calcBBox", "(", "node", ",", "toBBox", ")", "{", "distBBox", "(", "node", ",", "0", ",", "node", ".", "children", ".", "length", ",", "toBBox", ",", "node", ")", ";", "}" ]
calculate node's bbox from bboxes of its children
[ "calculate", "node", "s", "bbox", "from", "bboxes", "of", "its", "children" ]
175cb6a0201eda595d485d2ce38a3199a1b9ed7b
https://github.com/mourner/rbush/blob/175cb6a0201eda595d485d2ce38a3199a1b9ed7b/index.js#L469-L471
9,035
mourner/rbush
index.js
distBBox
function distBBox(node, k, p, toBBox, destNode) { if (!destNode) destNode = createNode(null); destNode.minX = Infinity; destNode.minY = Infinity; destNode.maxX = -Infinity; destNode.maxY = -Infinity; for (var i = k, child; i < p; i++) { child = node.children[i]; extend(destNode, node.leaf ? toBBox(child) : child); } return destNode; }
javascript
function distBBox(node, k, p, toBBox, destNode) { if (!destNode) destNode = createNode(null); destNode.minX = Infinity; destNode.minY = Infinity; destNode.maxX = -Infinity; destNode.maxY = -Infinity; for (var i = k, child; i < p; i++) { child = node.children[i]; extend(destNode, node.leaf ? toBBox(child) : child); } return destNode; }
[ "function", "distBBox", "(", "node", ",", "k", ",", "p", ",", "toBBox", ",", "destNode", ")", "{", "if", "(", "!", "destNode", ")", "destNode", "=", "createNode", "(", "null", ")", ";", "destNode", ".", "minX", "=", "Infinity", ";", "destNode", ".", ...
min bounding rectangle of node children from k to p-1
[ "min", "bounding", "rectangle", "of", "node", "children", "from", "k", "to", "p", "-", "1" ]
175cb6a0201eda595d485d2ce38a3199a1b9ed7b
https://github.com/mourner/rbush/blob/175cb6a0201eda595d485d2ce38a3199a1b9ed7b/index.js#L474-L487
9,036
mourner/rbush
index.js
multiSelect
function multiSelect(arr, left, right, n, compare) { var stack = [left, right], mid; while (stack.length) { right = stack.pop(); left = stack.pop(); if (right - left <= n) continue; mid = left + Math.ceil((right - left) / n / 2) * n; quickselect(arr, mid, left, right, compare); stack.push(left, mid, mid, right); } }
javascript
function multiSelect(arr, left, right, n, compare) { var stack = [left, right], mid; while (stack.length) { right = stack.pop(); left = stack.pop(); if (right - left <= n) continue; mid = left + Math.ceil((right - left) / n / 2) * n; quickselect(arr, mid, left, right, compare); stack.push(left, mid, mid, right); } }
[ "function", "multiSelect", "(", "arr", ",", "left", ",", "right", ",", "n", ",", "compare", ")", "{", "var", "stack", "=", "[", "left", ",", "right", "]", ",", "mid", ";", "while", "(", "stack", ".", "length", ")", "{", "right", "=", "stack", "."...
sort an array so that items come in groups of n unsorted items, with groups sorted between each other; combines selection algorithm with binary divide & conquer approach
[ "sort", "an", "array", "so", "that", "items", "come", "in", "groups", "of", "n", "unsorted", "items", "with", "groups", "sorted", "between", "each", "other", ";", "combines", "selection", "algorithm", "with", "binary", "divide", "&", "conquer", "approach" ]
175cb6a0201eda595d485d2ce38a3199a1b9ed7b
https://github.com/mourner/rbush/blob/175cb6a0201eda595d485d2ce38a3199a1b9ed7b/index.js#L547-L562
9,037
davidmarkclements/0x
visualizer/actions.js
jumpToState
function jumpToState () { return ({ merged, nodeId, excludeTypes }) => { state.focusedNodeId = nodeId state.control.merged = merged state.typeFilters.enableInlinable = !merged state.key.enableOptUnopt = !merged // Diff type exclude state to reach the one described by the entry const oldExclude = state.typeFilters.exclude const newExclude = new Set(excludeTypes) oldExclude.forEach((name) => { if (!newExclude.has(name)) { flamegraph.typeShow(name) } }) newExclude.forEach((name) => { if (!oldExclude.has(name)) { flamegraph.typeHide(name) } }) state.typeFilters.exclude = newExclude state.typeFilters.bgs = state.control.tiers ? highlightTypeFilters() : state.typeFilters.unhighlighted flamegraph.renderTree(merged ? state.trees.merged : state.trees.unmerged) const { idsToNodes } = merged ? mergedTags : unmergedTags flamegraph.zoom(idsToNodes.get(nodeId)) emit(state) } }
javascript
function jumpToState () { return ({ merged, nodeId, excludeTypes }) => { state.focusedNodeId = nodeId state.control.merged = merged state.typeFilters.enableInlinable = !merged state.key.enableOptUnopt = !merged // Diff type exclude state to reach the one described by the entry const oldExclude = state.typeFilters.exclude const newExclude = new Set(excludeTypes) oldExclude.forEach((name) => { if (!newExclude.has(name)) { flamegraph.typeShow(name) } }) newExclude.forEach((name) => { if (!oldExclude.has(name)) { flamegraph.typeHide(name) } }) state.typeFilters.exclude = newExclude state.typeFilters.bgs = state.control.tiers ? highlightTypeFilters() : state.typeFilters.unhighlighted flamegraph.renderTree(merged ? state.trees.merged : state.trees.unmerged) const { idsToNodes } = merged ? mergedTags : unmergedTags flamegraph.zoom(idsToNodes.get(nodeId)) emit(state) } }
[ "function", "jumpToState", "(", ")", "{", "return", "(", "{", "merged", ",", "nodeId", ",", "excludeTypes", "}", ")", "=>", "{", "state", ".", "focusedNodeId", "=", "nodeId", "state", ".", "control", ".", "merged", "=", "merged", "state", ".", "typeFilte...
Jump to a state based on a history entry.
[ "Jump", "to", "a", "state", "based", "on", "a", "history", "entry", "." ]
9863309871a805536c86d7027c7345bb2e9ac40b
https://github.com/davidmarkclements/0x/blob/9863309871a805536c86d7027c7345bb2e9ac40b/visualizer/actions.js#L143-L174
9,038
davidmarkclements/0x
visualizer/actions.js
tagNodesWithIds
function tagNodesWithIds (data) { let id = 0 const idsToNodes = new Map() const nodesToIds = new Map() tagNodes(data) return { idsToNodes, nodesToIds } function tag (node) { idsToNodes.set(id, node) nodesToIds.set(node, id) id++ } function tagNodes (node) { tag(node) if (node.children) node.children.forEach(tagNodes) } }
javascript
function tagNodesWithIds (data) { let id = 0 const idsToNodes = new Map() const nodesToIds = new Map() tagNodes(data) return { idsToNodes, nodesToIds } function tag (node) { idsToNodes.set(id, node) nodesToIds.set(node, id) id++ } function tagNodes (node) { tag(node) if (node.children) node.children.forEach(tagNodes) } }
[ "function", "tagNodesWithIds", "(", "data", ")", "{", "let", "id", "=", "0", "const", "idsToNodes", "=", "new", "Map", "(", ")", "const", "nodesToIds", "=", "new", "Map", "(", ")", "tagNodes", "(", "data", ")", "return", "{", "idsToNodes", ",", "nodesT...
This just uses incrementing IDs but it will only be used for a single dataset, and it's deterministic enough for that
[ "This", "just", "uses", "incrementing", "IDs", "but", "it", "will", "only", "be", "used", "for", "a", "single", "dataset", "and", "it", "s", "deterministic", "enough", "for", "that" ]
9863309871a805536c86d7027c7345bb2e9ac40b
https://github.com/davidmarkclements/0x/blob/9863309871a805536c86d7027c7345bb2e9ac40b/visualizer/actions.js#L179-L199
9,039
davidmarkclements/0x
lib/v8-log-to-ticks.js
fixLines
function fixLines (line) { // Node 11+ are fine if (nodeMajorV > 10) return line // Work around a bug in Node 10's V8 --preprocess -j that breaks strings containing \\ if (nodeMajorV === 10) { // Look for backslashes that aren't escaping a unicode character code, like \\u01a2 // Small risk of false positives e.g. is C:\\Users\\u2bfab\\ unicode, or a U2 fan? // So, restrict to basic multilingual (4 char) only. No hieroglyphs or ancient Mayan. const startPath = line.search(/\\(?!u[0-9A-Fa-f]{4})/) if (startPath === -1) return line // Replace any \\ that's not part of a unicode escape character const replaceRegex = /\\(?!u[0-9A-Fa-f]{4})/g // \u005c is the unicode escape for the \ char return line.slice(0, startPath) + line.slice(startPath).replace(replaceRegex, '\\u005c') } if (nodeMajorV < 10) { // In regexs, Node 8 (and 9) hard-escapes unicode and doubles \\ to \\\\ if (!line.match(/^code-creation,RegExp/)) return line // Normal buffer decoding, String.normalize() etc doesn't work here, brute force needed const escapedUnicode = line.match(/(\\u[0-9A-Fa-f]{4})+/g) if (escapedUnicode) { for (const match of escapedUnicode) { line = line.replace(match, JSON.parse(`"${match}"`)) } } return line.replace(/\\\\/g, '\\') } }
javascript
function fixLines (line) { // Node 11+ are fine if (nodeMajorV > 10) return line // Work around a bug in Node 10's V8 --preprocess -j that breaks strings containing \\ if (nodeMajorV === 10) { // Look for backslashes that aren't escaping a unicode character code, like \\u01a2 // Small risk of false positives e.g. is C:\\Users\\u2bfab\\ unicode, or a U2 fan? // So, restrict to basic multilingual (4 char) only. No hieroglyphs or ancient Mayan. const startPath = line.search(/\\(?!u[0-9A-Fa-f]{4})/) if (startPath === -1) return line // Replace any \\ that's not part of a unicode escape character const replaceRegex = /\\(?!u[0-9A-Fa-f]{4})/g // \u005c is the unicode escape for the \ char return line.slice(0, startPath) + line.slice(startPath).replace(replaceRegex, '\\u005c') } if (nodeMajorV < 10) { // In regexs, Node 8 (and 9) hard-escapes unicode and doubles \\ to \\\\ if (!line.match(/^code-creation,RegExp/)) return line // Normal buffer decoding, String.normalize() etc doesn't work here, brute force needed const escapedUnicode = line.match(/(\\u[0-9A-Fa-f]{4})+/g) if (escapedUnicode) { for (const match of escapedUnicode) { line = line.replace(match, JSON.parse(`"${match}"`)) } } return line.replace(/\\\\/g, '\\') } }
[ "function", "fixLines", "(", "line", ")", "{", "// Node 11+ are fine", "if", "(", "nodeMajorV", ">", "10", ")", "return", "line", "// Work around a bug in Node 10's V8 --preprocess -j that breaks strings containing \\\\", "if", "(", "nodeMajorV", "===", "10", ")", "{", ...
Fixes node-version-specific issues with isolate log text
[ "Fixes", "node", "-", "version", "-", "specific", "issues", "with", "isolate", "log", "text" ]
9863309871a805536c86d7027c7345bb2e9ac40b
https://github.com/davidmarkclements/0x/blob/9863309871a805536c86d7027c7345bb2e9ac40b/lib/v8-log-to-ticks.js#L37-L68
9,040
harc/ohm
src/util.js
padNumbersToEqualLength
function padNumbersToEqualLength(arr) { var maxLen = 0; var strings = arr.map(function(n) { var str = n.toString(); maxLen = Math.max(maxLen, str.length); return str; }); return strings.map(function(s) { return common.padLeft(s, maxLen); }); }
javascript
function padNumbersToEqualLength(arr) { var maxLen = 0; var strings = arr.map(function(n) { var str = n.toString(); maxLen = Math.max(maxLen, str.length); return str; }); return strings.map(function(s) { return common.padLeft(s, maxLen); }); }
[ "function", "padNumbersToEqualLength", "(", "arr", ")", "{", "var", "maxLen", "=", "0", ";", "var", "strings", "=", "arr", ".", "map", "(", "function", "(", "n", ")", "{", "var", "str", "=", "n", ".", "toString", "(", ")", ";", "maxLen", "=", "Math...
Given an array of numbers `arr`, return an array of the numbers as strings, right-justified and padded to the same length.
[ "Given", "an", "array", "of", "numbers", "arr", "return", "an", "array", "of", "the", "numbers", "as", "strings", "right", "-", "justified", "and", "padded", "to", "the", "same", "length", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/util.js#L15-L23
9,041
harc/ohm
src/util.js
strcpy
function strcpy(dest, src, offset) { var origDestLen = dest.length; var start = dest.slice(0, offset); var end = dest.slice(offset + src.length); return (start + src + end).substr(0, origDestLen); }
javascript
function strcpy(dest, src, offset) { var origDestLen = dest.length; var start = dest.slice(0, offset); var end = dest.slice(offset + src.length); return (start + src + end).substr(0, origDestLen); }
[ "function", "strcpy", "(", "dest", ",", "src", ",", "offset", ")", "{", "var", "origDestLen", "=", "dest", ".", "length", ";", "var", "start", "=", "dest", ".", "slice", "(", "0", ",", "offset", ")", ";", "var", "end", "=", "dest", ".", "slice", ...
Produce a new string that would be the result of copying the contents of the string `src` onto `dest` at offset `offest`.
[ "Produce", "a", "new", "string", "that", "would", "be", "the", "result", "of", "copying", "the", "contents", "of", "the", "string", "src", "onto", "dest", "at", "offset", "offest", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/util.js#L27-L32
9,042
harc/ohm
src/util.js
appendLine
function appendLine(num, content, prefix) { sb.append(prefix + lineNumbers[num] + ' | ' + content + '\n'); }
javascript
function appendLine(num, content, prefix) { sb.append(prefix + lineNumbers[num] + ' | ' + content + '\n'); }
[ "function", "appendLine", "(", "num", ",", "content", ",", "prefix", ")", "{", "sb", ".", "append", "(", "prefix", "+", "lineNumbers", "[", "num", "]", "+", "' | '", "+", "content", "+", "'\\n'", ")", ";", "}" ]
Helper for appending formatting input lines to the buffer.
[ "Helper", "for", "appending", "formatting", "input", "lines", "to", "the", "buffer", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/util.js#L127-L129
9,043
harc/ohm
src/pexprs.js
Extend
function Extend(superGrammar, name, body) { this.superGrammar = superGrammar; this.name = name; this.body = body; var origBody = superGrammar.rules[name].body; this.terms = [body, origBody]; }
javascript
function Extend(superGrammar, name, body) { this.superGrammar = superGrammar; this.name = name; this.body = body; var origBody = superGrammar.rules[name].body; this.terms = [body, origBody]; }
[ "function", "Extend", "(", "superGrammar", ",", "name", ",", "body", ")", "{", "this", ".", "superGrammar", "=", "superGrammar", ";", "this", ".", "name", "=", "name", ";", "this", ".", "body", "=", "body", ";", "var", "origBody", "=", "superGrammar", ...
Extend is an implementation detail of rule extension
[ "Extend", "is", "an", "implementation", "detail", "of", "rule", "extension" ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/pexprs.js#L68-L74
9,044
harc/ohm
src/Semantics.js
ASemantics
function ASemantics(matchResult) { if (!(matchResult instanceof MatchResult)) { throw new TypeError( 'Semantics expected a MatchResult, but got ' + common.unexpectedObjToString(matchResult)); } if (matchResult.failed()) { throw new TypeError('cannot apply Semantics to ' + matchResult.toString()); } var cst = matchResult._cst; if (cst.grammar !== grammar) { throw new Error( "Cannot use a MatchResult from grammar '" + cst.grammar.name + "' with a semantics for '" + grammar.name + "'"); } var inputStream = new InputStream(matchResult.input); return s.wrap(cst, inputStream.interval(matchResult._cstOffset, matchResult.input.length)); }
javascript
function ASemantics(matchResult) { if (!(matchResult instanceof MatchResult)) { throw new TypeError( 'Semantics expected a MatchResult, but got ' + common.unexpectedObjToString(matchResult)); } if (matchResult.failed()) { throw new TypeError('cannot apply Semantics to ' + matchResult.toString()); } var cst = matchResult._cst; if (cst.grammar !== grammar) { throw new Error( "Cannot use a MatchResult from grammar '" + cst.grammar.name + "' with a semantics for '" + grammar.name + "'"); } var inputStream = new InputStream(matchResult.input); return s.wrap(cst, inputStream.interval(matchResult._cstOffset, matchResult.input.length)); }
[ "function", "ASemantics", "(", "matchResult", ")", "{", "if", "(", "!", "(", "matchResult", "instanceof", "MatchResult", ")", ")", "{", "throw", "new", "TypeError", "(", "'Semantics expected a MatchResult, but got '", "+", "common", ".", "unexpectedObjToString", "("...
To enable clients to invoke a semantics like a function, return a function that acts as a proxy for `s`, which is the real `Semantics` instance.
[ "To", "enable", "clients", "to", "invoke", "a", "semantics", "like", "a", "function", "return", "a", "function", "that", "acts", "as", "a", "proxy", "for", "s", "which", "is", "the", "real", "Semantics", "instance", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/Semantics.js#L514-L531
9,045
harc/ohm
src/Semantics.js
Attribute
function Attribute(name, actionDict, builtInDefault) { this.name = name; this.formals = []; this.actionDict = actionDict; this.builtInDefault = builtInDefault; }
javascript
function Attribute(name, actionDict, builtInDefault) { this.name = name; this.formals = []; this.actionDict = actionDict; this.builtInDefault = builtInDefault; }
[ "function", "Attribute", "(", "name", ",", "actionDict", ",", "builtInDefault", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "formals", "=", "[", "]", ";", "this", ".", "actionDict", "=", "actionDict", ";", "this", ".", "builtInDefault",...
Attributes are Operations whose results are memoized. This means that, for any given semantics, the semantic action for a CST node will be invoked no more than once.
[ "Attributes", "are", "Operations", "whose", "results", "are", "memoized", ".", "This", "means", "that", "for", "any", "given", "semantics", "the", "semantic", "action", "for", "a", "CST", "node", "will", "be", "invoked", "no", "more", "than", "once", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/Semantics.js#L666-L671
9,046
harc/ohm
src/Grammar.js
function(what, name, actionDict) { function isSpecialAction(a) { return a === '_iter' || a === '_terminal' || a === '_nonterminal' || a === '_default'; } var problems = []; for (var k in actionDict) { var v = actionDict[k]; if (!isSpecialAction(k) && !(k in this.rules)) { problems.push("'" + k + "' is not a valid semantic action for '" + this.name + "'"); } else if (typeof v !== 'function') { problems.push( "'" + k + "' must be a function in an action dictionary for '" + this.name + "'"); } else { var actual = v.length; var expected = this._topDownActionArity(k); if (actual !== expected) { problems.push( "Semantic action '" + k + "' has the wrong arity: " + 'expected ' + expected + ', got ' + actual); } } } if (problems.length > 0) { var prettyProblems = problems.map(function(problem) { return '- ' + problem; }); var error = new Error( "Found errors in the action dictionary of the '" + name + "' " + what + ':\n' + prettyProblems.join('\n')); error.problems = problems; throw error; } }
javascript
function(what, name, actionDict) { function isSpecialAction(a) { return a === '_iter' || a === '_terminal' || a === '_nonterminal' || a === '_default'; } var problems = []; for (var k in actionDict) { var v = actionDict[k]; if (!isSpecialAction(k) && !(k in this.rules)) { problems.push("'" + k + "' is not a valid semantic action for '" + this.name + "'"); } else if (typeof v !== 'function') { problems.push( "'" + k + "' must be a function in an action dictionary for '" + this.name + "'"); } else { var actual = v.length; var expected = this._topDownActionArity(k); if (actual !== expected) { problems.push( "Semantic action '" + k + "' has the wrong arity: " + 'expected ' + expected + ', got ' + actual); } } } if (problems.length > 0) { var prettyProblems = problems.map(function(problem) { return '- ' + problem; }); var error = new Error( "Found errors in the action dictionary of the '" + name + "' " + what + ':\n' + prettyProblems.join('\n')); error.problems = problems; throw error; } }
[ "function", "(", "what", ",", "name", ",", "actionDict", ")", "{", "function", "isSpecialAction", "(", "a", ")", "{", "return", "a", "===", "'_iter'", "||", "a", "===", "'_terminal'", "||", "a", "===", "'_nonterminal'", "||", "a", "===", "'_default'", ";...
Check that every key in `actionDict` corresponds to a semantic action, and that it maps to a function of the correct arity. If not, throw an exception.
[ "Check", "that", "every", "key", "in", "actionDict", "corresponds", "to", "a", "semantic", "action", "and", "that", "it", "maps", "to", "a", "function", "of", "the", "correct", "arity", ".", "If", "not", "throw", "an", "exception", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/Grammar.js#L106-L137
9,047
harc/ohm
src/Grammar.js
function(str) { var app; if (str.indexOf('<') === -1) { // simple application app = new pexprs.Apply(str); } else { // parameterized application var cst = ohmGrammar.match(str, 'Base_application'); app = buildGrammar(cst, {}); } // Ensure that the application is valid. if (!(app.ruleName in this.rules)) { throw errors.undeclaredRule(app.ruleName, this.name); } var formals = this.rules[app.ruleName].formals; if (formals.length !== app.args.length) { var source = this.rules[app.ruleName].source; throw errors.wrongNumberOfParameters(app.ruleName, formals.length, app.args.length, source); } return app; }
javascript
function(str) { var app; if (str.indexOf('<') === -1) { // simple application app = new pexprs.Apply(str); } else { // parameterized application var cst = ohmGrammar.match(str, 'Base_application'); app = buildGrammar(cst, {}); } // Ensure that the application is valid. if (!(app.ruleName in this.rules)) { throw errors.undeclaredRule(app.ruleName, this.name); } var formals = this.rules[app.ruleName].formals; if (formals.length !== app.args.length) { var source = this.rules[app.ruleName].source; throw errors.wrongNumberOfParameters(app.ruleName, formals.length, app.args.length, source); } return app; }
[ "function", "(", "str", ")", "{", "var", "app", ";", "if", "(", "str", ".", "indexOf", "(", "'<'", ")", "===", "-", "1", ")", "{", "// simple application", "app", "=", "new", "pexprs", ".", "Apply", "(", "str", ")", ";", "}", "else", "{", "// par...
Parse a string which expresses a rule application in this grammar, and return the resulting Apply node.
[ "Parse", "a", "string", "which", "expresses", "a", "rule", "application", "in", "this", "grammar", "and", "return", "the", "resulting", "Apply", "node", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/Grammar.js#L264-L285
9,048
harc/ohm
src/MatchState.js
function(pos, expr) { var posInfo = this.memoTable[pos]; if (posInfo && expr.ruleName) { var memoRec = posInfo.memo[expr.toMemoKey()]; if (memoRec && memoRec.traceEntry) { var entry = memoRec.traceEntry.cloneWithExpr(expr); entry.isMemoized = true; return entry; } } return null; }
javascript
function(pos, expr) { var posInfo = this.memoTable[pos]; if (posInfo && expr.ruleName) { var memoRec = posInfo.memo[expr.toMemoKey()]; if (memoRec && memoRec.traceEntry) { var entry = memoRec.traceEntry.cloneWithExpr(expr); entry.isMemoized = true; return entry; } } return null; }
[ "function", "(", "pos", ",", "expr", ")", "{", "var", "posInfo", "=", "this", ".", "memoTable", "[", "pos", "]", ";", "if", "(", "posInfo", "&&", "expr", ".", "ruleName", ")", "{", "var", "memoRec", "=", "posInfo", ".", "memo", "[", "expr", ".", ...
Returns the memoized trace entry for `expr` at `pos`, if one exists, `null` otherwise.
[ "Returns", "the", "memoized", "trace", "entry", "for", "expr", "at", "pos", "if", "one", "exists", "null", "otherwise", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/MatchState.js#L220-L231
9,049
harc/ohm
src/MatchState.js
function(pos, expr, succeeded, bindings) { if (expr instanceof pexprs.Apply) { var app = this.currentApplication(); var actuals = app ? app.args : []; expr = expr.substituteParams(actuals); } return this.getMemoizedTraceEntry(pos, expr) || new Trace(this.input, pos, this.inputStream.pos, expr, succeeded, bindings, this.trace); }
javascript
function(pos, expr, succeeded, bindings) { if (expr instanceof pexprs.Apply) { var app = this.currentApplication(); var actuals = app ? app.args : []; expr = expr.substituteParams(actuals); } return this.getMemoizedTraceEntry(pos, expr) || new Trace(this.input, pos, this.inputStream.pos, expr, succeeded, bindings, this.trace); }
[ "function", "(", "pos", ",", "expr", ",", "succeeded", ",", "bindings", ")", "{", "if", "(", "expr", "instanceof", "pexprs", ".", "Apply", ")", "{", "var", "app", "=", "this", ".", "currentApplication", "(", ")", ";", "var", "actuals", "=", "app", "?...
Returns a new trace entry, with the currently active trace array as its children.
[ "Returns", "a", "new", "trace", "entry", "with", "the", "currently", "active", "trace", "array", "as", "its", "children", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/MatchState.js#L234-L242
9,050
harc/ohm
examples/operators/operator-example.js
binaryExpression
function binaryExpression(first, ops, rest) { if (associativity[ops[0]] === 'L') { const applyLeft = (x, y) => new BinaryExpression(x, ops.shift(), y); return [first].concat(rest).reduce(applyLeft); } else { const applyRight = (x, y) => new BinaryExpression(y, ops.pop(), x); return [first].concat(rest).reduceRight(applyRight); } }
javascript
function binaryExpression(first, ops, rest) { if (associativity[ops[0]] === 'L') { const applyLeft = (x, y) => new BinaryExpression(x, ops.shift(), y); return [first].concat(rest).reduce(applyLeft); } else { const applyRight = (x, y) => new BinaryExpression(y, ops.pop(), x); return [first].concat(rest).reduceRight(applyRight); } }
[ "function", "binaryExpression", "(", "first", ",", "ops", ",", "rest", ")", "{", "if", "(", "associativity", "[", "ops", "[", "0", "]", "]", "===", "'L'", ")", "{", "const", "applyLeft", "=", "(", "x", ",", "y", ")", "=>", "new", "BinaryExpression", ...
We know that all lists will have ops at the same precedence levels.
[ "We", "know", "that", "all", "lists", "will", "have", "ops", "at", "the", "same", "precedence", "levels", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/examples/operators/operator-example.js#L127-L135
9,051
harc/ohm
examples/operators/operator-example.js
makeTree
function makeTree(left, ops, rights, minPrecedence = 0) { while (ops.length > 0 && precedence[ops[0]] >= minPrecedence) { let op = ops.shift(); let right = rights.shift(); while (ops.length > 0 && (precedence[ops[0]] > precedence[op] || associativity[ops[0]] === 'R' && precedence[ops[0]] === precedence[op])) { right = makeTree(right, ops, rights, precedence[ops[0]]); } left = new BinaryExpression(left, op, right); } return left; }
javascript
function makeTree(left, ops, rights, minPrecedence = 0) { while (ops.length > 0 && precedence[ops[0]] >= minPrecedence) { let op = ops.shift(); let right = rights.shift(); while (ops.length > 0 && (precedence[ops[0]] > precedence[op] || associativity[ops[0]] === 'R' && precedence[ops[0]] === precedence[op])) { right = makeTree(right, ops, rights, precedence[ops[0]]); } left = new BinaryExpression(left, op, right); } return left; }
[ "function", "makeTree", "(", "left", ",", "ops", ",", "rights", ",", "minPrecedence", "=", "0", ")", "{", "while", "(", "ops", ".", "length", ">", "0", "&&", "precedence", "[", "ops", "[", "0", "]", "]", ">=", "minPrecedence", ")", "{", "let", "op"...
Modified Richards and Whitby-Stevens precedence climbing method.
[ "Modified", "Richards", "and", "Whitby", "-", "Stevens", "precedence", "climbing", "method", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/examples/operators/operator-example.js#L207-L218
9,052
harc/ohm
src/Trace.js
getInputExcerpt
function getInputExcerpt(input, pos, len) { var excerpt = asEscapedString(input.slice(pos, pos + len)); // Pad the output if necessary. if (excerpt.length < len) { return excerpt + common.repeat(' ', len - excerpt.length).join(''); } return excerpt; }
javascript
function getInputExcerpt(input, pos, len) { var excerpt = asEscapedString(input.slice(pos, pos + len)); // Pad the output if necessary. if (excerpt.length < len) { return excerpt + common.repeat(' ', len - excerpt.length).join(''); } return excerpt; }
[ "function", "getInputExcerpt", "(", "input", ",", "pos", ",", "len", ")", "{", "var", "excerpt", "=", "asEscapedString", "(", "input", ".", "slice", "(", "pos", ",", "pos", "+", "len", ")", ")", ";", "// Pad the output if necessary.", "if", "(", "excerpt",...
Return a string representation of a portion of `input` at offset `pos`. The result will contain exactly `len` characters.
[ "Return", "a", "string", "representation", "of", "a", "portion", "of", "input", "at", "offset", "pos", ".", "The", "result", "will", "contain", "exactly", "len", "characters", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/Trace.js#L38-L46
9,053
harc/ohm
src/main.js
getScriptElementContents
function getScriptElementContents(el) { if (!isElement(el)) { throw new TypeError('Expected a DOM Node, got ' + common.unexpectedObjToString(el)); } if (el.type !== 'text/ohm-js') { throw new Error('Expected a script tag with type="text/ohm-js", got ' + el); } return el.getAttribute('src') ? load(el.getAttribute('src')) : el.innerHTML; }
javascript
function getScriptElementContents(el) { if (!isElement(el)) { throw new TypeError('Expected a DOM Node, got ' + common.unexpectedObjToString(el)); } if (el.type !== 'text/ohm-js') { throw new Error('Expected a script tag with type="text/ohm-js", got ' + el); } return el.getAttribute('src') ? load(el.getAttribute('src')) : el.innerHTML; }
[ "function", "getScriptElementContents", "(", "el", ")", "{", "if", "(", "!", "isElement", "(", "el", ")", ")", "{", "throw", "new", "TypeError", "(", "'Expected a DOM Node, got '", "+", "common", ".", "unexpectedObjToString", "(", "el", ")", ")", ";", "}", ...
Return the contents of a script element, fetching it via XHR if necessary.
[ "Return", "the", "contents", "of", "a", "script", "element", "fetching", "it", "via", "XHR", "if", "necessary", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/main.js#L264-L272
9,054
harc/ohm
src/Interval.js
function(that) { if (this.sourceString !== that.sourceString) { throw errors.intervalSourcesDontMatch(); } else if (this.startIdx === that.startIdx && this.endIdx === that.endIdx) { // `this` and `that` are the same interval! return [ ]; } else if (this.startIdx < that.startIdx && that.endIdx < this.endIdx) { // `that` splits `this` into two intervals return [ new Interval(this.sourceString, this.startIdx, that.startIdx), new Interval(this.sourceString, that.endIdx, this.endIdx) ]; } else if (this.startIdx < that.endIdx && that.endIdx < this.endIdx) { // `that` contains a prefix of `this` return [ new Interval(this.sourceString, that.endIdx, this.endIdx) ]; } else if (this.startIdx < that.startIdx && that.startIdx < this.endIdx) { // `that` contains a suffix of `this` return [ new Interval(this.sourceString, this.startIdx, that.startIdx) ]; } else { // `that` and `this` do not overlap return [ this ]; } }
javascript
function(that) { if (this.sourceString !== that.sourceString) { throw errors.intervalSourcesDontMatch(); } else if (this.startIdx === that.startIdx && this.endIdx === that.endIdx) { // `this` and `that` are the same interval! return [ ]; } else if (this.startIdx < that.startIdx && that.endIdx < this.endIdx) { // `that` splits `this` into two intervals return [ new Interval(this.sourceString, this.startIdx, that.startIdx), new Interval(this.sourceString, that.endIdx, this.endIdx) ]; } else if (this.startIdx < that.endIdx && that.endIdx < this.endIdx) { // `that` contains a prefix of `this` return [ new Interval(this.sourceString, that.endIdx, this.endIdx) ]; } else if (this.startIdx < that.startIdx && that.startIdx < this.endIdx) { // `that` contains a suffix of `this` return [ new Interval(this.sourceString, this.startIdx, that.startIdx) ]; } else { // `that` and `this` do not overlap return [ this ]; } }
[ "function", "(", "that", ")", "{", "if", "(", "this", ".", "sourceString", "!==", "that", ".", "sourceString", ")", "{", "throw", "errors", ".", "intervalSourcesDontMatch", "(", ")", ";", "}", "else", "if", "(", "this", ".", "startIdx", "===", "that", ...
Returns an array of 0, 1, or 2 intervals that represents the result of the interval difference operation.
[ "Returns", "an", "array", "of", "0", "1", "or", "2", "intervals", "that", "represents", "the", "result", "of", "the", "interval", "difference", "operation", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/Interval.js#L59-L88
9,055
harc/ohm
src/Interval.js
function(that) { if (this.sourceString !== that.sourceString) { throw errors.intervalSourcesDontMatch(); } assert(this.startIdx >= that.startIdx && this.endIdx <= that.endIdx, 'other interval does not cover this one'); return new Interval(this.sourceString, this.startIdx - that.startIdx, this.endIdx - that.startIdx); }
javascript
function(that) { if (this.sourceString !== that.sourceString) { throw errors.intervalSourcesDontMatch(); } assert(this.startIdx >= that.startIdx && this.endIdx <= that.endIdx, 'other interval does not cover this one'); return new Interval(this.sourceString, this.startIdx - that.startIdx, this.endIdx - that.startIdx); }
[ "function", "(", "that", ")", "{", "if", "(", "this", ".", "sourceString", "!==", "that", ".", "sourceString", ")", "{", "throw", "errors", ".", "intervalSourcesDontMatch", "(", ")", ";", "}", "assert", "(", "this", ".", "startIdx", ">=", "that", ".", ...
Returns a new Interval that has the same extent as this one, but which is relative to `that`, an Interval that fully covers this one.
[ "Returns", "a", "new", "Interval", "that", "has", "the", "same", "extent", "as", "this", "one", "but", "which", "is", "relative", "to", "that", "an", "Interval", "that", "fully", "covers", "this", "one", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/Interval.js#L92-L101
9,056
harc/ohm
examples/ecmascript/es5.js
flattenIterNodes
function flattenIterNodes(nodes) { var result = []; for (var i = 0; i < nodes.length; ++i) { if (nodes[i]._node.ctorName === '_iter') { result.push.apply(result, flattenIterNodes(nodes[i].children)); } else { result.push(nodes[i]); } } return result; }
javascript
function flattenIterNodes(nodes) { var result = []; for (var i = 0; i < nodes.length; ++i) { if (nodes[i]._node.ctorName === '_iter') { result.push.apply(result, flattenIterNodes(nodes[i].children)); } else { result.push(nodes[i]); } } return result; }
[ "function", "flattenIterNodes", "(", "nodes", ")", "{", "var", "result", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "++", "i", ")", "{", "if", "(", "nodes", "[", "i", "]", ".", "_node", "...
Take an Array of nodes, and whenever an _iter node is encountered, splice in its recursively-flattened children instead.
[ "Take", "an", "Array", "of", "nodes", "and", "whenever", "an", "_iter", "node", "is", "encountered", "splice", "in", "its", "recursively", "-", "flattened", "children", "instead", "." ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/examples/ecmascript/es5.js#L20-L30
9,057
harc/ohm
src/errors.js
duplicateRuleDeclaration
function duplicateRuleDeclaration(ruleName, grammarName, declGrammarName, optSource) { var message = "Duplicate declaration for rule '" + ruleName + "' in grammar '" + grammarName + "'"; if (grammarName !== declGrammarName) { message += " (originally declared in '" + declGrammarName + "')"; } return createError(message, optSource); }
javascript
function duplicateRuleDeclaration(ruleName, grammarName, declGrammarName, optSource) { var message = "Duplicate declaration for rule '" + ruleName + "' in grammar '" + grammarName + "'"; if (grammarName !== declGrammarName) { message += " (originally declared in '" + declGrammarName + "')"; } return createError(message, optSource); }
[ "function", "duplicateRuleDeclaration", "(", "ruleName", ",", "grammarName", ",", "declGrammarName", ",", "optSource", ")", "{", "var", "message", "=", "\"Duplicate declaration for rule '\"", "+", "ruleName", "+", "\"' in grammar '\"", "+", "grammarName", "+", "\"'\"", ...
Duplicate rule declaration
[ "Duplicate", "rule", "declaration" ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/errors.js#L90-L97
9,058
harc/ohm
src/errors.js
wrongNumberOfParameters
function wrongNumberOfParameters(ruleName, expected, actual, source) { return createError( 'Wrong number of parameters for rule ' + ruleName + ' (expected ' + expected + ', got ' + actual + ')', source); }
javascript
function wrongNumberOfParameters(ruleName, expected, actual, source) { return createError( 'Wrong number of parameters for rule ' + ruleName + ' (expected ' + expected + ', got ' + actual + ')', source); }
[ "function", "wrongNumberOfParameters", "(", "ruleName", ",", "expected", ",", "actual", ",", "source", ")", "{", "return", "createError", "(", "'Wrong number of parameters for rule '", "+", "ruleName", "+", "' (expected '", "+", "expected", "+", "', got '", "+", "ac...
Wrong number of parameters
[ "Wrong", "number", "of", "parameters" ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/errors.js#L101-L106
9,059
harc/ohm
src/errors.js
wrongNumberOfArguments
function wrongNumberOfArguments(ruleName, expected, actual, expr) { return createError( 'Wrong number of arguments for rule ' + ruleName + ' (expected ' + expected + ', got ' + actual + ')', expr.source); }
javascript
function wrongNumberOfArguments(ruleName, expected, actual, expr) { return createError( 'Wrong number of arguments for rule ' + ruleName + ' (expected ' + expected + ', got ' + actual + ')', expr.source); }
[ "function", "wrongNumberOfArguments", "(", "ruleName", ",", "expected", ",", "actual", ",", "expr", ")", "{", "return", "createError", "(", "'Wrong number of arguments for rule '", "+", "ruleName", "+", "' (expected '", "+", "expected", "+", "', got '", "+", "actual...
Wrong number of arguments
[ "Wrong", "number", "of", "arguments" ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/errors.js#L110-L115
9,060
harc/ohm
src/errors.js
invalidParameter
function invalidParameter(ruleName, expr) { return createError( 'Invalid parameter to rule ' + ruleName + ': ' + expr + ' has arity ' + expr.getArity() + ', but parameter expressions must have arity 1', expr.source); }
javascript
function invalidParameter(ruleName, expr) { return createError( 'Invalid parameter to rule ' + ruleName + ': ' + expr + ' has arity ' + expr.getArity() + ', but parameter expressions must have arity 1', expr.source); }
[ "function", "invalidParameter", "(", "ruleName", ",", "expr", ")", "{", "return", "createError", "(", "'Invalid parameter to rule '", "+", "ruleName", "+", "': '", "+", "expr", "+", "' has arity '", "+", "expr", ".", "getArity", "(", ")", "+", "', but parameter ...
Invalid parameter expression
[ "Invalid", "parameter", "expression" ]
9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f
https://github.com/harc/ohm/blob/9fd4fabc135c1303b9a8cb5ed47d2eb5fa1aef8f/src/errors.js#L127-L132
9,061
senecajs/seneca
lib/logging.js
log_level_plus
function log_level_plus(logLevel) { let index = log_levels.indexOf(logLevel) if (index < 0) { return [] } else { return log_levels.slice(index, log_levels.length) } }
javascript
function log_level_plus(logLevel) { let index = log_levels.indexOf(logLevel) if (index < 0) { return [] } else { return log_levels.slice(index, log_levels.length) } }
[ "function", "log_level_plus", "(", "logLevel", ")", "{", "let", "index", "=", "log_levels", ".", "indexOf", "(", "logLevel", ")", "if", "(", "index", "<", "0", ")", "{", "return", "[", "]", "}", "else", "{", "return", "log_levels", ".", "slice", "(", ...
It returns the levels above the argument @param {String} logLevel the log level to calculate @return {Array} the list of logs above the argument
[ "It", "returns", "the", "levels", "above", "the", "argument" ]
98af1536196d4461e050ab6b71ca7563ea79ed8f
https://github.com/senecajs/seneca/blob/98af1536196d4461e050ab6b71ca7563ea79ed8f/lib/logging.js#L242-L249
9,062
senecajs/seneca
seneca.js
api_act
function api_act() { var argsarr = new Array(arguments.length) for (var l = 0; l < argsarr.length; ++l) { argsarr[l] = arguments[l] } var self = this var spec = Common.build_message(self, argsarr, 'reply:f?', self.fixedargs) var msg = spec.msg var reply = spec.reply if (opts.$.debug.act_caller || opts.$.test) { msg.caller$ = '\n Action call arguments and location: ' + (new Error(Util.inspect(msg).replace(/\n/g, '')).stack + '\n') .replace(/Error: /, '') .replace(/.*\/gate-executor\.js:.*\n/g, '') .replace(/.*\/seneca\.js:.*\n/g, '') .replace(/.*\/seneca\/lib\/.*\.js:.*\n/g, '') } do_act(self, msg, reply) return self }
javascript
function api_act() { var argsarr = new Array(arguments.length) for (var l = 0; l < argsarr.length; ++l) { argsarr[l] = arguments[l] } var self = this var spec = Common.build_message(self, argsarr, 'reply:f?', self.fixedargs) var msg = spec.msg var reply = spec.reply if (opts.$.debug.act_caller || opts.$.test) { msg.caller$ = '\n Action call arguments and location: ' + (new Error(Util.inspect(msg).replace(/\n/g, '')).stack + '\n') .replace(/Error: /, '') .replace(/.*\/gate-executor\.js:.*\n/g, '') .replace(/.*\/seneca\.js:.*\n/g, '') .replace(/.*\/seneca\/lib\/.*\.js:.*\n/g, '') } do_act(self, msg, reply) return self }
[ "function", "api_act", "(", ")", "{", "var", "argsarr", "=", "new", "Array", "(", "arguments", ".", "length", ")", "for", "(", "var", "l", "=", "0", ";", "l", "<", "argsarr", ".", "length", ";", "++", "l", ")", "{", "argsarr", "[", "l", "]", "=...
Perform an action. The properties of the first argument are matched against known patterns, and the most specific one wins.
[ "Perform", "an", "action", ".", "The", "properties", "of", "the", "first", "argument", "are", "matched", "against", "known", "patterns", "and", "the", "most", "specific", "one", "wins", "." ]
98af1536196d4461e050ab6b71ca7563ea79ed8f
https://github.com/senecajs/seneca/blob/98af1536196d4461e050ab6b71ca7563ea79ed8f/seneca.js#L755-L778
9,063
senecajs/seneca
seneca.js
api_close
function api_close(done) { var seneca = this var safe_done = _.once(function(err) { if (_.isFunction(done)) { return done.call(seneca, err) } }) // don't try to close twice if (seneca.flags.closed) { return safe_done() } seneca.ready(do_close) var close_timeout = setTimeout(do_close, opts.$.close_delay) function do_close() { clearTimeout(close_timeout) if (seneca.flags.closed) { return safe_done() } // TODO: remove in 4.x seneca.closed = true seneca.flags.closed = true // cleanup process event listeners _.each(opts.$.system.close_signals, function(active, signal) { if (active) { process.removeListener(signal, private$.handle_close) } }) seneca.log.debug({ kind: 'close', notice: 'start', callpoint: callpoint() }) seneca.act('role:seneca,cmd:close,closing$:true', function(err) { seneca.log.debug(errlog(err, { kind: 'close', notice: 'end' })) seneca.removeAllListeners('act-in') seneca.removeAllListeners('act-out') seneca.removeAllListeners('act-err') seneca.removeAllListeners('pin') seneca.removeAllListeners('after-pin') seneca.removeAllListeners('ready') seneca.private$.history.close() if (seneca.private$.status_interval) { clearInterval(seneca.private$.status_interval) } return safe_done(err) }) } return seneca }
javascript
function api_close(done) { var seneca = this var safe_done = _.once(function(err) { if (_.isFunction(done)) { return done.call(seneca, err) } }) // don't try to close twice if (seneca.flags.closed) { return safe_done() } seneca.ready(do_close) var close_timeout = setTimeout(do_close, opts.$.close_delay) function do_close() { clearTimeout(close_timeout) if (seneca.flags.closed) { return safe_done() } // TODO: remove in 4.x seneca.closed = true seneca.flags.closed = true // cleanup process event listeners _.each(opts.$.system.close_signals, function(active, signal) { if (active) { process.removeListener(signal, private$.handle_close) } }) seneca.log.debug({ kind: 'close', notice: 'start', callpoint: callpoint() }) seneca.act('role:seneca,cmd:close,closing$:true', function(err) { seneca.log.debug(errlog(err, { kind: 'close', notice: 'end' })) seneca.removeAllListeners('act-in') seneca.removeAllListeners('act-out') seneca.removeAllListeners('act-err') seneca.removeAllListeners('pin') seneca.removeAllListeners('after-pin') seneca.removeAllListeners('ready') seneca.private$.history.close() if (seneca.private$.status_interval) { clearInterval(seneca.private$.status_interval) } return safe_done(err) }) } return seneca }
[ "function", "api_close", "(", "done", ")", "{", "var", "seneca", "=", "this", "var", "safe_done", "=", "_", ".", "once", "(", "function", "(", "err", ")", "{", "if", "(", "_", ".", "isFunction", "(", "done", ")", ")", "{", "return", "done", ".", ...
close seneca instance sets public seneca.closed property
[ "close", "seneca", "instance", "sets", "public", "seneca", ".", "closed", "property" ]
98af1536196d4461e050ab6b71ca7563ea79ed8f
https://github.com/senecajs/seneca/blob/98af1536196d4461e050ab6b71ca7563ea79ed8f/seneca.js#L808-L871
9,064
senecajs/seneca
seneca.js
make_private
function make_private() { return { stats: { start: Date.now(), act: { calls: 0, done: 0, fails: 0, cache: 0 }, actmap: {} }, actdef: {}, transport: { register: [] }, plugins: {}, ignore_plugins: {} } }
javascript
function make_private() { return { stats: { start: Date.now(), act: { calls: 0, done: 0, fails: 0, cache: 0 }, actmap: {} }, actdef: {}, transport: { register: [] }, plugins: {}, ignore_plugins: {} } }
[ "function", "make_private", "(", ")", "{", "return", "{", "stats", ":", "{", "start", ":", "Date", ".", "now", "(", ")", ",", "act", ":", "{", "calls", ":", "0", ",", "done", ":", "0", ",", "fails", ":", "0", ",", "cache", ":", "0", "}", ",",...
Private member variables of Seneca object.
[ "Private", "member", "variables", "of", "Seneca", "object", "." ]
98af1536196d4461e050ab6b71ca7563ea79ed8f
https://github.com/senecajs/seneca/blob/98af1536196d4461e050ab6b71ca7563ea79ed8f/seneca.js#L1091-L1110
9,065
senecajs/seneca
docs/examples/custom-logger.js
adapter
function adapter (context, payload) { var when = payload.when.toString() var kind = pad(payload.kind || '-', 8).toUpperCase() var type = pad(payload.case || '-', 8).toUpperCase() var text = payload.pattern || payload.notice || '-' console.log(when, kind, type, text) }
javascript
function adapter (context, payload) { var when = payload.when.toString() var kind = pad(payload.kind || '-', 8).toUpperCase() var type = pad(payload.case || '-', 8).toUpperCase() var text = payload.pattern || payload.notice || '-' console.log(when, kind, type, text) }
[ "function", "adapter", "(", "context", ",", "payload", ")", "{", "var", "when", "=", "payload", ".", "when", ".", "toString", "(", ")", "var", "kind", "=", "pad", "(", "payload", ".", "kind", "||", "'-'", ",", "8", ")", ".", "toUpperCase", "(", ")"...
Everything something is logged it calls whatever custom adapter is set. Adapters are passed the current instance of Seneca plus the raw payload.
[ "Everything", "something", "is", "logged", "it", "calls", "whatever", "custom", "adapter", "is", "set", ".", "Adapters", "are", "passed", "the", "current", "instance", "of", "Seneca", "plus", "the", "raw", "payload", "." ]
98af1536196d4461e050ab6b71ca7563ea79ed8f
https://github.com/senecajs/seneca/blob/98af1536196d4461e050ab6b71ca7563ea79ed8f/docs/examples/custom-logger.js#L30-L37
9,066
senecajs/seneca
lib/inward.js
inward_act_cache
function inward_act_cache(ctxt, data) { var so = ctxt.options var meta = data.meta var actid = meta.id var private$ = ctxt.seneca.private$ if (actid != null && so.history.active) { var actdetails = private$.history.get(actid) if (actdetails) { private$.stats.act.cache++ var latest = actdetails.result[actdetails.result.length - 1] || {} var out = { kind: latest.err ? 'error' : 'result', result: latest.res || null, error: latest.err || null, log: { level: 'debug', data: { kind: 'act', case: 'CACHE', cachetime: latest.when } } } ctxt.cached$ = true return out } } }
javascript
function inward_act_cache(ctxt, data) { var so = ctxt.options var meta = data.meta var actid = meta.id var private$ = ctxt.seneca.private$ if (actid != null && so.history.active) { var actdetails = private$.history.get(actid) if (actdetails) { private$.stats.act.cache++ var latest = actdetails.result[actdetails.result.length - 1] || {} var out = { kind: latest.err ? 'error' : 'result', result: latest.res || null, error: latest.err || null, log: { level: 'debug', data: { kind: 'act', case: 'CACHE', cachetime: latest.when } } } ctxt.cached$ = true return out } } }
[ "function", "inward_act_cache", "(", "ctxt", ",", "data", ")", "{", "var", "so", "=", "ctxt", ".", "options", "var", "meta", "=", "data", ".", "meta", "var", "actid", "=", "meta", ".", "id", "var", "private$", "=", "ctxt", ".", "seneca", ".", "privat...
Check if actid has already been seen, and if action cache is active, then provide cached result, if any. Return true in this case.
[ "Check", "if", "actid", "has", "already", "been", "seen", "and", "if", "action", "cache", "is", "active", "then", "provide", "cached", "result", "if", "any", ".", "Return", "true", "in", "this", "case", "." ]
98af1536196d4461e050ab6b71ca7563ea79ed8f
https://github.com/senecajs/seneca/blob/98af1536196d4461e050ab6b71ca7563ea79ed8f/lib/inward.js#L199-L233
9,067
mourner/simplify-js
simplify.js
getSqSegDist
function getSqSegDist(p, p1, p2) { var x = p1.x, y = p1.y, dx = p2.x - x, dy = p2.y - y; if (dx !== 0 || dy !== 0) { var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy); if (t > 1) { x = p2.x; y = p2.y; } else if (t > 0) { x += dx * t; y += dy * t; } } dx = p.x - x; dy = p.y - y; return dx * dx + dy * dy; }
javascript
function getSqSegDist(p, p1, p2) { var x = p1.x, y = p1.y, dx = p2.x - x, dy = p2.y - y; if (dx !== 0 || dy !== 0) { var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy); if (t > 1) { x = p2.x; y = p2.y; } else if (t > 0) { x += dx * t; y += dy * t; } } dx = p.x - x; dy = p.y - y; return dx * dx + dy * dy; }
[ "function", "getSqSegDist", "(", "p", ",", "p1", ",", "p2", ")", "{", "var", "x", "=", "p1", ".", "x", ",", "y", "=", "p1", ".", "y", ",", "dx", "=", "p2", ".", "x", "-", "x", ",", "dy", "=", "p2", ".", "y", "-", "y", ";", "if", "(", ...
square distance from a point to a segment
[ "square", "distance", "from", "a", "point", "to", "a", "segment" ]
d5aae2be69835719d33eca21c229a286559c1664
https://github.com/mourner/simplify-js/blob/d5aae2be69835719d33eca21c229a286559c1664/simplify.js#L22-L47
9,068
mourner/simplify-js
simplify.js
simplifyRadialDist
function simplifyRadialDist(points, sqTolerance) { var prevPoint = points[0], newPoints = [prevPoint], point; for (var i = 1, len = points.length; i < len; i++) { point = points[i]; if (getSqDist(point, prevPoint) > sqTolerance) { newPoints.push(point); prevPoint = point; } } if (prevPoint !== point) newPoints.push(point); return newPoints; }
javascript
function simplifyRadialDist(points, sqTolerance) { var prevPoint = points[0], newPoints = [prevPoint], point; for (var i = 1, len = points.length; i < len; i++) { point = points[i]; if (getSqDist(point, prevPoint) > sqTolerance) { newPoints.push(point); prevPoint = point; } } if (prevPoint !== point) newPoints.push(point); return newPoints; }
[ "function", "simplifyRadialDist", "(", "points", ",", "sqTolerance", ")", "{", "var", "prevPoint", "=", "points", "[", "0", "]", ",", "newPoints", "=", "[", "prevPoint", "]", ",", "point", ";", "for", "(", "var", "i", "=", "1", ",", "len", "=", "poin...
rest of the code doesn't care about point format basic distance-based simplification
[ "rest", "of", "the", "code", "doesn", "t", "care", "about", "point", "format", "basic", "distance", "-", "based", "simplification" ]
d5aae2be69835719d33eca21c229a286559c1664
https://github.com/mourner/simplify-js/blob/d5aae2be69835719d33eca21c229a286559c1664/simplify.js#L51-L69
9,069
mourner/simplify-js
simplify.js
simplifyDouglasPeucker
function simplifyDouglasPeucker(points, sqTolerance) { var last = points.length - 1; var simplified = [points[0]]; simplifyDPStep(points, 0, last, sqTolerance, simplified); simplified.push(points[last]); return simplified; }
javascript
function simplifyDouglasPeucker(points, sqTolerance) { var last = points.length - 1; var simplified = [points[0]]; simplifyDPStep(points, 0, last, sqTolerance, simplified); simplified.push(points[last]); return simplified; }
[ "function", "simplifyDouglasPeucker", "(", "points", ",", "sqTolerance", ")", "{", "var", "last", "=", "points", ".", "length", "-", "1", ";", "var", "simplified", "=", "[", "points", "[", "0", "]", "]", ";", "simplifyDPStep", "(", "points", ",", "0", ...
simplification using Ramer-Douglas-Peucker algorithm
[ "simplification", "using", "Ramer", "-", "Douglas", "-", "Peucker", "algorithm" ]
d5aae2be69835719d33eca21c229a286559c1664
https://github.com/mourner/simplify-js/blob/d5aae2be69835719d33eca21c229a286559c1664/simplify.js#L92-L100
9,070
estools/escodegen
benchmark/old.js
isExpression
function isExpression(node) { switch (node.type) { case Syntax.AssignmentExpression: case Syntax.ArrayExpression: case Syntax.ArrayPattern: case Syntax.BinaryExpression: case Syntax.CallExpression: case Syntax.ConditionalExpression: case Syntax.ClassExpression: case Syntax.ExportBatchSpecifier: case Syntax.ExportSpecifier: case Syntax.FunctionExpression: case Syntax.Identifier: case Syntax.ImportDefaultSpecifier: case Syntax.ImportNamespaceSpecifier: case Syntax.ImportSpecifier: case Syntax.Literal: case Syntax.LogicalExpression: case Syntax.MemberExpression: case Syntax.MethodDefinition: case Syntax.ModuleSpecifier: case Syntax.NewExpression: case Syntax.ObjectExpression: case Syntax.ObjectPattern: case Syntax.Property: case Syntax.SequenceExpression: case Syntax.ThisExpression: case Syntax.UnaryExpression: case Syntax.UpdateExpression: case Syntax.YieldExpression: return true; } return false; }
javascript
function isExpression(node) { switch (node.type) { case Syntax.AssignmentExpression: case Syntax.ArrayExpression: case Syntax.ArrayPattern: case Syntax.BinaryExpression: case Syntax.CallExpression: case Syntax.ConditionalExpression: case Syntax.ClassExpression: case Syntax.ExportBatchSpecifier: case Syntax.ExportSpecifier: case Syntax.FunctionExpression: case Syntax.Identifier: case Syntax.ImportDefaultSpecifier: case Syntax.ImportNamespaceSpecifier: case Syntax.ImportSpecifier: case Syntax.Literal: case Syntax.LogicalExpression: case Syntax.MemberExpression: case Syntax.MethodDefinition: case Syntax.ModuleSpecifier: case Syntax.NewExpression: case Syntax.ObjectExpression: case Syntax.ObjectPattern: case Syntax.Property: case Syntax.SequenceExpression: case Syntax.ThisExpression: case Syntax.UnaryExpression: case Syntax.UpdateExpression: case Syntax.YieldExpression: return true; } return false; }
[ "function", "isExpression", "(", "node", ")", "{", "switch", "(", "node", ".", "type", ")", "{", "case", "Syntax", ".", "AssignmentExpression", ":", "case", "Syntax", ".", "ArrayExpression", ":", "case", "Syntax", ".", "ArrayPattern", ":", "case", "Syntax", ...
Generation is done by generateExpression.
[ "Generation", "is", "done", "by", "generateExpression", "." ]
4a93ffc24378722dbfd8859d633746ef5916ce86
https://github.com/estools/escodegen/blob/4a93ffc24378722dbfd8859d633746ef5916ce86/benchmark/old.js#L136-L169
9,071
estools/escodegen
benchmark/old.js
isStatement
function isStatement(node) { switch (node.type) { case Syntax.BlockStatement: case Syntax.BreakStatement: case Syntax.CatchClause: case Syntax.ContinueStatement: case Syntax.ClassDeclaration: case Syntax.ClassBody: case Syntax.DirectiveStatement: case Syntax.DoWhileStatement: case Syntax.DebuggerStatement: case Syntax.EmptyStatement: case Syntax.ExpressionStatement: case Syntax.ForStatement: case Syntax.ForInStatement: case Syntax.ForOfStatement: case Syntax.FunctionDeclaration: case Syntax.IfStatement: case Syntax.LabeledStatement: case Syntax.Program: case Syntax.ReturnStatement: case Syntax.SwitchStatement: case Syntax.SwitchCase: case Syntax.ThrowStatement: case Syntax.TryStatement: case Syntax.VariableDeclaration: case Syntax.VariableDeclarator: case Syntax.WhileStatement: case Syntax.WithStatement: return true; } return false; }
javascript
function isStatement(node) { switch (node.type) { case Syntax.BlockStatement: case Syntax.BreakStatement: case Syntax.CatchClause: case Syntax.ContinueStatement: case Syntax.ClassDeclaration: case Syntax.ClassBody: case Syntax.DirectiveStatement: case Syntax.DoWhileStatement: case Syntax.DebuggerStatement: case Syntax.EmptyStatement: case Syntax.ExpressionStatement: case Syntax.ForStatement: case Syntax.ForInStatement: case Syntax.ForOfStatement: case Syntax.FunctionDeclaration: case Syntax.IfStatement: case Syntax.LabeledStatement: case Syntax.Program: case Syntax.ReturnStatement: case Syntax.SwitchStatement: case Syntax.SwitchCase: case Syntax.ThrowStatement: case Syntax.TryStatement: case Syntax.VariableDeclaration: case Syntax.VariableDeclarator: case Syntax.WhileStatement: case Syntax.WithStatement: return true; } return false; }
[ "function", "isStatement", "(", "node", ")", "{", "switch", "(", "node", ".", "type", ")", "{", "case", "Syntax", ".", "BlockStatement", ":", "case", "Syntax", ".", "BreakStatement", ":", "case", "Syntax", ".", "CatchClause", ":", "case", "Syntax", ".", ...
Generation is done by generateStatement.
[ "Generation", "is", "done", "by", "generateStatement", "." ]
4a93ffc24378722dbfd8859d633746ef5916ce86
https://github.com/estools/escodegen/blob/4a93ffc24378722dbfd8859d633746ef5916ce86/benchmark/old.js#L172-L204
9,072
estools/escodegen
benchmark/old.js
flattenToString
function flattenToString(arr) { var i, iz, elem, result = ''; for (i = 0, iz = arr.length; i < iz; ++i) { elem = arr[i]; result += isArray(elem) ? flattenToString(elem) : elem; } return result; }
javascript
function flattenToString(arr) { var i, iz, elem, result = ''; for (i = 0, iz = arr.length; i < iz; ++i) { elem = arr[i]; result += isArray(elem) ? flattenToString(elem) : elem; } return result; }
[ "function", "flattenToString", "(", "arr", ")", "{", "var", "i", ",", "iz", ",", "elem", ",", "result", "=", "''", ";", "for", "(", "i", "=", "0", ",", "iz", "=", "arr", ".", "length", ";", "i", "<", "iz", ";", "++", "i", ")", "{", "elem", ...
flatten an array to a string, where the array can contain either strings or nested arrays
[ "flatten", "an", "array", "to", "a", "string", "where", "the", "array", "can", "contain", "either", "strings", "or", "nested", "arrays" ]
4a93ffc24378722dbfd8859d633746ef5916ce86
https://github.com/estools/escodegen/blob/4a93ffc24378722dbfd8859d633746ef5916ce86/benchmark/old.js#L586-L593
9,073
estools/escodegen
benchmark/old.js
toSourceNodeWhenNeeded
function toSourceNodeWhenNeeded(generated, node) { if (!sourceMap) { // with no source maps, generated is either an // array or a string. if an array, flatten it. // if a string, just return it if (isArray(generated)) { return flattenToString(generated); } else { return generated; } } if (node == null) { if (generated instanceof SourceNode) { return generated; } else { node = {}; } } if (node.loc == null) { return new SourceNode(null, null, sourceMap, generated, node.name || null); } return new SourceNode(node.loc.start.line, node.loc.start.column, (sourceMap === true ? node.loc.source || null : sourceMap), generated, node.name || null); }
javascript
function toSourceNodeWhenNeeded(generated, node) { if (!sourceMap) { // with no source maps, generated is either an // array or a string. if an array, flatten it. // if a string, just return it if (isArray(generated)) { return flattenToString(generated); } else { return generated; } } if (node == null) { if (generated instanceof SourceNode) { return generated; } else { node = {}; } } if (node.loc == null) { return new SourceNode(null, null, sourceMap, generated, node.name || null); } return new SourceNode(node.loc.start.line, node.loc.start.column, (sourceMap === true ? node.loc.source || null : sourceMap), generated, node.name || null); }
[ "function", "toSourceNodeWhenNeeded", "(", "generated", ",", "node", ")", "{", "if", "(", "!", "sourceMap", ")", "{", "// with no source maps, generated is either an", "// array or a string. if an array, flatten it.", "// if a string, just return it", "if", "(", "isArray", "...
convert generated to a SourceNode when source maps are enabled.
[ "convert", "generated", "to", "a", "SourceNode", "when", "source", "maps", "are", "enabled", "." ]
4a93ffc24378722dbfd8859d633746ef5916ce86
https://github.com/estools/escodegen/blob/4a93ffc24378722dbfd8859d633746ef5916ce86/benchmark/old.js#L598-L620
9,074
TonyGermaneri/canvas-datagrid
lib/draw.js
fillArray
function fillArray(low, high, step, def) { step = step || 1; var i = [], x; for (x = low; x <= high; x += step) { i[x] = def === undefined ? x : (typeof def === 'function' ? def(x) : def); } return i; }
javascript
function fillArray(low, high, step, def) { step = step || 1; var i = [], x; for (x = low; x <= high; x += step) { i[x] = def === undefined ? x : (typeof def === 'function' ? def(x) : def); } return i; }
[ "function", "fillArray", "(", "low", ",", "high", ",", "step", ",", "def", ")", "{", "step", "=", "step", "||", "1", ";", "var", "i", "=", "[", "]", ",", "x", ";", "for", "(", "x", "=", "low", ";", "x", "<=", "high", ";", "x", "+=", "step",...
more heavyweight version than fillArray defined in intf.js
[ "more", "heavyweight", "version", "than", "fillArray", "defined", "in", "intf", ".", "js" ]
71217ae00f26cadbbfa884bc94617435762d24d3
https://github.com/TonyGermaneri/canvas-datagrid/blob/71217ae00f26cadbbfa884bc94617435762d24d3/lib/draw.js#L16-L23
9,075
TonyGermaneri/canvas-datagrid
tutorials/tutorials.js
createData
function createData() { var x, y, d = []; for (x = 0; x < 100; x += 1) { d[x] = {}; for (y = 0; y < 20; y += 1) { d[x][y] = y * x; } } return d; }
javascript
function createData() { var x, y, d = []; for (x = 0; x < 100; x += 1) { d[x] = {}; for (y = 0; y < 20; y += 1) { d[x][y] = y * x; } } return d; }
[ "function", "createData", "(", ")", "{", "var", "x", ",", "y", ",", "d", "=", "[", "]", ";", "for", "(", "x", "=", "0", ";", "x", "<", "100", ";", "x", "+=", "1", ")", "{", "d", "[", "x", "]", "=", "{", "}", ";", "for", "(", "y", "=",...
this is not a real mode, just for fun you'll probably have to refresh the page to get rid of this timer
[ "this", "is", "not", "a", "real", "mode", "just", "for", "fun", "you", "ll", "probably", "have", "to", "refresh", "the", "page", "to", "get", "rid", "of", "this", "timer" ]
71217ae00f26cadbbfa884bc94617435762d24d3
https://github.com/TonyGermaneri/canvas-datagrid/blob/71217ae00f26cadbbfa884bc94617435762d24d3/tutorials/tutorials.js#L1017-L1026
9,076
TonyGermaneri/canvas-datagrid
lib/events.js
checkScrollBoxVisibility
function checkScrollBoxVisibility() { self.scrollBox.horizontalBarVisible = (self.style.width !== 'auto' && dataWidth > self.scrollBox.width && self.style.overflowX !== 'hidden') || self.style.overflowX === 'scroll'; self.scrollBox.horizontalBoxVisible = dataWidth > self.scrollBox.width; self.scrollBox.verticalBarVisible = (self.style.height !== 'auto' && dataHeight > self.scrollBox.height && self.style.overflowY !== 'hidden') || self.style.overflowY === 'scroll'; self.scrollBox.verticalBoxVisible = dataHeight > self.scrollBox.height; }
javascript
function checkScrollBoxVisibility() { self.scrollBox.horizontalBarVisible = (self.style.width !== 'auto' && dataWidth > self.scrollBox.width && self.style.overflowX !== 'hidden') || self.style.overflowX === 'scroll'; self.scrollBox.horizontalBoxVisible = dataWidth > self.scrollBox.width; self.scrollBox.verticalBarVisible = (self.style.height !== 'auto' && dataHeight > self.scrollBox.height && self.style.overflowY !== 'hidden') || self.style.overflowY === 'scroll'; self.scrollBox.verticalBoxVisible = dataHeight > self.scrollBox.height; }
[ "function", "checkScrollBoxVisibility", "(", ")", "{", "self", ".", "scrollBox", ".", "horizontalBarVisible", "=", "(", "self", ".", "style", ".", "width", "!==", "'auto'", "&&", "dataWidth", ">", "self", ".", "scrollBox", ".", "width", "&&", "self", ".", ...
sets actual DOM canvas element
[ "sets", "actual", "DOM", "canvas", "element" ]
71217ae00f26cadbbfa884bc94617435762d24d3
https://github.com/TonyGermaneri/canvas-datagrid/blob/71217ae00f26cadbbfa884bc94617435762d24d3/lib/events.js#L123-L130
9,077
architect/architect
src/create/aws/create-events/index.js
createTopic
function createTopic(env, callback) { sns.createTopic({ Name: `${params.app}-${env}-${params.event}`, }, function _createTopic(err) { if (err) { console.log(err) } setTimeout(callback, 0) }) }
javascript
function createTopic(env, callback) { sns.createTopic({ Name: `${params.app}-${env}-${params.event}`, }, function _createTopic(err) { if (err) { console.log(err) } setTimeout(callback, 0) }) }
[ "function", "createTopic", "(", "env", ",", "callback", ")", "{", "sns", ".", "createTopic", "(", "{", "Name", ":", "`", "${", "params", ".", "app", "}", "${", "env", "}", "${", "params", ".", "event", "}", "`", ",", "}", ",", "function", "_createT...
creates an sns topic
[ "creates", "an", "sns", "topic" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/create/aws/create-events/index.js#L22-L32
9,078
architect/architect
src/deploy/lambda-all/00-read.js
filter
function filter(p) { if (filters.length === 0) return true let predicate = false filters.forEach(section=> { let current = path.join('src', section) if (p.startsWith(current)) { predicate = true } }) return predicate }
javascript
function filter(p) { if (filters.length === 0) return true let predicate = false filters.forEach(section=> { let current = path.join('src', section) if (p.startsWith(current)) { predicate = true } }) return predicate }
[ "function", "filter", "(", "p", ")", "{", "if", "(", "filters", ".", "length", "===", "0", ")", "return", "true", "let", "predicate", "=", "false", "filters", ".", "forEach", "(", "section", "=>", "{", "let", "current", "=", "path", ".", "join", "(",...
if filters exist only deploy functions of that type
[ "if", "filters", "exist", "only", "deploy", "functions", "of", "that", "type" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/deploy/lambda-all/00-read.js#L11-L22
9,079
architect/architect
src/sandbox/db/index.js
start
function start(callback) { let handle = {close(){server.close()}} check(function _check(err, inUse) { if (err) throw err if (inUse) { server = {close(){}} init(callback) } else { server = dynalite({ createTableMs: 0 }).listen(5000, function _server(err) { if (err) { // if we err then the db has been started elsewhere.. // just try to continue console.log(err) } init(callback) }) } }) return handle }
javascript
function start(callback) { let handle = {close(){server.close()}} check(function _check(err, inUse) { if (err) throw err if (inUse) { server = {close(){}} init(callback) } else { server = dynalite({ createTableMs: 0 }).listen(5000, function _server(err) { if (err) { // if we err then the db has been started elsewhere.. // just try to continue console.log(err) } init(callback) }) } }) return handle }
[ "function", "start", "(", "callback", ")", "{", "let", "handle", "=", "{", "close", "(", ")", "{", "server", ".", "close", "(", ")", "}", "}", "check", "(", "function", "_check", "(", "err", ",", "inUse", ")", "{", "if", "(", "err", ")", "throw",...
starts an in-memory dynalite dynamodb server - automatically creates any tables or indexes defined by the arcfile - also creates a local session table
[ "starts", "an", "in", "-", "memory", "dynalite", "dynamodb", "server" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/sandbox/db/index.js#L12-L34
9,080
architect/architect
src/sandbox/events/index.js
start
function start(callback) { let {arc} = readArc() let close = x=> !x // if .arc has events and we're not clobbering with ARC_LOCAL flag if (arc.events || arc.queues) { // start a little web server let server = http.createServer(function listener(req, res) { let body = '' req.on('data', chunk => { body += chunk.toString() }) req.on('end', () => { let message = JSON.parse(body) if (req.url === '/queues') { message.arcType = 'queue' } else if (req.url === '/events' || req.url === '/') { message.arcType = 'event' } else { res.statusCode = 404 res.end('not found') console.log(chalk.red.dim('event bus 404 for URL ' + req.url)) return } console.log(chalk.grey.dim('@' + message.arcType), chalk.green.dim(JSON.stringify(JSON.parse(body), null, 2))) // spawn a fork of the node process let subprocess = fork(path.join(__dirname, '_subprocess.js')) subprocess.send(message) subprocess.on('message', function _message(msg) { console.log(chalk.grey.dim(msg.text)) }) res.statusCode = 200 res.end('ok') }) }) // ends our little web server close = function _closer() { try { server.close() } catch(e) { console.log('swallowing server.close error in sandbox events', e) } } // start listening on 3334 server.listen(3334, callback ? callback: x=>!x) } else { callback() } return {close} }
javascript
function start(callback) { let {arc} = readArc() let close = x=> !x // if .arc has events and we're not clobbering with ARC_LOCAL flag if (arc.events || arc.queues) { // start a little web server let server = http.createServer(function listener(req, res) { let body = '' req.on('data', chunk => { body += chunk.toString() }) req.on('end', () => { let message = JSON.parse(body) if (req.url === '/queues') { message.arcType = 'queue' } else if (req.url === '/events' || req.url === '/') { message.arcType = 'event' } else { res.statusCode = 404 res.end('not found') console.log(chalk.red.dim('event bus 404 for URL ' + req.url)) return } console.log(chalk.grey.dim('@' + message.arcType), chalk.green.dim(JSON.stringify(JSON.parse(body), null, 2))) // spawn a fork of the node process let subprocess = fork(path.join(__dirname, '_subprocess.js')) subprocess.send(message) subprocess.on('message', function _message(msg) { console.log(chalk.grey.dim(msg.text)) }) res.statusCode = 200 res.end('ok') }) }) // ends our little web server close = function _closer() { try { server.close() } catch(e) { console.log('swallowing server.close error in sandbox events', e) } } // start listening on 3334 server.listen(3334, callback ? callback: x=>!x) } else { callback() } return {close} }
[ "function", "start", "(", "callback", ")", "{", "let", "{", "arc", "}", "=", "readArc", "(", ")", "let", "close", "=", "x", "=>", "!", "x", "// if .arc has events and we're not clobbering with ARC_LOCAL flag", "if", "(", "arc", ".", "events", "||", "arc", "....
creates a little web server that listens for events on 3334
[ "creates", "a", "little", "web", "server", "that", "listens", "for", "events", "on", "3334" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/sandbox/events/index.js#L12-L64
9,081
architect/architect
src/sandbox/env/index.js
_readArc
function _readArc(callback) { let parsed = readArc() arc = parsed.arc inventory(arc, null, function _arc(err, result) { if (err) callback(err) else { pathToCode = result.localPaths callback() } }) }
javascript
function _readArc(callback) { let parsed = readArc() arc = parsed.arc inventory(arc, null, function _arc(err, result) { if (err) callback(err) else { pathToCode = result.localPaths callback() } }) }
[ "function", "_readArc", "(", "callback", ")", "{", "let", "parsed", "=", "readArc", "(", ")", "arc", "=", "parsed", ".", "arc", "inventory", "(", "arc", ",", "null", ",", "function", "_arc", "(", "err", ",", "result", ")", "{", "if", "(", "err", ")...
Shared copier and env need Arc inventory
[ "Shared", "copier", "and", "env", "need", "Arc", "inventory" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/sandbox/env/index.js#L12-L22
9,082
architect/architect
src/hydrate/shared/_arc.js
copy
function copy(source, destination, callback) { cp(source, destination, {overwrite: true}, function done(err) { if (err) callback(err) else callback() }) }
javascript
function copy(source, destination, callback) { cp(source, destination, {overwrite: true}, function done(err) { if (err) callback(err) else callback() }) }
[ "function", "copy", "(", "source", ",", "destination", ",", "callback", ")", "{", "cp", "(", "source", ",", "destination", ",", "{", "overwrite", ":", "true", "}", ",", "function", "done", "(", "err", ")", "{", "if", "(", "err", ")", "callback", "(",...
Reusable copier, always overwrites
[ "Reusable", "copier", "always", "overwrites" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/hydrate/shared/_arc.js#L47-L52
9,083
architect/architect
src/create/aws/create-event-lambda-deployments/_get-sns-topic-arn.js
listTopics
function listTopics(next, done) { let params = next? {NextToken:next} : {} sns.listTopics(params, function _listTopics(err, result) { if (err) { done(err) } else { // keep track of our current iteration let index = 0 let tidy = t=> t.TopicArn.split(':').reverse().shift() // iterate the topics seeking our name result.Topics.map(tidy).forEach(t=> { if (t === name) { found = result.Topics[index].TopicArn } index += 1 }) // if there are more pages walk those let more = result.NextToken && !found if (more) { listTopics(result.NextToken, done) } else { // otherwise we're done walking done() } } }) }
javascript
function listTopics(next, done) { let params = next? {NextToken:next} : {} sns.listTopics(params, function _listTopics(err, result) { if (err) { done(err) } else { // keep track of our current iteration let index = 0 let tidy = t=> t.TopicArn.split(':').reverse().shift() // iterate the topics seeking our name result.Topics.map(tidy).forEach(t=> { if (t === name) { found = result.Topics[index].TopicArn } index += 1 }) // if there are more pages walk those let more = result.NextToken && !found if (more) { listTopics(result.NextToken, done) } else { // otherwise we're done walking done() } } }) }
[ "function", "listTopics", "(", "next", ",", "done", ")", "{", "let", "params", "=", "next", "?", "{", "NextToken", ":", "next", "}", ":", "{", "}", "sns", ".", "listTopics", "(", "params", ",", "function", "_listTopics", "(", "err", ",", "result", ")...
aws-sdk isn't the friendliest api we need to recurse thru topics searching for the arn
[ "aws", "-", "sdk", "isn", "t", "the", "friendliest", "api", "we", "need", "to", "recurse", "thru", "topics", "searching", "for", "the", "arn" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/create/aws/create-event-lambda-deployments/_get-sns-topic-arn.js#L10-L38
9,084
architect/architect
src/audit/_sync-role.js
read
function read(callback) { let raw = fs.readFileSync(thing.path).toString() //let json = thing.path.split('.').reverse()[0] === 'json' // TODO add support for role.yaml let policies = JSON.parse(raw).policies callback(null, policies || []) }
javascript
function read(callback) { let raw = fs.readFileSync(thing.path).toString() //let json = thing.path.split('.').reverse()[0] === 'json' // TODO add support for role.yaml let policies = JSON.parse(raw).policies callback(null, policies || []) }
[ "function", "read", "(", "callback", ")", "{", "let", "raw", "=", "fs", ".", "readFileSync", "(", "thing", ".", "path", ")", ".", "toString", "(", ")", "//let json = thing.path.split('.').reverse()[0] === 'json'", "// TODO add support for role.yaml", "let", "policies"...
read the managed policies
[ "read", "the", "managed", "policies" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/audit/_sync-role.js#L20-L26
9,085
architect/architect
src/audit/_sync-role.js
removes
function removes(result, callback) { let fns = result.AttachedPolicies.map(p=> { return function maybeRemove(callback) { let PolicyArn = p.PolicyArn if (policies.includes(PolicyArn)) { callback() } else { iam.detachRolePolicy({ RoleName, PolicyArn }, callback) } } }) series(fns, callback) }
javascript
function removes(result, callback) { let fns = result.AttachedPolicies.map(p=> { return function maybeRemove(callback) { let PolicyArn = p.PolicyArn if (policies.includes(PolicyArn)) { callback() } else { iam.detachRolePolicy({ RoleName, PolicyArn }, callback) } } }) series(fns, callback) }
[ "function", "removes", "(", "result", ",", "callback", ")", "{", "let", "fns", "=", "result", ".", "AttachedPolicies", ".", "map", "(", "p", "=>", "{", "return", "function", "maybeRemove", "(", "callback", ")", "{", "let", "PolicyArn", "=", "p", ".", "...
if not in the list remove it
[ "if", "not", "in", "the", "list", "remove", "it" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/audit/_sync-role.js#L63-L79
9,086
architect/architect
src/audit/_sync-role.js
adds
function adds(result, callback) { let fns = policies.map(PolicyArn=> { return function maybeAdd(callback) { iam.attachRolePolicy({ RoleName, PolicyArn }, callback) } }) series(fns, callback) }
javascript
function adds(result, callback) { let fns = policies.map(PolicyArn=> { return function maybeAdd(callback) { iam.attachRolePolicy({ RoleName, PolicyArn }, callback) } }) series(fns, callback) }
[ "function", "adds", "(", "result", ",", "callback", ")", "{", "let", "fns", "=", "policies", ".", "map", "(", "PolicyArn", "=>", "{", "return", "function", "maybeAdd", "(", "callback", ")", "{", "iam", ".", "attachRolePolicy", "(", "{", "RoleName", ",", ...
attaches policies from role.json
[ "attaches", "policies", "from", "role", ".", "json" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/audit/_sync-role.js#L81-L91
9,087
architect/architect
src/deploy/lambda-one/_zip-impl.js
_read
function _read(callback) { glob(path.join(process.cwd(), pathToCode, '/*'), {dot:true}, callback) }
javascript
function _read(callback) { glob(path.join(process.cwd(), pathToCode, '/*'), {dot:true}, callback) }
[ "function", "_read", "(", "callback", ")", "{", "glob", "(", "path", ".", "join", "(", "process", ".", "cwd", "(", ")", ",", "pathToCode", ",", "'/*'", ")", ",", "{", "dot", ":", "true", "}", ",", "callback", ")", "}" ]
get a handle on the files to zip
[ "get", "a", "handle", "on", "the", "files", "to", "zip" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/deploy/lambda-one/_zip-impl.js#L19-L21
9,088
architect/architect
src/create/aws/create-ws-router/create/route.js
createIntegration
function createIntegration(callback) { setTimeout(function throttle() { let uri = `arn:aws:apigateway:${region}:lambda:path/2015-03-31/functions/${arn}/invocations` // console.log(api) gateway.createIntegration({ ApiId: api.ApiId, IntegrationMethod: 'POST', IntegrationType: 'AWS_PROXY', IntegrationUri: uri }, callback) }, 1000) }
javascript
function createIntegration(callback) { setTimeout(function throttle() { let uri = `arn:aws:apigateway:${region}:lambda:path/2015-03-31/functions/${arn}/invocations` // console.log(api) gateway.createIntegration({ ApiId: api.ApiId, IntegrationMethod: 'POST', IntegrationType: 'AWS_PROXY', IntegrationUri: uri }, callback) }, 1000) }
[ "function", "createIntegration", "(", "callback", ")", "{", "setTimeout", "(", "function", "throttle", "(", ")", "{", "let", "uri", "=", "`", "${", "region", "}", "${", "arn", "}", "`", "// console.log(api)", "gateway", ".", "createIntegration", "(", "{", ...
setup the integration
[ "setup", "the", "integration" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/create/aws/create-ws-router/create/route.js#L18-L29
9,089
architect/architect
src/create/aws/create-ws-router/create/route.js
createRoute
function createRoute(result, callback) { setTimeout(function throttle() { gateway.createRoute({ ApiId: api.ApiId, RouteKey, Target: `integrations/${integrationId}` }, callback) }, 1000) }
javascript
function createRoute(result, callback) { setTimeout(function throttle() { gateway.createRoute({ ApiId: api.ApiId, RouteKey, Target: `integrations/${integrationId}` }, callback) }, 1000) }
[ "function", "createRoute", "(", "result", ",", "callback", ")", "{", "setTimeout", "(", "function", "throttle", "(", ")", "{", "gateway", ".", "createRoute", "(", "{", "ApiId", ":", "api", ".", "ApiId", ",", "RouteKey", ",", "Target", ":", "`", "${", "...
create the route
[ "create", "the", "route" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/create/aws/create-ws-router/create/route.js#L50-L58
9,090
architect/architect
src/create/aws/create-http-static-proxy/read.js
getBucket
function getBucket(env, static) { let staging let production static.forEach(thing=> { if (thing[0] === 'staging') { staging = thing[1] } if (thing[0] === 'production') { production = thing[1] } }) if (env === 'staging') return staging if (env === 'production') return production }
javascript
function getBucket(env, static) { let staging let production static.forEach(thing=> { if (thing[0] === 'staging') { staging = thing[1] } if (thing[0] === 'production') { production = thing[1] } }) if (env === 'staging') return staging if (env === 'production') return production }
[ "function", "getBucket", "(", "env", ",", "static", ")", "{", "let", "staging", "let", "production", "static", ".", "forEach", "(", "thing", "=>", "{", "if", "(", "thing", "[", "0", "]", "===", "'staging'", ")", "{", "staging", "=", "thing", "[", "1"...
helper returns the @static value for the current NODE_ENV
[ "helper", "returns", "the" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/create/aws/create-http-static-proxy/read.js#L36-L51
9,091
architect/architect
src/dns/basic/_domains-create.js
reads
function reads(callback) { parallel({ cert(callback) { acm.listCertificates({}, callback) }, apis(callback) { gw.getRestApis({ limit: 500, }, callback) } }, callback) }
javascript
function reads(callback) { parallel({ cert(callback) { acm.listCertificates({}, callback) }, apis(callback) { gw.getRestApis({ limit: 500, }, callback) } }, callback) }
[ "function", "reads", "(", "callback", ")", "{", "parallel", "(", "{", "cert", "(", "callback", ")", "{", "acm", ".", "listCertificates", "(", "{", "}", ",", "callback", ")", "}", ",", "apis", "(", "callback", ")", "{", "gw", ".", "getRestApis", "(", ...
get the cert and the restapiid
[ "get", "the", "cert", "and", "the", "restapiid" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/dns/basic/_domains-create.js#L17-L28
9,092
architect/architect
src/dns/route53/03-alias.js
getRecordSetsAndDomains
function getRecordSetsAndDomains(result, callback) { HostedZoneId = result.HostedZones.find(i=>i.Name === `${domain}.`).Id parallel({ apis(callback) { gateway.getDomainNames({ limit: 500, }, callback) }, records(callback) { route53.listResourceRecordSets({ HostedZoneId, }, callback) } }, callback) }
javascript
function getRecordSetsAndDomains(result, callback) { HostedZoneId = result.HostedZones.find(i=>i.Name === `${domain}.`).Id parallel({ apis(callback) { gateway.getDomainNames({ limit: 500, }, callback) }, records(callback) { route53.listResourceRecordSets({ HostedZoneId, }, callback) } }, callback) }
[ "function", "getRecordSetsAndDomains", "(", "result", ",", "callback", ")", "{", "HostedZoneId", "=", "result", ".", "HostedZones", ".", "find", "(", "i", "=>", "i", ".", "Name", "===", "`", "${", "domain", "}", "`", ")", ".", "Id", "parallel", "(", "{...
read route53 recordsets and apigateway domains
[ "read", "route53", "recordsets", "and", "apigateway", "domains" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/dns/route53/03-alias.js#L22-L36
9,093
architect/architect
src/deploy/helpers/delta.js
stringify
function stringify(arc) { let fmtTbl = obj=> { let name = Object.keys(obj)[0] let keys = Object.keys(obj[name]) let result = `${name}\n` keys.forEach(key=> { let val = obj[name][key] result += ` ${key} ${val}\n` }) return result } let str = `@app\n${arc.app[0]}\n` ///////////////////////////////// if (arc.http.length > 0) str += `\n@http\n` + arc.http.map(tuple=> tuple.join(' ') + '\n').join('') if (arc.events.length > 0) str += `\n@events\n` + arc.events.join('\n') + '\n' if (arc.queues.length > 0) str += `\n@queues\n` + arc.queues.join('\n') + '\n' if (arc.scheduled.length > 0) str += `\n@scheduled\n` + arc.scheduled.map(v=> v.join(' ')).join('\n') + '\n' if (arc.tables.length > 0) str += `\n@tables\n` + arc.tables.map(fmtTbl).join('\n') if (arc.aws.length > 0) str += `\n@aws\n` + arc.aws.map(tuple=> tuple.join(' ') + '\n').join('') ////////// return str }
javascript
function stringify(arc) { let fmtTbl = obj=> { let name = Object.keys(obj)[0] let keys = Object.keys(obj[name]) let result = `${name}\n` keys.forEach(key=> { let val = obj[name][key] result += ` ${key} ${val}\n` }) return result } let str = `@app\n${arc.app[0]}\n` ///////////////////////////////// if (arc.http.length > 0) str += `\n@http\n` + arc.http.map(tuple=> tuple.join(' ') + '\n').join('') if (arc.events.length > 0) str += `\n@events\n` + arc.events.join('\n') + '\n' if (arc.queues.length > 0) str += `\n@queues\n` + arc.queues.join('\n') + '\n' if (arc.scheduled.length > 0) str += `\n@scheduled\n` + arc.scheduled.map(v=> v.join(' ')).join('\n') + '\n' if (arc.tables.length > 0) str += `\n@tables\n` + arc.tables.map(fmtTbl).join('\n') if (arc.aws.length > 0) str += `\n@aws\n` + arc.aws.map(tuple=> tuple.join(' ') + '\n').join('') ////////// return str }
[ "function", "stringify", "(", "arc", ")", "{", "let", "fmtTbl", "=", "obj", "=>", "{", "let", "name", "=", "Object", ".", "keys", "(", "obj", ")", "[", "0", "]", "let", "keys", "=", "Object", ".", "keys", "(", "obj", "[", "name", "]", ")", "let...
create a .arc string from arc object
[ "create", "a", ".", "arc", "string", "from", "arc", "object" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/deploy/helpers/delta.js#L103-L135
9,094
architect/architect
src/create/aws/_get-iam-role.js
_createRole
function _createRole(callback) { var iam = new aws.IAM iam.createRole({ AssumeRolePolicyDocument: JSON.stringify({ Version: '2012-10-17', Statement: [{ Sid: '', Effect: 'Allow', Principal: { Service: 'lambda.amazonaws.com' }, Action: 'sts:AssumeRole' }] }), Path: '/', RoleName, }, function done(err, result) { if (err) throw err var policies = [ 'arn:aws:iam::aws:policy/AmazonS3FullAccess', 'arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess', 'arn:aws:iam::aws:policy/AmazonSNSFullAccess', 'arn:aws:iam::aws:policy/AmazonSQSFullAccess', 'arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole', 'arn:aws:iam::aws:policy/AmazonAPIGatewayInvokeFullAccess', ].map(PolicyArn=> { return function _attachPolicy(callback) { iam.attachRolePolicy({ RoleName, PolicyArn, }, callback) } }) policies.push(function _putPolicy(callback) { iam.putRolePolicy({ PolicyDocument: JSON.stringify({ 'Version': '2012-10-17', 'Statement': [{ 'Effect': 'Allow', 'Action': [ 'logs:CreateLogGroup', 'logs:CreateLogStream', 'logs:PutLogEvents', 'logs:DescribeLogStreams' ], 'Resource': 'arn:aws:logs:*:*:*' }] }, null, 2), PolicyName: 'ArcLambdaCloudwatchPolicy', RoleName }, callback) }) parallel(policies, function _done(err) { if (err) throw err // the latency magic numbers is a weirder part of cloud setTimeout(function _fakeLatency() { callback(null, result.Role) }, 9999) }) }) }
javascript
function _createRole(callback) { var iam = new aws.IAM iam.createRole({ AssumeRolePolicyDocument: JSON.stringify({ Version: '2012-10-17', Statement: [{ Sid: '', Effect: 'Allow', Principal: { Service: 'lambda.amazonaws.com' }, Action: 'sts:AssumeRole' }] }), Path: '/', RoleName, }, function done(err, result) { if (err) throw err var policies = [ 'arn:aws:iam::aws:policy/AmazonS3FullAccess', 'arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess', 'arn:aws:iam::aws:policy/AmazonSNSFullAccess', 'arn:aws:iam::aws:policy/AmazonSQSFullAccess', 'arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole', 'arn:aws:iam::aws:policy/AmazonAPIGatewayInvokeFullAccess', ].map(PolicyArn=> { return function _attachPolicy(callback) { iam.attachRolePolicy({ RoleName, PolicyArn, }, callback) } }) policies.push(function _putPolicy(callback) { iam.putRolePolicy({ PolicyDocument: JSON.stringify({ 'Version': '2012-10-17', 'Statement': [{ 'Effect': 'Allow', 'Action': [ 'logs:CreateLogGroup', 'logs:CreateLogStream', 'logs:PutLogEvents', 'logs:DescribeLogStreams' ], 'Resource': 'arn:aws:logs:*:*:*' }] }, null, 2), PolicyName: 'ArcLambdaCloudwatchPolicy', RoleName }, callback) }) parallel(policies, function _done(err) { if (err) throw err // the latency magic numbers is a weirder part of cloud setTimeout(function _fakeLatency() { callback(null, result.Role) }, 9999) }) }) }
[ "function", "_createRole", "(", "callback", ")", "{", "var", "iam", "=", "new", "aws", ".", "IAM", "iam", ".", "createRole", "(", "{", "AssumeRolePolicyDocument", ":", "JSON", ".", "stringify", "(", "{", "Version", ":", "'2012-10-17'", ",", "Statement", ":...
create arc-role
[ "create", "arc", "-", "role" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/create/aws/_get-iam-role.js#L34-L98
9,095
architect/architect
src/inventory/index.js
getName
function getName(tuple) { if (Array.isArray(tuple)) { var verb = tuple[0] var path = getLambdaName(tuple[1]) return [`${app}-production-${verb}${path}`, `${app}-staging-${verb}${path}`] } else { var path = getLambdaName(tuple) return [`${app}-production-get${path}`, `${app}-staging-get${path}`] } }
javascript
function getName(tuple) { if (Array.isArray(tuple)) { var verb = tuple[0] var path = getLambdaName(tuple[1]) return [`${app}-production-${verb}${path}`, `${app}-staging-${verb}${path}`] } else { var path = getLambdaName(tuple) return [`${app}-production-get${path}`, `${app}-staging-get${path}`] } }
[ "function", "getName", "(", "tuple", ")", "{", "if", "(", "Array", ".", "isArray", "(", "tuple", ")", ")", "{", "var", "verb", "=", "tuple", "[", "0", "]", "var", "path", "=", "getLambdaName", "(", "tuple", "[", "1", "]", ")", "return", "[", "`",...
gets an http lambda name
[ "gets", "an", "http", "lambda", "name" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/inventory/index.js#L56-L66
9,096
architect/architect
src/inventory/index.js
getSystemName
function getSystemName(tuple) { if (Array.isArray(tuple)) { var verb = tuple[0] var path = getLambdaName(tuple[1]) return `${verb}${path}` } else { var path = getLambdaName(tuple) return `get${path}` } }
javascript
function getSystemName(tuple) { if (Array.isArray(tuple)) { var verb = tuple[0] var path = getLambdaName(tuple[1]) return `${verb}${path}` } else { var path = getLambdaName(tuple) return `get${path}` } }
[ "function", "getSystemName", "(", "tuple", ")", "{", "if", "(", "Array", ".", "isArray", "(", "tuple", ")", ")", "{", "var", "verb", "=", "tuple", "[", "0", "]", "var", "path", "=", "getLambdaName", "(", "tuple", "[", "1", "]", ")", "return", "`", ...
gets an http filesystem name
[ "gets", "an", "http", "filesystem", "name" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/inventory/index.js#L83-L93
9,097
architect/architect
src/inventory/index.js
getLegacyName
function getLegacyName(tuple) { if (Array.isArray(tuple)) { var verb = tuple[0] var path = getLegacyLambdaName(tuple[1]) return [`${app}-production-${verb}${path}`, `${app}-staging-${verb}${path}`] } else { var path = getLegacyLambdaName(tuple) return [`${app}-production-get${path}`, `${app}-staging-get${path}`] } }
javascript
function getLegacyName(tuple) { if (Array.isArray(tuple)) { var verb = tuple[0] var path = getLegacyLambdaName(tuple[1]) return [`${app}-production-${verb}${path}`, `${app}-staging-${verb}${path}`] } else { var path = getLegacyLambdaName(tuple) return [`${app}-production-get${path}`, `${app}-staging-get${path}`] } }
[ "function", "getLegacyName", "(", "tuple", ")", "{", "if", "(", "Array", ".", "isArray", "(", "tuple", ")", ")", "{", "var", "verb", "=", "tuple", "[", "0", "]", "var", "path", "=", "getLegacyLambdaName", "(", "tuple", "[", "1", "]", ")", "return", ...
gets an legacy lambda name
[ "gets", "an", "legacy", "lambda", "name" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/inventory/index.js#L96-L106
9,098
architect/architect
src/inventory/index.js
getLegacySystemName
function getLegacySystemName(tuple) { if (Array.isArray(tuple)) { var verb = tuple[0] var path = getLegacyLambdaName(tuple[1]) return `${verb}${path}` } else { var path = getLegacyLambdaName(tuple) return `get${path}` } }
javascript
function getLegacySystemName(tuple) { if (Array.isArray(tuple)) { var verb = tuple[0] var path = getLegacyLambdaName(tuple[1]) return `${verb}${path}` } else { var path = getLegacyLambdaName(tuple) return `get${path}` } }
[ "function", "getLegacySystemName", "(", "tuple", ")", "{", "if", "(", "Array", ".", "isArray", "(", "tuple", ")", ")", "{", "var", "verb", "=", "tuple", "[", "0", "]", "var", "path", "=", "getLegacyLambdaName", "(", "tuple", "[", "1", "]", ")", "retu...
gets an legacy filesystem name
[ "gets", "an", "legacy", "filesystem", "name" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/inventory/index.js#L109-L119
9,099
architect/architect
src/inventory/index.js
getScheduledName
function getScheduledName(arr) { var name = arr.slice(0).shift() return [`${app}-production-${name}`, `${app}-staging-${name}`] }
javascript
function getScheduledName(arr) { var name = arr.slice(0).shift() return [`${app}-production-${name}`, `${app}-staging-${name}`] }
[ "function", "getScheduledName", "(", "arr", ")", "{", "var", "name", "=", "arr", ".", "slice", "(", "0", ")", ".", "shift", "(", ")", "return", "[", "`", "${", "app", "}", "${", "name", "}", "`", ",", "`", "${", "app", "}", "${", "name", "}", ...
get a scheduled lambda name
[ "get", "a", "scheduled", "lambda", "name" ]
c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd
https://github.com/architect/architect/blob/c5fd0b9b73ce57f2a34cf854ff8e49cc671468dd/src/inventory/index.js#L127-L130