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
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
6,500
mongodb/node-mongodb-native
lib/operations/admin_ops.js
validateCollection
function validateCollection(admin, collectionName, options, callback) { const command = { validate: collectionName }; const keys = Object.keys(options); // Decorate command with extra options for (let i = 0; i < keys.length; i++) { if (options.hasOwnProperty(keys[i]) && keys[i] !== 'session') { command[keys[i]] = options[keys[i]]; } } executeCommand(admin.s.db, command, options, (err, doc) => { if (err != null) return callback(err, null); if (doc.ok === 0) return callback(new Error('Error with validate command'), null); if (doc.result != null && doc.result.constructor !== String) return callback(new Error('Error with validation data'), null); if (doc.result != null && doc.result.match(/exception|corrupt/) != null) return callback(new Error('Error: invalid collection ' + collectionName), null); if (doc.valid != null && !doc.valid) return callback(new Error('Error: invalid collection ' + collectionName), null); return callback(null, doc); }); }
javascript
function validateCollection(admin, collectionName, options, callback) { const command = { validate: collectionName }; const keys = Object.keys(options); // Decorate command with extra options for (let i = 0; i < keys.length; i++) { if (options.hasOwnProperty(keys[i]) && keys[i] !== 'session') { command[keys[i]] = options[keys[i]]; } } executeCommand(admin.s.db, command, options, (err, doc) => { if (err != null) return callback(err, null); if (doc.ok === 0) return callback(new Error('Error with validate command'), null); if (doc.result != null && doc.result.constructor !== String) return callback(new Error('Error with validation data'), null); if (doc.result != null && doc.result.match(/exception|corrupt/) != null) return callback(new Error('Error: invalid collection ' + collectionName), null); if (doc.valid != null && !doc.valid) return callback(new Error('Error: invalid collection ' + collectionName), null); return callback(null, doc); }); }
[ "function", "validateCollection", "(", "admin", ",", "collectionName", ",", "options", ",", "callback", ")", "{", "const", "command", "=", "{", "validate", ":", "collectionName", "}", ";", "const", "keys", "=", "Object", ".", "keys", "(", "options", ")", ";", "// Decorate command with extra options", "for", "(", "let", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "i", "++", ")", "{", "if", "(", "options", ".", "hasOwnProperty", "(", "keys", "[", "i", "]", ")", "&&", "keys", "[", "i", "]", "!==", "'session'", ")", "{", "command", "[", "keys", "[", "i", "]", "]", "=", "options", "[", "keys", "[", "i", "]", "]", ";", "}", "}", "executeCommand", "(", "admin", ".", "s", ".", "db", ",", "command", ",", "options", ",", "(", "err", ",", "doc", ")", "=>", "{", "if", "(", "err", "!=", "null", ")", "return", "callback", "(", "err", ",", "null", ")", ";", "if", "(", "doc", ".", "ok", "===", "0", ")", "return", "callback", "(", "new", "Error", "(", "'Error with validate command'", ")", ",", "null", ")", ";", "if", "(", "doc", ".", "result", "!=", "null", "&&", "doc", ".", "result", ".", "constructor", "!==", "String", ")", "return", "callback", "(", "new", "Error", "(", "'Error with validation data'", ")", ",", "null", ")", ";", "if", "(", "doc", ".", "result", "!=", "null", "&&", "doc", ".", "result", ".", "match", "(", "/", "exception|corrupt", "/", ")", "!=", "null", ")", "return", "callback", "(", "new", "Error", "(", "'Error: invalid collection '", "+", "collectionName", ")", ",", "null", ")", ";", "if", "(", "doc", ".", "valid", "!=", "null", "&&", "!", "doc", ".", "valid", ")", "return", "callback", "(", "new", "Error", "(", "'Error: invalid collection '", "+", "collectionName", ")", ",", "null", ")", ";", "return", "callback", "(", "null", ",", "doc", ")", ";", "}", ")", ";", "}" ]
Validate an existing collection @param {Admin} a collection instance. @param {string} collectionName The name of the collection to validate. @param {Object} [options] Optional settings. See Admin.prototype.validateCollection for a list of options. @param {Admin~resultCallback} [callback] The command result callback.
[ "Validate", "an", "existing", "collection" ]
0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5
https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/admin_ops.js#L36-L60
6,501
mongodb/node-mongodb-native
lib/operations/mongo_client_ops.js
collectEvents
function collectEvents(mongoClient, topology) { let MongoClient = loadClient(); const collectedEvents = []; if (mongoClient instanceof MongoClient) { monitoringEvents.forEach(event => { topology.on(event, (object1, object2) => { if (event === 'open') { collectedEvents.push({ event: event, object1: mongoClient }); } else { collectedEvents.push({ event: event, object1: object1, object2: object2 }); } }); }); } return collectedEvents; }
javascript
function collectEvents(mongoClient, topology) { let MongoClient = loadClient(); const collectedEvents = []; if (mongoClient instanceof MongoClient) { monitoringEvents.forEach(event => { topology.on(event, (object1, object2) => { if (event === 'open') { collectedEvents.push({ event: event, object1: mongoClient }); } else { collectedEvents.push({ event: event, object1: object1, object2: object2 }); } }); }); } return collectedEvents; }
[ "function", "collectEvents", "(", "mongoClient", ",", "topology", ")", "{", "let", "MongoClient", "=", "loadClient", "(", ")", ";", "const", "collectedEvents", "=", "[", "]", ";", "if", "(", "mongoClient", "instanceof", "MongoClient", ")", "{", "monitoringEvents", ".", "forEach", "(", "event", "=>", "{", "topology", ".", "on", "(", "event", ",", "(", "object1", ",", "object2", ")", "=>", "{", "if", "(", "event", "===", "'open'", ")", "{", "collectedEvents", ".", "push", "(", "{", "event", ":", "event", ",", "object1", ":", "mongoClient", "}", ")", ";", "}", "else", "{", "collectedEvents", ".", "push", "(", "{", "event", ":", "event", ",", "object1", ":", "object1", ",", "object2", ":", "object2", "}", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}", "return", "collectedEvents", ";", "}" ]
Collect all events in order from SDAM
[ "Collect", "all", "events", "in", "order", "from", "SDAM" ]
0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5
https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/mongo_client_ops.js#L144-L161
6,502
mongodb/node-mongodb-native
lib/operations/mongo_client_ops.js
replayEvents
function replayEvents(mongoClient, events) { for (let i = 0; i < events.length; i++) { mongoClient.emit(events[i].event, events[i].object1, events[i].object2); } }
javascript
function replayEvents(mongoClient, events) { for (let i = 0; i < events.length; i++) { mongoClient.emit(events[i].event, events[i].object1, events[i].object2); } }
[ "function", "replayEvents", "(", "mongoClient", ",", "events", ")", "{", "for", "(", "let", "i", "=", "0", ";", "i", "<", "events", ".", "length", ";", "i", "++", ")", "{", "mongoClient", ".", "emit", "(", "events", "[", "i", "]", ".", "event", ",", "events", "[", "i", "]", ".", "object1", ",", "events", "[", "i", "]", ".", "object2", ")", ";", "}", "}" ]
Replay any events due to single server connection switching to Mongos
[ "Replay", "any", "events", "due", "to", "single", "server", "connection", "switching", "to", "Mongos" ]
0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5
https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/mongo_client_ops.js#L502-L506
6,503
mongodb/node-mongodb-native
lib/mongo_client.js
MongoClient
function MongoClient(url, options) { if (!(this instanceof MongoClient)) return new MongoClient(url, options); // Set up event emitter EventEmitter.call(this); // The internal state this.s = { url: url, options: options || {}, promiseLibrary: null, dbCache: {}, sessions: [] }; // Get the promiseLibrary const promiseLibrary = this.s.options.promiseLibrary || Promise; // Add the promise to the internal state this.s.promiseLibrary = promiseLibrary; }
javascript
function MongoClient(url, options) { if (!(this instanceof MongoClient)) return new MongoClient(url, options); // Set up event emitter EventEmitter.call(this); // The internal state this.s = { url: url, options: options || {}, promiseLibrary: null, dbCache: {}, sessions: [] }; // Get the promiseLibrary const promiseLibrary = this.s.options.promiseLibrary || Promise; // Add the promise to the internal state this.s.promiseLibrary = promiseLibrary; }
[ "function", "MongoClient", "(", "url", ",", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "MongoClient", ")", ")", "return", "new", "MongoClient", "(", "url", ",", "options", ")", ";", "// Set up event emitter", "EventEmitter", ".", "call", "(", "this", ")", ";", "// The internal state", "this", ".", "s", "=", "{", "url", ":", "url", ",", "options", ":", "options", "||", "{", "}", ",", "promiseLibrary", ":", "null", ",", "dbCache", ":", "{", "}", ",", "sessions", ":", "[", "]", "}", ";", "// Get the promiseLibrary", "const", "promiseLibrary", "=", "this", ".", "s", ".", "options", ".", "promiseLibrary", "||", "Promise", ";", "// Add the promise to the internal state", "this", ".", "s", ".", "promiseLibrary", "=", "promiseLibrary", ";", "}" ]
A string specifying the level of a ReadConcern @typedef {'local'|'available'|'majority'|'linearizable'|'snapshot'} ReadConcernLevel @see https://docs.mongodb.com/manual/reference/read-concern/index.html#read-concern-levels Creates a new MongoClient instance @class @param {string} url The connection URI string @param {object} [options] Optional settings @param {number} [options.poolSize=5] The maximum size of the individual server pool @param {boolean} [options.ssl=false] Enable SSL connection. @param {boolean} [options.sslValidate=false] Validate mongod server certificate against Certificate Authority @param {buffer} [options.sslCA=undefined] SSL Certificate store binary buffer @param {buffer} [options.sslCert=undefined] SSL Certificate binary buffer @param {buffer} [options.sslKey=undefined] SSL Key file binary buffer @param {string} [options.sslPass=undefined] SSL Certificate pass phrase @param {buffer} [options.sslCRL=undefined] SSL Certificate revocation list binary buffer @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances @param {boolean} [options.noDelay=true] TCP Connection no delay @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled @param {number} [options.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket @param {number} [options.connectTimeoutMS=30000] TCP Connection timeout setting @param {number} [options.family] Version of IP stack. Can be 4, 6 or null (default). If null, will attempt to connect with IPv6, and will fall back to IPv4 on failure @param {number} [options.socketTimeoutMS=360000] TCP Socket timeout setting @param {number} [options.reconnectTries=30] Server attempt to reconnect #times @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry @param {string} [options.replicaSet=undefined] The Replicaset set name @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available @param {string} [options.authSource=undefined] Define the database to authenticate against @param {(number|string)} [options.w] The write concern @param {number} [options.wtimeout] The write concern timeout @param {boolean} [options.j=false] Specify a journal write concern @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver @param {boolean} [options.serializeFunctions=false] Serialize functions on any object @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields @param {boolean} [options.raw=false] Return document results as raw BSON buffers @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST) @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible @param {object} [options.readConcern] Specify a read concern for the collection (only MongoDB 3.2 or higher supported) @param {ReadConcernLevel} [options.readConcern.level='local'] Specify a read concern level for the collection operations (only MongoDB 3.2 or higher supported) @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed) @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug) @param {object} [options.logger=undefined] Custom logger object @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers @param {boolean} [options.promoteLongs=true] Promotes long values to number if they fit inside the 53 bits resolution @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function @param {object} [options.validateOptions=false] Validate MongoClient passed in options for correctness @param {string} [options.appname=undefined] The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections @param {string} [options.auth.user=undefined] The username for auth @param {string} [options.auth.password=undefined] The password for auth @param {string} [options.authMechanism=undefined] Mechanism for authentication: MDEFAULT, GSSAPI, PLAIN, MONGODB-X509, or SCRAM-SHA-1 @param {object} [options.compression] Type of compression to use: snappy or zlib @param {boolean} [options.fsync=false] Specify a file sync write concern @param {array} [options.readPreferenceTags] Read preference tags @param {number} [options.numberOfRetries=5] The number of retries for a tailable cursor @param {boolean} [options.auto_reconnect=true] Enable auto reconnecting for single server instances @param {boolean} [options.monitorCommands=false] Enable command monitoring for this client @param {number} [options.minSize] If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections @param {boolean} [options.useNewUrlParser=false] Determines whether or not to use the new url parser. Enables the new, spec-compliant, url parser shipped in the core driver. This url parser fixes a number of problems with the original parser, and aims to outright replace that parser in the near future. @param {boolean} [options.useUnifiedTopology] Enables the new unified topology layer @param {MongoClient~connectCallback} [callback] The command result callback @return {MongoClient} a MongoClient instance
[ "A", "string", "specifying", "the", "level", "of", "a", "ReadConcern" ]
0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5
https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/mongo_client.js#L123-L142
6,504
mongodb/node-mongodb-native
lib/db.js
Db
function Db(databaseName, topology, options) { options = options || {}; if (!(this instanceof Db)) return new Db(databaseName, topology, options); EventEmitter.call(this); // Get the promiseLibrary const promiseLibrary = options.promiseLibrary || Promise; // Filter the options options = filterOptions(options, legalOptionNames); // Ensure we put the promiseLib in the options options.promiseLibrary = promiseLibrary; // Internal state of the db object this.s = { // Database name databaseName: databaseName, // DbCache dbCache: {}, // Children db's children: [], // Topology topology: topology, // Options options: options, // Logger instance logger: Logger('Db', options), // Get the bson parser bson: topology ? topology.bson : null, // Unpack read preference readPreference: options.readPreference, // Set buffermaxEntries bufferMaxEntries: typeof options.bufferMaxEntries === 'number' ? options.bufferMaxEntries : -1, // Parent db (if chained) parentDb: options.parentDb || null, // Set up the primary key factory or fallback to ObjectID pkFactory: options.pkFactory || ObjectID, // Get native parser nativeParser: options.nativeParser || options.native_parser, // Promise library promiseLibrary: promiseLibrary, // No listener noListener: typeof options.noListener === 'boolean' ? options.noListener : false, // ReadConcern readConcern: options.readConcern }; // Ensure we have a valid db name validateDatabaseName(this.s.databaseName); // Add a read Only property getSingleProperty(this, 'serverConfig', this.s.topology); getSingleProperty(this, 'bufferMaxEntries', this.s.bufferMaxEntries); getSingleProperty(this, 'databaseName', this.s.databaseName); // This is a child db, do not register any listeners if (options.parentDb) return; if (this.s.noListener) return; // Add listeners topology.on('error', createListener(this, 'error', this)); topology.on('timeout', createListener(this, 'timeout', this)); topology.on('close', createListener(this, 'close', this)); topology.on('parseError', createListener(this, 'parseError', this)); topology.once('open', createListener(this, 'open', this)); topology.once('fullsetup', createListener(this, 'fullsetup', this)); topology.once('all', createListener(this, 'all', this)); topology.on('reconnect', createListener(this, 'reconnect', this)); }
javascript
function Db(databaseName, topology, options) { options = options || {}; if (!(this instanceof Db)) return new Db(databaseName, topology, options); EventEmitter.call(this); // Get the promiseLibrary const promiseLibrary = options.promiseLibrary || Promise; // Filter the options options = filterOptions(options, legalOptionNames); // Ensure we put the promiseLib in the options options.promiseLibrary = promiseLibrary; // Internal state of the db object this.s = { // Database name databaseName: databaseName, // DbCache dbCache: {}, // Children db's children: [], // Topology topology: topology, // Options options: options, // Logger instance logger: Logger('Db', options), // Get the bson parser bson: topology ? topology.bson : null, // Unpack read preference readPreference: options.readPreference, // Set buffermaxEntries bufferMaxEntries: typeof options.bufferMaxEntries === 'number' ? options.bufferMaxEntries : -1, // Parent db (if chained) parentDb: options.parentDb || null, // Set up the primary key factory or fallback to ObjectID pkFactory: options.pkFactory || ObjectID, // Get native parser nativeParser: options.nativeParser || options.native_parser, // Promise library promiseLibrary: promiseLibrary, // No listener noListener: typeof options.noListener === 'boolean' ? options.noListener : false, // ReadConcern readConcern: options.readConcern }; // Ensure we have a valid db name validateDatabaseName(this.s.databaseName); // Add a read Only property getSingleProperty(this, 'serverConfig', this.s.topology); getSingleProperty(this, 'bufferMaxEntries', this.s.bufferMaxEntries); getSingleProperty(this, 'databaseName', this.s.databaseName); // This is a child db, do not register any listeners if (options.parentDb) return; if (this.s.noListener) return; // Add listeners topology.on('error', createListener(this, 'error', this)); topology.on('timeout', createListener(this, 'timeout', this)); topology.on('close', createListener(this, 'close', this)); topology.on('parseError', createListener(this, 'parseError', this)); topology.once('open', createListener(this, 'open', this)); topology.once('fullsetup', createListener(this, 'fullsetup', this)); topology.once('all', createListener(this, 'all', this)); topology.on('reconnect', createListener(this, 'reconnect', this)); }
[ "function", "Db", "(", "databaseName", ",", "topology", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "if", "(", "!", "(", "this", "instanceof", "Db", ")", ")", "return", "new", "Db", "(", "databaseName", ",", "topology", ",", "options", ")", ";", "EventEmitter", ".", "call", "(", "this", ")", ";", "// Get the promiseLibrary", "const", "promiseLibrary", "=", "options", ".", "promiseLibrary", "||", "Promise", ";", "// Filter the options", "options", "=", "filterOptions", "(", "options", ",", "legalOptionNames", ")", ";", "// Ensure we put the promiseLib in the options", "options", ".", "promiseLibrary", "=", "promiseLibrary", ";", "// Internal state of the db object", "this", ".", "s", "=", "{", "// Database name", "databaseName", ":", "databaseName", ",", "// DbCache", "dbCache", ":", "{", "}", ",", "// Children db's", "children", ":", "[", "]", ",", "// Topology", "topology", ":", "topology", ",", "// Options", "options", ":", "options", ",", "// Logger instance", "logger", ":", "Logger", "(", "'Db'", ",", "options", ")", ",", "// Get the bson parser", "bson", ":", "topology", "?", "topology", ".", "bson", ":", "null", ",", "// Unpack read preference", "readPreference", ":", "options", ".", "readPreference", ",", "// Set buffermaxEntries", "bufferMaxEntries", ":", "typeof", "options", ".", "bufferMaxEntries", "===", "'number'", "?", "options", ".", "bufferMaxEntries", ":", "-", "1", ",", "// Parent db (if chained)", "parentDb", ":", "options", ".", "parentDb", "||", "null", ",", "// Set up the primary key factory or fallback to ObjectID", "pkFactory", ":", "options", ".", "pkFactory", "||", "ObjectID", ",", "// Get native parser", "nativeParser", ":", "options", ".", "nativeParser", "||", "options", ".", "native_parser", ",", "// Promise library", "promiseLibrary", ":", "promiseLibrary", ",", "// No listener", "noListener", ":", "typeof", "options", ".", "noListener", "===", "'boolean'", "?", "options", ".", "noListener", ":", "false", ",", "// ReadConcern", "readConcern", ":", "options", ".", "readConcern", "}", ";", "// Ensure we have a valid db name", "validateDatabaseName", "(", "this", ".", "s", ".", "databaseName", ")", ";", "// Add a read Only property", "getSingleProperty", "(", "this", ",", "'serverConfig'", ",", "this", ".", "s", ".", "topology", ")", ";", "getSingleProperty", "(", "this", ",", "'bufferMaxEntries'", ",", "this", ".", "s", ".", "bufferMaxEntries", ")", ";", "getSingleProperty", "(", "this", ",", "'databaseName'", ",", "this", ".", "s", ".", "databaseName", ")", ";", "// This is a child db, do not register any listeners", "if", "(", "options", ".", "parentDb", ")", "return", ";", "if", "(", "this", ".", "s", ".", "noListener", ")", "return", ";", "// Add listeners", "topology", ".", "on", "(", "'error'", ",", "createListener", "(", "this", ",", "'error'", ",", "this", ")", ")", ";", "topology", ".", "on", "(", "'timeout'", ",", "createListener", "(", "this", ",", "'timeout'", ",", "this", ")", ")", ";", "topology", ".", "on", "(", "'close'", ",", "createListener", "(", "this", ",", "'close'", ",", "this", ")", ")", ";", "topology", ".", "on", "(", "'parseError'", ",", "createListener", "(", "this", ",", "'parseError'", ",", "this", ")", ")", ";", "topology", ".", "once", "(", "'open'", ",", "createListener", "(", "this", ",", "'open'", ",", "this", ")", ")", ";", "topology", ".", "once", "(", "'fullsetup'", ",", "createListener", "(", "this", ",", "'fullsetup'", ",", "this", ")", ")", ";", "topology", ".", "once", "(", "'all'", ",", "createListener", "(", "this", ",", "'all'", ",", "this", ")", ")", ";", "topology", ".", "on", "(", "'reconnect'", ",", "createListener", "(", "this", ",", "'reconnect'", ",", "this", ")", ")", ";", "}" ]
Creates a new Db instance @class @param {string} databaseName The name of the database this instance represents. @param {(Server|ReplSet|Mongos)} topology The server topology for the database. @param {object} [options] Optional settings. @param {string} [options.authSource] If the database authentication is dependent on another databaseName. @param {(number|string)} [options.w] The write concern. @param {number} [options.wtimeout] The write concern timeout. @param {boolean} [options.j=false] Specify a journal write concern. @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. @param {boolean} [options.raw=false] Return document results as raw BSON buffers. @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited. @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys. @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible @param {object} [options.readConcern] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) @param {ReadConcernLevel} [options.readConcern.level='local'] Specify a read concern level for the collection operations (only MongoDB 3.2 or higher supported) @property {(Server|ReplSet|Mongos)} serverConfig Get the current db topology. @property {number} bufferMaxEntries Current bufferMaxEntries value for the database @property {string} databaseName The name of the database this instance represents. @property {object} options The options associated with the db instance. @property {boolean} native_parser The current value of the parameter native_parser. @property {boolean} slaveOk The current slaveOk value for the db instance. @property {object} writeConcern The current write concern values. @property {object} topology Access the topology object (single server, replicaset or mongos). @fires Db#close @fires Db#reconnect @fires Db#error @fires Db#timeout @fires Db#parseError @fires Db#fullsetup @return {Db} a Db instance.
[ "Creates", "a", "new", "Db", "instance" ]
0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5
https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/db.js#L133-L202
6,505
reduxjs/redux-devtools
packages/react-json-tree/src/JSONIterableNode.js
createItemString
function createItemString(data, limit) { let count = 0; let hasMore = false; if (Number.isSafeInteger(data.size)) { count = data.size; } else { // eslint-disable-next-line no-unused-vars for (const entry of data) { if (limit && count + 1 > limit) { hasMore = true; break; } count += 1; } } return `${hasMore ? '>' : ''}${count} ${count !== 1 ? 'entries' : 'entry'}`; }
javascript
function createItemString(data, limit) { let count = 0; let hasMore = false; if (Number.isSafeInteger(data.size)) { count = data.size; } else { // eslint-disable-next-line no-unused-vars for (const entry of data) { if (limit && count + 1 > limit) { hasMore = true; break; } count += 1; } } return `${hasMore ? '>' : ''}${count} ${count !== 1 ? 'entries' : 'entry'}`; }
[ "function", "createItemString", "(", "data", ",", "limit", ")", "{", "let", "count", "=", "0", ";", "let", "hasMore", "=", "false", ";", "if", "(", "Number", ".", "isSafeInteger", "(", "data", ".", "size", ")", ")", "{", "count", "=", "data", ".", "size", ";", "}", "else", "{", "// eslint-disable-next-line no-unused-vars", "for", "(", "const", "entry", "of", "data", ")", "{", "if", "(", "limit", "&&", "count", "+", "1", ">", "limit", ")", "{", "hasMore", "=", "true", ";", "break", ";", "}", "count", "+=", "1", ";", "}", "}", "return", "`", "${", "hasMore", "?", "'>'", ":", "''", "}", "${", "count", "}", "${", "count", "!==", "1", "?", "'entries'", ":", "'entry'", "}", "`", ";", "}" ]
Returns the "n Items" string for this node, generating and caching it if it hasn't been created yet.
[ "Returns", "the", "n", "Items", "string", "for", "this", "node", "generating", "and", "caching", "it", "if", "it", "hasn", "t", "been", "created", "yet", "." ]
03d1448dc3c47ffd75a8cf07f21399b86d557988
https://github.com/reduxjs/redux-devtools/blob/03d1448dc3c47ffd75a8cf07f21399b86d557988/packages/react-json-tree/src/JSONIterableNode.js#L6-L22
6,506
reduxjs/redux-devtools
packages/redux-devtools-instrument/src/instrument.js
computeWithTryCatch
function computeWithTryCatch(reducer, action, state) { let nextState = state; let nextError; try { nextState = reducer(state, action); } catch (err) { nextError = err.toString(); if (isChrome) { // In Chrome, rethrowing provides better source map support setTimeout(() => { throw err; }); } else { console.error(err); // eslint-disable-line no-console } } return { state: nextState, error: nextError }; }
javascript
function computeWithTryCatch(reducer, action, state) { let nextState = state; let nextError; try { nextState = reducer(state, action); } catch (err) { nextError = err.toString(); if (isChrome) { // In Chrome, rethrowing provides better source map support setTimeout(() => { throw err; }); } else { console.error(err); // eslint-disable-line no-console } } return { state: nextState, error: nextError }; }
[ "function", "computeWithTryCatch", "(", "reducer", ",", "action", ",", "state", ")", "{", "let", "nextState", "=", "state", ";", "let", "nextError", ";", "try", "{", "nextState", "=", "reducer", "(", "state", ",", "action", ")", ";", "}", "catch", "(", "err", ")", "{", "nextError", "=", "err", ".", "toString", "(", ")", ";", "if", "(", "isChrome", ")", "{", "// In Chrome, rethrowing provides better source map support", "setTimeout", "(", "(", ")", "=>", "{", "throw", "err", ";", "}", ")", ";", "}", "else", "{", "console", ".", "error", "(", "err", ")", ";", "// eslint-disable-line no-console", "}", "}", "return", "{", "state", ":", "nextState", ",", "error", ":", "nextError", "}", ";", "}" ]
Computes the next entry with exceptions catching.
[ "Computes", "the", "next", "entry", "with", "exceptions", "catching", "." ]
03d1448dc3c47ffd75a8cf07f21399b86d557988
https://github.com/reduxjs/redux-devtools/blob/03d1448dc3c47ffd75a8cf07f21399b86d557988/packages/redux-devtools-instrument/src/instrument.js#L153-L174
6,507
reduxjs/redux-devtools
packages/redux-devtools-instrument/src/instrument.js
computeNextEntry
function computeNextEntry(reducer, action, state, shouldCatchErrors) { if (!shouldCatchErrors) { return { state: reducer(state, action) }; } return computeWithTryCatch(reducer, action, state); }
javascript
function computeNextEntry(reducer, action, state, shouldCatchErrors) { if (!shouldCatchErrors) { return { state: reducer(state, action) }; } return computeWithTryCatch(reducer, action, state); }
[ "function", "computeNextEntry", "(", "reducer", ",", "action", ",", "state", ",", "shouldCatchErrors", ")", "{", "if", "(", "!", "shouldCatchErrors", ")", "{", "return", "{", "state", ":", "reducer", "(", "state", ",", "action", ")", "}", ";", "}", "return", "computeWithTryCatch", "(", "reducer", ",", "action", ",", "state", ")", ";", "}" ]
Computes the next entry in the log by applying an action.
[ "Computes", "the", "next", "entry", "in", "the", "log", "by", "applying", "an", "action", "." ]
03d1448dc3c47ffd75a8cf07f21399b86d557988
https://github.com/reduxjs/redux-devtools/blob/03d1448dc3c47ffd75a8cf07f21399b86d557988/packages/redux-devtools-instrument/src/instrument.js#L179-L184
6,508
reduxjs/redux-devtools
packages/redux-devtools-instrument/src/instrument.js
recomputeStates
function recomputeStates( computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, shouldCatchErrors ) { // Optimization: exit early and return the same reference // if we know nothing could have changed. if ( !computedStates || minInvalidatedStateIndex === -1 || (minInvalidatedStateIndex >= computedStates.length && computedStates.length === stagedActionIds.length) ) { return computedStates; } const nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex); for (let i = minInvalidatedStateIndex; i < stagedActionIds.length; i++) { const actionId = stagedActionIds[i]; const action = actionsById[actionId].action; const previousEntry = nextComputedStates[i - 1]; const previousState = previousEntry ? previousEntry.state : committedState; const shouldSkip = skippedActionIds.indexOf(actionId) > -1; let entry; if (shouldSkip) { entry = previousEntry; } else { if (shouldCatchErrors && previousEntry && previousEntry.error) { entry = { state: previousState, error: 'Interrupted by an error up the chain' }; } else { entry = computeNextEntry( reducer, action, previousState, shouldCatchErrors ); } } nextComputedStates.push(entry); } return nextComputedStates; }
javascript
function recomputeStates( computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, shouldCatchErrors ) { // Optimization: exit early and return the same reference // if we know nothing could have changed. if ( !computedStates || minInvalidatedStateIndex === -1 || (minInvalidatedStateIndex >= computedStates.length && computedStates.length === stagedActionIds.length) ) { return computedStates; } const nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex); for (let i = minInvalidatedStateIndex; i < stagedActionIds.length; i++) { const actionId = stagedActionIds[i]; const action = actionsById[actionId].action; const previousEntry = nextComputedStates[i - 1]; const previousState = previousEntry ? previousEntry.state : committedState; const shouldSkip = skippedActionIds.indexOf(actionId) > -1; let entry; if (shouldSkip) { entry = previousEntry; } else { if (shouldCatchErrors && previousEntry && previousEntry.error) { entry = { state: previousState, error: 'Interrupted by an error up the chain' }; } else { entry = computeNextEntry( reducer, action, previousState, shouldCatchErrors ); } } nextComputedStates.push(entry); } return nextComputedStates; }
[ "function", "recomputeStates", "(", "computedStates", ",", "minInvalidatedStateIndex", ",", "reducer", ",", "committedState", ",", "actionsById", ",", "stagedActionIds", ",", "skippedActionIds", ",", "shouldCatchErrors", ")", "{", "// Optimization: exit early and return the same reference", "// if we know nothing could have changed.", "if", "(", "!", "computedStates", "||", "minInvalidatedStateIndex", "===", "-", "1", "||", "(", "minInvalidatedStateIndex", ">=", "computedStates", ".", "length", "&&", "computedStates", ".", "length", "===", "stagedActionIds", ".", "length", ")", ")", "{", "return", "computedStates", ";", "}", "const", "nextComputedStates", "=", "computedStates", ".", "slice", "(", "0", ",", "minInvalidatedStateIndex", ")", ";", "for", "(", "let", "i", "=", "minInvalidatedStateIndex", ";", "i", "<", "stagedActionIds", ".", "length", ";", "i", "++", ")", "{", "const", "actionId", "=", "stagedActionIds", "[", "i", "]", ";", "const", "action", "=", "actionsById", "[", "actionId", "]", ".", "action", ";", "const", "previousEntry", "=", "nextComputedStates", "[", "i", "-", "1", "]", ";", "const", "previousState", "=", "previousEntry", "?", "previousEntry", ".", "state", ":", "committedState", ";", "const", "shouldSkip", "=", "skippedActionIds", ".", "indexOf", "(", "actionId", ")", ">", "-", "1", ";", "let", "entry", ";", "if", "(", "shouldSkip", ")", "{", "entry", "=", "previousEntry", ";", "}", "else", "{", "if", "(", "shouldCatchErrors", "&&", "previousEntry", "&&", "previousEntry", ".", "error", ")", "{", "entry", "=", "{", "state", ":", "previousState", ",", "error", ":", "'Interrupted by an error up the chain'", "}", ";", "}", "else", "{", "entry", "=", "computeNextEntry", "(", "reducer", ",", "action", ",", "previousState", ",", "shouldCatchErrors", ")", ";", "}", "}", "nextComputedStates", ".", "push", "(", "entry", ")", ";", "}", "return", "nextComputedStates", ";", "}" ]
Runs the reducer on invalidated actions to get a fresh computation log.
[ "Runs", "the", "reducer", "on", "invalidated", "actions", "to", "get", "a", "fresh", "computation", "log", "." ]
03d1448dc3c47ffd75a8cf07f21399b86d557988
https://github.com/reduxjs/redux-devtools/blob/03d1448dc3c47ffd75a8cf07f21399b86d557988/packages/redux-devtools-instrument/src/instrument.js#L189-L241
6,509
CreateJS/PreloadJS
lib/preloadjs.js
AbstractMediaLoader
function AbstractMediaLoader(loadItem, preferXHR, type) { this.AbstractLoader_constructor(loadItem, preferXHR, type); // public properties this.resultFormatter = this._formatResult; // protected properties this._tagSrcAttribute = "src"; this.on("initialize", this._updateXHR, this); }
javascript
function AbstractMediaLoader(loadItem, preferXHR, type) { this.AbstractLoader_constructor(loadItem, preferXHR, type); // public properties this.resultFormatter = this._formatResult; // protected properties this._tagSrcAttribute = "src"; this.on("initialize", this._updateXHR, this); }
[ "function", "AbstractMediaLoader", "(", "loadItem", ",", "preferXHR", ",", "type", ")", "{", "this", ".", "AbstractLoader_constructor", "(", "loadItem", ",", "preferXHR", ",", "type", ")", ";", "// public properties", "this", ".", "resultFormatter", "=", "this", ".", "_formatResult", ";", "// protected properties", "this", ".", "_tagSrcAttribute", "=", "\"src\"", ";", "this", ".", "on", "(", "\"initialize\"", ",", "this", ".", "_updateXHR", ",", "this", ")", ";", "}" ]
constructor The AbstractMediaLoader is a base class that handles some of the shared methods and properties of loaders that handle HTML media elements, such as Video and Audio. @class AbstractMediaLoader @param {LoadItem|Object} loadItem @param {Boolean} preferXHR @param {String} type The type of media to load. Usually "video" or "audio". @extends AbstractLoader @constructor
[ "constructor", "The", "AbstractMediaLoader", "is", "a", "base", "class", "that", "handles", "some", "of", "the", "shared", "methods", "and", "properties", "of", "loaders", "that", "handle", "HTML", "media", "elements", "such", "as", "Video", "and", "Audio", "." ]
eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083
https://github.com/CreateJS/PreloadJS/blob/eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083/lib/preloadjs.js#L3429-L3439
6,510
CreateJS/PreloadJS
lib/preloadjs.js
XHRRequest
function XHRRequest (item) { this.AbstractRequest_constructor(item); // protected properties /** * A reference to the XHR request used to load the content. * @property _request * @type {XMLHttpRequest | XDomainRequest | ActiveX.XMLHTTP} * @private */ this._request = null; /** * A manual load timeout that is used for browsers that do not support the onTimeout event on XHR (XHR level 1, * typically IE9). * @property _loadTimeout * @type {Number} * @private */ this._loadTimeout = null; /** * The browser's XHR (XMLHTTPRequest) version. Supported versions are 1 and 2. There is no official way to detect * the version, so we use capabilities to make a best guess. * @property _xhrLevel * @type {Number} * @default 1 * @private */ this._xhrLevel = 1; /** * The response of a loaded file. This is set because it is expensive to look up constantly. This property will be * null until the file is loaded. * @property _response * @type {mixed} * @private */ this._response = null; /** * The response of the loaded file before it is modified. In most cases, content is converted from raw text to * an HTML tag or a formatted object which is set to the <code>result</code> property, but the developer may still * want to access the raw content as it was loaded. * @property _rawResponse * @type {String|Object} * @private */ this._rawResponse = null; this._canceled = false; // Setup our event handlers now. this._handleLoadStartProxy = createjs.proxy(this._handleLoadStart, this); this._handleProgressProxy = createjs.proxy(this._handleProgress, this); this._handleAbortProxy = createjs.proxy(this._handleAbort, this); this._handleErrorProxy = createjs.proxy(this._handleError, this); this._handleTimeoutProxy = createjs.proxy(this._handleTimeout, this); this._handleLoadProxy = createjs.proxy(this._handleLoad, this); this._handleReadyStateChangeProxy = createjs.proxy(this._handleReadyStateChange, this); if (!this._createXHR(item)) { //TODO: Throw error? } }
javascript
function XHRRequest (item) { this.AbstractRequest_constructor(item); // protected properties /** * A reference to the XHR request used to load the content. * @property _request * @type {XMLHttpRequest | XDomainRequest | ActiveX.XMLHTTP} * @private */ this._request = null; /** * A manual load timeout that is used for browsers that do not support the onTimeout event on XHR (XHR level 1, * typically IE9). * @property _loadTimeout * @type {Number} * @private */ this._loadTimeout = null; /** * The browser's XHR (XMLHTTPRequest) version. Supported versions are 1 and 2. There is no official way to detect * the version, so we use capabilities to make a best guess. * @property _xhrLevel * @type {Number} * @default 1 * @private */ this._xhrLevel = 1; /** * The response of a loaded file. This is set because it is expensive to look up constantly. This property will be * null until the file is loaded. * @property _response * @type {mixed} * @private */ this._response = null; /** * The response of the loaded file before it is modified. In most cases, content is converted from raw text to * an HTML tag or a formatted object which is set to the <code>result</code> property, but the developer may still * want to access the raw content as it was loaded. * @property _rawResponse * @type {String|Object} * @private */ this._rawResponse = null; this._canceled = false; // Setup our event handlers now. this._handleLoadStartProxy = createjs.proxy(this._handleLoadStart, this); this._handleProgressProxy = createjs.proxy(this._handleProgress, this); this._handleAbortProxy = createjs.proxy(this._handleAbort, this); this._handleErrorProxy = createjs.proxy(this._handleError, this); this._handleTimeoutProxy = createjs.proxy(this._handleTimeout, this); this._handleLoadProxy = createjs.proxy(this._handleLoad, this); this._handleReadyStateChangeProxy = createjs.proxy(this._handleReadyStateChange, this); if (!this._createXHR(item)) { //TODO: Throw error? } }
[ "function", "XHRRequest", "(", "item", ")", "{", "this", ".", "AbstractRequest_constructor", "(", "item", ")", ";", "// protected properties", "/**\n\t\t * A reference to the XHR request used to load the content.\n\t\t * @property _request\n\t\t * @type {XMLHttpRequest | XDomainRequest | ActiveX.XMLHTTP}\n\t\t * @private\n\t\t */", "this", ".", "_request", "=", "null", ";", "/**\n\t\t * A manual load timeout that is used for browsers that do not support the onTimeout event on XHR (XHR level 1,\n\t\t * typically IE9).\n\t\t * @property _loadTimeout\n\t\t * @type {Number}\n\t\t * @private\n\t\t */", "this", ".", "_loadTimeout", "=", "null", ";", "/**\n\t\t * The browser's XHR (XMLHTTPRequest) version. Supported versions are 1 and 2. There is no official way to detect\n\t\t * the version, so we use capabilities to make a best guess.\n\t\t * @property _xhrLevel\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t * @private\n\t\t */", "this", ".", "_xhrLevel", "=", "1", ";", "/**\n\t\t * The response of a loaded file. This is set because it is expensive to look up constantly. This property will be\n\t\t * null until the file is loaded.\n\t\t * @property _response\n\t\t * @type {mixed}\n\t\t * @private\n\t\t */", "this", ".", "_response", "=", "null", ";", "/**\n\t\t * The response of the loaded file before it is modified. In most cases, content is converted from raw text to\n\t\t * an HTML tag or a formatted object which is set to the <code>result</code> property, but the developer may still\n\t\t * want to access the raw content as it was loaded.\n\t\t * @property _rawResponse\n\t\t * @type {String|Object}\n\t\t * @private\n\t\t */", "this", ".", "_rawResponse", "=", "null", ";", "this", ".", "_canceled", "=", "false", ";", "// Setup our event handlers now.", "this", ".", "_handleLoadStartProxy", "=", "createjs", ".", "proxy", "(", "this", ".", "_handleLoadStart", ",", "this", ")", ";", "this", ".", "_handleProgressProxy", "=", "createjs", ".", "proxy", "(", "this", ".", "_handleProgress", ",", "this", ")", ";", "this", ".", "_handleAbortProxy", "=", "createjs", ".", "proxy", "(", "this", ".", "_handleAbort", ",", "this", ")", ";", "this", ".", "_handleErrorProxy", "=", "createjs", ".", "proxy", "(", "this", ".", "_handleError", ",", "this", ")", ";", "this", ".", "_handleTimeoutProxy", "=", "createjs", ".", "proxy", "(", "this", ".", "_handleTimeout", ",", "this", ")", ";", "this", ".", "_handleLoadProxy", "=", "createjs", ".", "proxy", "(", "this", ".", "_handleLoad", ",", "this", ")", ";", "this", ".", "_handleReadyStateChangeProxy", "=", "createjs", ".", "proxy", "(", "this", ".", "_handleReadyStateChange", ",", "this", ")", ";", "if", "(", "!", "this", ".", "_createXHR", "(", "item", ")", ")", "{", "//TODO: Throw error?", "}", "}" ]
constructor A preloader that loads items using XHR requests, usually XMLHttpRequest. However XDomainRequests will be used for cross-domain requests if possible, and older versions of IE fall back on to ActiveX objects when necessary. XHR requests load the content as text or binary data, provide progress and consistent completion events, and can be canceled during load. Note that XHR is not supported in IE 6 or earlier, and is not recommended for cross-domain loading. @class XHRRequest @constructor @param {Object} item The object that defines the file to load. Please see the {{#crossLink "LoadQueue/loadFile"}}{{/crossLink}} for an overview of supported file properties. @extends AbstractLoader
[ "constructor", "A", "preloader", "that", "loads", "items", "using", "XHR", "requests", "usually", "XMLHttpRequest", ".", "However", "XDomainRequests", "will", "be", "used", "for", "cross", "-", "domain", "requests", "if", "possible", "and", "older", "versions", "of", "IE", "fall", "back", "on", "to", "ActiveX", "objects", "when", "necessary", ".", "XHR", "requests", "load", "the", "content", "as", "text", "or", "binary", "data", "provide", "progress", "and", "consistent", "completion", "events", "and", "can", "be", "canceled", "during", "load", ".", "Note", "that", "XHR", "is", "not", "supported", "in", "IE", "6", "or", "earlier", "and", "is", "not", "recommended", "for", "cross", "-", "domain", "loading", "." ]
eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083
https://github.com/CreateJS/PreloadJS/blob/eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083/lib/preloadjs.js#L3839-L3903
6,511
CreateJS/PreloadJS
lib/preloadjs.js
LoadQueue
function LoadQueue (preferXHR, basePath, crossOrigin) { this.AbstractLoader_constructor(); /** * An array of the plugins registered using {{#crossLink "LoadQueue/installPlugin"}}{{/crossLink}}. * @property _plugins * @type {Array} * @private * @since 0.6.1 */ this._plugins = []; /** * An object hash of callbacks that are fired for each file type before the file is loaded, giving plugins the * ability to override properties of the load. Please see the {{#crossLink "LoadQueue/installPlugin"}}{{/crossLink}} * method for more information. * @property _typeCallbacks * @type {Object} * @private */ this._typeCallbacks = {}; /** * An object hash of callbacks that are fired for each file extension before the file is loaded, giving plugins the * ability to override properties of the load. Please see the {{#crossLink "LoadQueue/installPlugin"}}{{/crossLink}} * method for more information. * @property _extensionCallbacks * @type {null} * @private */ this._extensionCallbacks = {}; /** * The next preload queue to process when this one is complete. If an error is thrown in the current queue, and * {{#crossLink "LoadQueue/stopOnError:property"}}{{/crossLink}} is `true`, the next queue will not be processed. * @property next * @type {LoadQueue} * @default null */ this.next = null; /** * Ensure loaded scripts "complete" in the order they are specified. Loaded scripts are added to the document head * once they are loaded. Scripts loaded via tags will load one-at-a-time when this property is `true`, whereas * scripts loaded using XHR can load in any order, but will "finish" and be added to the document in the order * specified. * * Any items can be set to load in order by setting the {{#crossLink "maintainOrder:property"}}{{/crossLink}} * property on the load item, or by ensuring that only one connection can be open at a time using * {{#crossLink "LoadQueue/setMaxConnections"}}{{/crossLink}}. Note that when the `maintainScriptOrder` property * is set to `true`, scripts items are automatically set to `maintainOrder=true`, and changing the * `maintainScriptOrder` to `false` during a load will not change items already in a queue. * * <h4>Example</h4> * * var queue = new createjs.LoadQueue(); * queue.setMaxConnections(3); // Set a higher number to load multiple items at once * queue.maintainScriptOrder = true; // Ensure scripts are loaded in order * queue.loadManifest([ * "script1.js", * "script2.js", * "image.png", // Load any time * {src: "image2.png", maintainOrder: true} // Will wait for script2.js * "image3.png", * "script3.js" // Will wait for image2.png before loading (or completing when loading with XHR) * ]); * * @property maintainScriptOrder * @type {Boolean} * @default true */ this.maintainScriptOrder = true; /** * Determines if the LoadQueue will stop processing the current queue when an error is encountered. * @property stopOnError * @type {Boolean} * @default false */ this.stopOnError = false; /** * The number of maximum open connections that a loadQueue tries to maintain. Please see * {{#crossLink "LoadQueue/setMaxConnections"}}{{/crossLink}} for more information. * @property _maxConnections * @type {Number} * @default 1 * @private */ this._maxConnections = 1; /** * An internal list of all the default Loaders that are included with PreloadJS. Before an item is loaded, the * available loader list is iterated, in the order they are included, and as soon as a loader indicates it can * handle the content, it will be selected. The default loader, ({{#crossLink "TextLoader"}}{{/crossLink}} is * last in the list, so it will be used if no other match is found. Typically, loaders will match based on the * {{#crossLink "LoadItem/type"}}{{/crossLink}}, which is automatically determined using the file extension of * the {{#crossLink "LoadItem/src:property"}}{{/crossLink}}. * * Loaders can be removed from PreloadJS by simply not including them. * * Custom loaders installed using {{#crossLink "registerLoader"}}{{/crossLink}} will be prepended to this list * so that they are checked first. * @property _availableLoaders * @type {Array} * @private * @since 0.6.0 */ this._availableLoaders = [ createjs.FontLoader, createjs.ImageLoader, createjs.JavaScriptLoader, createjs.CSSLoader, createjs.JSONLoader, createjs.JSONPLoader, createjs.SoundLoader, createjs.ManifestLoader, createjs.SpriteSheetLoader, createjs.XMLLoader, createjs.SVGLoader, createjs.BinaryLoader, createjs.VideoLoader, createjs.TextLoader ]; /** * The number of built in loaders, so they can't be removed by {{#crossLink "unregisterLoader"}}{{/crossLink}. * @property _defaultLoaderLength * @type {Number} * @private * @since 0.6.0 */ this._defaultLoaderLength = this._availableLoaders.length; this.init(preferXHR, basePath, crossOrigin); }
javascript
function LoadQueue (preferXHR, basePath, crossOrigin) { this.AbstractLoader_constructor(); /** * An array of the plugins registered using {{#crossLink "LoadQueue/installPlugin"}}{{/crossLink}}. * @property _plugins * @type {Array} * @private * @since 0.6.1 */ this._plugins = []; /** * An object hash of callbacks that are fired for each file type before the file is loaded, giving plugins the * ability to override properties of the load. Please see the {{#crossLink "LoadQueue/installPlugin"}}{{/crossLink}} * method for more information. * @property _typeCallbacks * @type {Object} * @private */ this._typeCallbacks = {}; /** * An object hash of callbacks that are fired for each file extension before the file is loaded, giving plugins the * ability to override properties of the load. Please see the {{#crossLink "LoadQueue/installPlugin"}}{{/crossLink}} * method for more information. * @property _extensionCallbacks * @type {null} * @private */ this._extensionCallbacks = {}; /** * The next preload queue to process when this one is complete. If an error is thrown in the current queue, and * {{#crossLink "LoadQueue/stopOnError:property"}}{{/crossLink}} is `true`, the next queue will not be processed. * @property next * @type {LoadQueue} * @default null */ this.next = null; /** * Ensure loaded scripts "complete" in the order they are specified. Loaded scripts are added to the document head * once they are loaded. Scripts loaded via tags will load one-at-a-time when this property is `true`, whereas * scripts loaded using XHR can load in any order, but will "finish" and be added to the document in the order * specified. * * Any items can be set to load in order by setting the {{#crossLink "maintainOrder:property"}}{{/crossLink}} * property on the load item, or by ensuring that only one connection can be open at a time using * {{#crossLink "LoadQueue/setMaxConnections"}}{{/crossLink}}. Note that when the `maintainScriptOrder` property * is set to `true`, scripts items are automatically set to `maintainOrder=true`, and changing the * `maintainScriptOrder` to `false` during a load will not change items already in a queue. * * <h4>Example</h4> * * var queue = new createjs.LoadQueue(); * queue.setMaxConnections(3); // Set a higher number to load multiple items at once * queue.maintainScriptOrder = true; // Ensure scripts are loaded in order * queue.loadManifest([ * "script1.js", * "script2.js", * "image.png", // Load any time * {src: "image2.png", maintainOrder: true} // Will wait for script2.js * "image3.png", * "script3.js" // Will wait for image2.png before loading (or completing when loading with XHR) * ]); * * @property maintainScriptOrder * @type {Boolean} * @default true */ this.maintainScriptOrder = true; /** * Determines if the LoadQueue will stop processing the current queue when an error is encountered. * @property stopOnError * @type {Boolean} * @default false */ this.stopOnError = false; /** * The number of maximum open connections that a loadQueue tries to maintain. Please see * {{#crossLink "LoadQueue/setMaxConnections"}}{{/crossLink}} for more information. * @property _maxConnections * @type {Number} * @default 1 * @private */ this._maxConnections = 1; /** * An internal list of all the default Loaders that are included with PreloadJS. Before an item is loaded, the * available loader list is iterated, in the order they are included, and as soon as a loader indicates it can * handle the content, it will be selected. The default loader, ({{#crossLink "TextLoader"}}{{/crossLink}} is * last in the list, so it will be used if no other match is found. Typically, loaders will match based on the * {{#crossLink "LoadItem/type"}}{{/crossLink}}, which is automatically determined using the file extension of * the {{#crossLink "LoadItem/src:property"}}{{/crossLink}}. * * Loaders can be removed from PreloadJS by simply not including them. * * Custom loaders installed using {{#crossLink "registerLoader"}}{{/crossLink}} will be prepended to this list * so that they are checked first. * @property _availableLoaders * @type {Array} * @private * @since 0.6.0 */ this._availableLoaders = [ createjs.FontLoader, createjs.ImageLoader, createjs.JavaScriptLoader, createjs.CSSLoader, createjs.JSONLoader, createjs.JSONPLoader, createjs.SoundLoader, createjs.ManifestLoader, createjs.SpriteSheetLoader, createjs.XMLLoader, createjs.SVGLoader, createjs.BinaryLoader, createjs.VideoLoader, createjs.TextLoader ]; /** * The number of built in loaders, so they can't be removed by {{#crossLink "unregisterLoader"}}{{/crossLink}. * @property _defaultLoaderLength * @type {Number} * @private * @since 0.6.0 */ this._defaultLoaderLength = this._availableLoaders.length; this.init(preferXHR, basePath, crossOrigin); }
[ "function", "LoadQueue", "(", "preferXHR", ",", "basePath", ",", "crossOrigin", ")", "{", "this", ".", "AbstractLoader_constructor", "(", ")", ";", "/**\n\t\t * An array of the plugins registered using {{#crossLink \"LoadQueue/installPlugin\"}}{{/crossLink}}.\n\t\t * @property _plugins\n\t\t * @type {Array}\n\t\t * @private\n\t\t * @since 0.6.1\n\t\t */", "this", ".", "_plugins", "=", "[", "]", ";", "/**\n\t\t * An object hash of callbacks that are fired for each file type before the file is loaded, giving plugins the\n\t\t * ability to override properties of the load. Please see the {{#crossLink \"LoadQueue/installPlugin\"}}{{/crossLink}}\n\t\t * method for more information.\n\t\t * @property _typeCallbacks\n\t\t * @type {Object}\n\t\t * @private\n\t\t */", "this", ".", "_typeCallbacks", "=", "{", "}", ";", "/**\n\t\t * An object hash of callbacks that are fired for each file extension before the file is loaded, giving plugins the\n\t\t * ability to override properties of the load. Please see the {{#crossLink \"LoadQueue/installPlugin\"}}{{/crossLink}}\n\t\t * method for more information.\n\t\t * @property _extensionCallbacks\n\t\t * @type {null}\n\t\t * @private\n\t\t */", "this", ".", "_extensionCallbacks", "=", "{", "}", ";", "/**\n\t\t * The next preload queue to process when this one is complete. If an error is thrown in the current queue, and\n\t\t * {{#crossLink \"LoadQueue/stopOnError:property\"}}{{/crossLink}} is `true`, the next queue will not be processed.\n\t\t * @property next\n\t\t * @type {LoadQueue}\n\t\t * @default null\n\t\t */", "this", ".", "next", "=", "null", ";", "/**\n\t\t * Ensure loaded scripts \"complete\" in the order they are specified. Loaded scripts are added to the document head\n\t\t * once they are loaded. Scripts loaded via tags will load one-at-a-time when this property is `true`, whereas\n\t\t * scripts loaded using XHR can load in any order, but will \"finish\" and be added to the document in the order\n\t\t * specified.\n\t\t *\n\t\t * Any items can be set to load in order by setting the {{#crossLink \"maintainOrder:property\"}}{{/crossLink}}\n\t\t * property on the load item, or by ensuring that only one connection can be open at a time using\n\t\t * {{#crossLink \"LoadQueue/setMaxConnections\"}}{{/crossLink}}. Note that when the `maintainScriptOrder` property\n\t\t * is set to `true`, scripts items are automatically set to `maintainOrder=true`, and changing the\n\t\t * `maintainScriptOrder` to `false` during a load will not change items already in a queue.\n\t\t *\n\t\t * <h4>Example</h4>\n\t\t *\n\t\t * var queue = new createjs.LoadQueue();\n\t\t * queue.setMaxConnections(3); // Set a higher number to load multiple items at once\n\t\t * queue.maintainScriptOrder = true; // Ensure scripts are loaded in order\n\t\t * queue.loadManifest([\n\t\t * \"script1.js\",\n\t\t * \"script2.js\",\n\t\t * \"image.png\", // Load any time\n\t\t * {src: \"image2.png\", maintainOrder: true} // Will wait for script2.js\n\t\t * \"image3.png\",\n\t\t * \"script3.js\" // Will wait for image2.png before loading (or completing when loading with XHR)\n\t\t * ]);\n\t\t *\n\t\t * @property maintainScriptOrder\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */", "this", ".", "maintainScriptOrder", "=", "true", ";", "/**\n\t\t * Determines if the LoadQueue will stop processing the current queue when an error is encountered.\n\t\t * @property stopOnError\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */", "this", ".", "stopOnError", "=", "false", ";", "/**\n\t\t * The number of maximum open connections that a loadQueue tries to maintain. Please see\n\t\t * {{#crossLink \"LoadQueue/setMaxConnections\"}}{{/crossLink}} for more information.\n\t\t * @property _maxConnections\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t * @private\n\t\t */", "this", ".", "_maxConnections", "=", "1", ";", "/**\n\t\t * An internal list of all the default Loaders that are included with PreloadJS. Before an item is loaded, the\n\t\t * available loader list is iterated, in the order they are included, and as soon as a loader indicates it can\n\t\t * handle the content, it will be selected. The default loader, ({{#crossLink \"TextLoader\"}}{{/crossLink}} is\n\t\t * last in the list, so it will be used if no other match is found. Typically, loaders will match based on the\n\t\t * {{#crossLink \"LoadItem/type\"}}{{/crossLink}}, which is automatically determined using the file extension of\n\t\t * the {{#crossLink \"LoadItem/src:property\"}}{{/crossLink}}.\n\t\t *\n\t\t * Loaders can be removed from PreloadJS by simply not including them.\n\t\t *\n\t\t * Custom loaders installed using {{#crossLink \"registerLoader\"}}{{/crossLink}} will be prepended to this list\n\t\t * so that they are checked first.\n\t\t * @property _availableLoaders\n\t\t * @type {Array}\n\t\t * @private\n\t\t * @since 0.6.0\n\t\t */", "this", ".", "_availableLoaders", "=", "[", "createjs", ".", "FontLoader", ",", "createjs", ".", "ImageLoader", ",", "createjs", ".", "JavaScriptLoader", ",", "createjs", ".", "CSSLoader", ",", "createjs", ".", "JSONLoader", ",", "createjs", ".", "JSONPLoader", ",", "createjs", ".", "SoundLoader", ",", "createjs", ".", "ManifestLoader", ",", "createjs", ".", "SpriteSheetLoader", ",", "createjs", ".", "XMLLoader", ",", "createjs", ".", "SVGLoader", ",", "createjs", ".", "BinaryLoader", ",", "createjs", ".", "VideoLoader", ",", "createjs", ".", "TextLoader", "]", ";", "/**\n\t\t * The number of built in loaders, so they can't be removed by {{#crossLink \"unregisterLoader\"}}{{/crossLink}.\n\t\t\t\t * @property _defaultLoaderLength\n\t\t * @type {Number}\n\t\t * @private\n\t\t * @since 0.6.0\n\t\t */", "this", ".", "_defaultLoaderLength", "=", "this", ".", "_availableLoaders", ".", "length", ";", "this", ".", "init", "(", "preferXHR", ",", "basePath", ",", "crossOrigin", ")", ";", "}" ]
constructor The LoadQueue class is the main API for preloading content. LoadQueue is a load manager, which can preload either a single file, or queue of files. <b>Creating a Queue</b><br /> To use LoadQueue, create a LoadQueue instance. If you want to force tag loading where possible, set the preferXHR argument to false. var queue = new createjs.LoadQueue(true); <b>Listening for Events</b><br /> Add any listeners you want to the queue. Since PreloadJS 0.3.0, the {{#crossLink "EventDispatcher"}}{{/crossLink}} lets you add as many listeners as you want for events. You can subscribe to the following events:<ul> <li>{{#crossLink "AbstractLoader/complete:event"}}{{/crossLink}}: fired when a queue completes loading all files</li> <li>{{#crossLink "AbstractLoader/error:event"}}{{/crossLink}}: fired when the queue encounters an error with any file.</li> <li>{{#crossLink "AbstractLoader/progress:event"}}{{/crossLink}}: Progress for the entire queue has changed.</li> <li>{{#crossLink "LoadQueue/fileload:event"}}{{/crossLink}}: A single file has completed loading.</li> <li>{{#crossLink "LoadQueue/fileprogress:event"}}{{/crossLink}}: Progress for a single file has changes. Note that only files loaded with XHR (or possibly by plugins) will fire progress events other than 0 or 100%.</li> </ul> queue.on("fileload", handleFileLoad, this); queue.on("complete", handleComplete, this); <b>Adding files and manifests</b><br /> Add files you want to load using {{#crossLink "LoadQueue/loadFile"}}{{/crossLink}} or add multiple files at a time using a list or a manifest definition using {{#crossLink "LoadQueue/loadManifest"}}{{/crossLink}}. Files are appended to the end of the active queue, so you can use these methods as many times as you like, whenever you like. queue.loadFile("filePath/file.jpg"); queue.loadFile({id:"image", src:"filePath/file.jpg"}); queue.loadManifest(["filePath/file.jpg", {id:"image", src:"filePath/file.jpg"}]); // Use an external manifest queue.loadManifest("path/to/manifest.json"); queue.loadManifest({src:"manifest.json", type:"manifest"}); If you pass `false` as the `loadNow` parameter, the queue will not kick of the load of the files, but it will not stop if it has already been started. Call the {{#crossLink "AbstractLoader/load"}}{{/crossLink}} method to begin a paused queue. Note that a paused queue will automatically resume when new files are added to it with a `loadNow` argument of `true`. queue.load(); <b>File Types</b><br /> The file type of a manifest item is auto-determined by the file extension. The pattern matching in PreloadJS should handle the majority of standard file and url formats, and works with common file extensions. If you have either a non-standard file extension, or are serving the file using a proxy script, then you can pass in a <code>type</code> property with any manifest item. queue.loadFile({src:"path/to/myFile.mp3x", type:createjs.Types.SOUND}); // Note that PreloadJS will not read a file extension from the query string queue.loadFile({src:"http://server.com/proxy?file=image.jpg", type:createjs.Types.IMAGE}); Supported types are defined on the {{#crossLink "AbstractLoader"}}{{/crossLink}} class, and include: <ul> <li>{{#crossLink "Types/BINARY:property"}}{{/crossLink}}: Raw binary data via XHR</li> <li>{{#crossLink "Types/CSS:property"}}{{/crossLink}}: CSS files</li> <li>{{#crossLink "Types/IMAGE:property"}}{{/crossLink}}: Common image formats</li> <li>{{#crossLink "Types/JAVASCRIPT:property"}}{{/crossLink}}: JavaScript files</li> <li>{{#crossLink "Types/JSON:property"}}{{/crossLink}}: JSON data</li> <li>{{#crossLink "Types/JSONP:property"}}{{/crossLink}}: JSON files cross-domain</li> <li>{{#crossLink "Types/MANIFEST:property"}}{{/crossLink}}: A list of files to load in JSON format, see {{#crossLink "AbstractLoader/loadManifest"}}{{/crossLink}}</li> <li>{{#crossLink "Types/SOUND:property"}}{{/crossLink}}: Audio file formats</li> <li>{{#crossLink "Types/SPRITESHEET:property"}}{{/crossLink}}: JSON SpriteSheet definitions. This will also load sub-images, and provide a {{#crossLink "SpriteSheet"}}{{/crossLink}} instance.</li> <li>{{#crossLink "Types/SVG:property"}}{{/crossLink}}: SVG files</li> <li>{{#crossLink "Types/TEXT:property"}}{{/crossLink}}: Text files - XHR only</li> <li>{{#crossLink "Types/VIDEO:property"}}{{/crossLink}}: Video objects</li> <li>{{#crossLink "Types/XML:property"}}{{/crossLink}}: XML data</li> </ul> <em>Note: Loader types used to be defined on LoadQueue, but have been moved to the Types class</em> <b>Handling Results</b><br /> When a file is finished downloading, a {{#crossLink "LoadQueue/fileload:event"}}{{/crossLink}} event is dispatched. In an example above, there is an event listener snippet for fileload. Loaded files are usually a formatted object that can be used immediately, including: <ul> <li>Binary: The binary loaded result</li> <li>CSS: A &lt;link /&gt; tag</li> <li>Image: An &lt;img /&gt; tag</li> <li>JavaScript: A &lt;script /&gt; tag</li> <li>JSON/JSONP: A formatted JavaScript Object</li> <li>Manifest: A JavaScript object. <li>Sound: An &lt;audio /&gt; tag</a> <li>SpriteSheet: A {{#crossLink "SpriteSheet"}}{{/crossLink}} instance, containing loaded images. <li>SVG: An &lt;object /&gt; tag</li> <li>Text: Raw text</li> <li>Video: A Video DOM node</li> <li>XML: An XML DOM node</li> </ul> function handleFileLoad(event) { var item = event.item; // A reference to the item that was passed in to the LoadQueue var type = item.type; // Add any images to the page body. if (type == createjs.Types.IMAGE) { document.body.appendChild(event.result); } } At any time after the file has been loaded (usually after the queue has completed), any result can be looked up via its "id" using {{#crossLink "LoadQueue/getResult"}}{{/crossLink}}. If no id was provided, then the "src" or file path can be used instead, including the `path` defined by a manifest, but <strong>not including</strong> a base path defined on the LoadQueue. It is recommended to always pass an id if you want to look up content. var image = queue.getResult("image"); document.body.appendChild(image); Raw loaded content can be accessed using the <code>rawResult</code> property of the {{#crossLink "LoadQueue/fileload:event"}}{{/crossLink}} event, or can be looked up using {{#crossLink "LoadQueue/getResult"}}{{/crossLink}}, passing `true` as the 2nd argument. This is only applicable for content that has been parsed for the browser, specifically: JavaScript, CSS, XML, SVG, and JSON objects, or anything loaded with XHR. var image = queue.getResult("image", true); // load the binary image data loaded with XHR. <b>Plugins</b><br /> LoadQueue has a simple plugin architecture to help process and preload content. For example, to preload audio, make sure to install the <a href="http://soundjs.com">SoundJS</a> Sound class, which will help load HTML audio, Flash audio, and WebAudio files. This should be installed <strong>before</strong> loading any audio files. queue.installPlugin(createjs.Sound); <h4>Known Browser Issues</h4> <ul> <li>Browsers without audio support can not load audio files.</li> <li>Safari on Mac OS X can only play HTML audio if QuickTime is installed</li> <li>HTML Audio tags will only download until their <code>canPlayThrough</code> event is fired. Browsers other than Chrome will continue to download in the background.</li> <li>When loading scripts using tags, they are automatically added to the document.</li> <li>Scripts loaded via XHR may not be properly inspectable with browser tools.</li> <li>IE6 and IE7 (and some other browsers) may not be able to load XML, Text, or JSON, since they require XHR to work.</li> <li>Content loaded via tags will not show progress, and will continue to download in the background when canceled, although no events will be dispatched.</li> </ul> @class LoadQueue @param {Boolean} [preferXHR=true] Determines whether the preload instance will favor loading with XHR (XML HTTP Requests), or HTML tags. When this is `false`, the queue will use tag loading when possible, and fall back on XHR when necessary. @param {String} [basePath=""] A path that will be prepended on to the source parameter of all items in the queue before they are loaded. Sources beginning with a protocol such as `http://` or a relative path such as `../` will not receive a base path. @param {String|Boolean} [crossOrigin=""] An optional flag to support images loaded from a CORS-enabled server. To use it, set this value to `true`, which will default the crossOrigin property on images to "Anonymous". Any string value will be passed through, but only "" and "Anonymous" are recommended. <strong>Note: The crossOrigin parameter is deprecated. Use LoadItem.crossOrigin instead</strong> @constructor @extends AbstractLoader
[ "constructor", "The", "LoadQueue", "class", "is", "the", "main", "API", "for", "preloading", "content", ".", "LoadQueue", "is", "a", "load", "manager", "which", "can", "preload", "either", "a", "single", "file", "or", "queue", "of", "files", "." ]
eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083
https://github.com/CreateJS/PreloadJS/blob/eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083/lib/preloadjs.js#L4542-L4677
6,512
CreateJS/PreloadJS
lib/preloadjs.js
BinaryLoader
function BinaryLoader(loadItem) { this.AbstractLoader_constructor(loadItem, true, createjs.Types.BINARY); this.on("initialize", this._updateXHR, this); }
javascript
function BinaryLoader(loadItem) { this.AbstractLoader_constructor(loadItem, true, createjs.Types.BINARY); this.on("initialize", this._updateXHR, this); }
[ "function", "BinaryLoader", "(", "loadItem", ")", "{", "this", ".", "AbstractLoader_constructor", "(", "loadItem", ",", "true", ",", "createjs", ".", "Types", ".", "BINARY", ")", ";", "this", ".", "on", "(", "\"initialize\"", ",", "this", ".", "_updateXHR", ",", "this", ")", ";", "}" ]
constructor A loader for binary files. This is useful for loading web audio, or content that requires an ArrayBuffer. @class BinaryLoader @param {LoadItem|Object} loadItem @extends AbstractLoader @constructor
[ "constructor", "A", "loader", "for", "binary", "files", ".", "This", "is", "useful", "for", "loading", "web", "audio", "or", "content", "that", "requires", "an", "ArrayBuffer", "." ]
eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083
https://github.com/CreateJS/PreloadJS/blob/eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083/lib/preloadjs.js#L6129-L6132
6,513
sockjs/sockjs-client
lib/utils/escape.js
function(escapable) { var i; var unrolled = {}; var c = []; for (i = 0; i < 65536; i++) { c.push( String.fromCharCode(i) ); } escapable.lastIndex = 0; c.join('').replace(escapable, function(a) { unrolled[ a ] = '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); return ''; }); escapable.lastIndex = 0; return unrolled; }
javascript
function(escapable) { var i; var unrolled = {}; var c = []; for (i = 0; i < 65536; i++) { c.push( String.fromCharCode(i) ); } escapable.lastIndex = 0; c.join('').replace(escapable, function(a) { unrolled[ a ] = '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); return ''; }); escapable.lastIndex = 0; return unrolled; }
[ "function", "(", "escapable", ")", "{", "var", "i", ";", "var", "unrolled", "=", "{", "}", ";", "var", "c", "=", "[", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "65536", ";", "i", "++", ")", "{", "c", ".", "push", "(", "String", ".", "fromCharCode", "(", "i", ")", ")", ";", "}", "escapable", ".", "lastIndex", "=", "0", ";", "c", ".", "join", "(", "''", ")", ".", "replace", "(", "escapable", ",", "function", "(", "a", ")", "{", "unrolled", "[", "a", "]", "=", "'\\\\u'", "+", "(", "'0000'", "+", "a", ".", "charCodeAt", "(", "0", ")", ".", "toString", "(", "16", ")", ")", ".", "slice", "(", "-", "4", ")", ";", "return", "''", ";", "}", ")", ";", "escapable", ".", "lastIndex", "=", "0", ";", "return", "unrolled", ";", "}" ]
This may be quite slow, so let's delay until user actually uses bad characters.
[ "This", "may", "be", "quite", "slow", "so", "let", "s", "delay", "until", "user", "actually", "uses", "bad", "characters", "." ]
477e30d4d1ba61d9d995c991aef89627c1c14aed
https://github.com/sockjs/sockjs-client/blob/477e30d4d1ba61d9d995c991aef89627c1c14aed/lib/utils/escape.js#L13-L27
6,514
glidejs/glide
dist/glide.esm.js
mount
function mount(glide, extensions, events) { var components = {}; for (var name in extensions) { if (isFunction(extensions[name])) { components[name] = extensions[name](glide, components, events); } else { warn('Extension must be a function'); } } for (var _name in components) { if (isFunction(components[_name].mount)) { components[_name].mount(); } } return components; }
javascript
function mount(glide, extensions, events) { var components = {}; for (var name in extensions) { if (isFunction(extensions[name])) { components[name] = extensions[name](glide, components, events); } else { warn('Extension must be a function'); } } for (var _name in components) { if (isFunction(components[_name].mount)) { components[_name].mount(); } } return components; }
[ "function", "mount", "(", "glide", ",", "extensions", ",", "events", ")", "{", "var", "components", "=", "{", "}", ";", "for", "(", "var", "name", "in", "extensions", ")", "{", "if", "(", "isFunction", "(", "extensions", "[", "name", "]", ")", ")", "{", "components", "[", "name", "]", "=", "extensions", "[", "name", "]", "(", "glide", ",", "components", ",", "events", ")", ";", "}", "else", "{", "warn", "(", "'Extension must be a function'", ")", ";", "}", "}", "for", "(", "var", "_name", "in", "components", ")", "{", "if", "(", "isFunction", "(", "components", "[", "_name", "]", ".", "mount", ")", ")", "{", "components", "[", "_name", "]", ".", "mount", "(", ")", ";", "}", "}", "return", "components", ";", "}" ]
Creates and initializes specified collection of extensions. Each extension receives access to instance of glide and rest of components. @param {Object} glide @param {Object} extensions @returns {Object}
[ "Creates", "and", "initializes", "specified", "collection", "of", "extensions", ".", "Each", "extension", "receives", "access", "to", "instance", "of", "glide", "and", "rest", "of", "components", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L408-L426
6,515
glidejs/glide
dist/glide.esm.js
sortKeys
function sortKeys(obj) { return Object.keys(obj).sort().reduce(function (r, k) { r[k] = obj[k]; return r[k], r; }, {}); }
javascript
function sortKeys(obj) { return Object.keys(obj).sort().reduce(function (r, k) { r[k] = obj[k]; return r[k], r; }, {}); }
[ "function", "sortKeys", "(", "obj", ")", "{", "return", "Object", ".", "keys", "(", "obj", ")", ".", "sort", "(", ")", ".", "reduce", "(", "function", "(", "r", ",", "k", ")", "{", "r", "[", "k", "]", "=", "obj", "[", "k", "]", ";", "return", "r", "[", "k", "]", ",", "r", ";", "}", ",", "{", "}", ")", ";", "}" ]
Sorts aphabetically object keys. @param {Object} obj @return {Object}
[ "Sorts", "aphabetically", "object", "keys", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L446-L452
6,516
glidejs/glide
dist/glide.esm.js
mergeOptions
function mergeOptions(defaults, settings) { var options = _extends({}, defaults, settings); // `Object.assign` do not deeply merge objects, so we // have to do it manually for every nested object // in options. Although it does not look smart, // it's smaller and faster than some fancy // merging deep-merge algorithm script. if (settings.hasOwnProperty('classes')) { options.classes = _extends({}, defaults.classes, settings.classes); if (settings.classes.hasOwnProperty('direction')) { options.classes.direction = _extends({}, defaults.classes.direction, settings.classes.direction); } } if (settings.hasOwnProperty('breakpoints')) { options.breakpoints = _extends({}, defaults.breakpoints, settings.breakpoints); } return options; }
javascript
function mergeOptions(defaults, settings) { var options = _extends({}, defaults, settings); // `Object.assign` do not deeply merge objects, so we // have to do it manually for every nested object // in options. Although it does not look smart, // it's smaller and faster than some fancy // merging deep-merge algorithm script. if (settings.hasOwnProperty('classes')) { options.classes = _extends({}, defaults.classes, settings.classes); if (settings.classes.hasOwnProperty('direction')) { options.classes.direction = _extends({}, defaults.classes.direction, settings.classes.direction); } } if (settings.hasOwnProperty('breakpoints')) { options.breakpoints = _extends({}, defaults.breakpoints, settings.breakpoints); } return options; }
[ "function", "mergeOptions", "(", "defaults", ",", "settings", ")", "{", "var", "options", "=", "_extends", "(", "{", "}", ",", "defaults", ",", "settings", ")", ";", "// `Object.assign` do not deeply merge objects, so we", "// have to do it manually for every nested object", "// in options. Although it does not look smart,", "// it's smaller and faster than some fancy", "// merging deep-merge algorithm script.", "if", "(", "settings", ".", "hasOwnProperty", "(", "'classes'", ")", ")", "{", "options", ".", "classes", "=", "_extends", "(", "{", "}", ",", "defaults", ".", "classes", ",", "settings", ".", "classes", ")", ";", "if", "(", "settings", ".", "classes", ".", "hasOwnProperty", "(", "'direction'", ")", ")", "{", "options", ".", "classes", ".", "direction", "=", "_extends", "(", "{", "}", ",", "defaults", ".", "classes", ".", "direction", ",", "settings", ".", "classes", ".", "direction", ")", ";", "}", "}", "if", "(", "settings", ".", "hasOwnProperty", "(", "'breakpoints'", ")", ")", "{", "options", ".", "breakpoints", "=", "_extends", "(", "{", "}", ",", "defaults", ".", "breakpoints", ",", "settings", ".", "breakpoints", ")", ";", "}", "return", "options", ";", "}" ]
Merges passed settings object with default options. @param {Object} defaults @param {Object} settings @return {Object}
[ "Merges", "passed", "settings", "object", "with", "default", "options", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L461-L482
6,517
glidejs/glide
dist/glide.esm.js
EventsBus
function EventsBus() { var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; classCallCheck(this, EventsBus); this.events = events; this.hop = events.hasOwnProperty; }
javascript
function EventsBus() { var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; classCallCheck(this, EventsBus); this.events = events; this.hop = events.hasOwnProperty; }
[ "function", "EventsBus", "(", ")", "{", "var", "events", "=", "arguments", ".", "length", ">", "0", "&&", "arguments", "[", "0", "]", "!==", "undefined", "?", "arguments", "[", "0", "]", ":", "{", "}", ";", "classCallCheck", "(", "this", ",", "EventsBus", ")", ";", "this", ".", "events", "=", "events", ";", "this", ".", "hop", "=", "events", ".", "hasOwnProperty", ";", "}" ]
Construct a EventBus instance. @param {Object} events
[ "Construct", "a", "EventBus", "instance", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L490-L496
6,518
glidejs/glide
dist/glide.esm.js
Glide
function Glide(selector) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; classCallCheck(this, Glide); this._c = {}; this._t = []; this._e = new EventsBus(); this.disabled = false; this.selector = selector; this.settings = mergeOptions(defaults, options); this.index = this.settings.startAt; }
javascript
function Glide(selector) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; classCallCheck(this, Glide); this._c = {}; this._t = []; this._e = new EventsBus(); this.disabled = false; this.selector = selector; this.settings = mergeOptions(defaults, options); this.index = this.settings.startAt; }
[ "function", "Glide", "(", "selector", ")", "{", "var", "options", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "{", "}", ";", "classCallCheck", "(", "this", ",", "Glide", ")", ";", "this", ".", "_c", "=", "{", "}", ";", "this", ".", "_t", "=", "[", "]", ";", "this", ".", "_e", "=", "new", "EventsBus", "(", ")", ";", "this", ".", "disabled", "=", "false", ";", "this", ".", "selector", "=", "selector", ";", "this", ".", "settings", "=", "mergeOptions", "(", "defaults", ",", "options", ")", ";", "this", ".", "index", "=", "this", ".", "settings", ".", "startAt", ";", "}" ]
Construct glide. @param {String} selector @param {Object} options
[ "Construct", "glide", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L568-L580
6,519
glidejs/glide
dist/glide.esm.js
make
function make(move) { var _this = this; if (!Glide.disabled) { Glide.disable(); this.move = move; Events.emit('run.before', this.move); this.calculate(); Events.emit('run', this.move); Components.Transition.after(function () { if (_this.isStart()) { Events.emit('run.start', _this.move); } if (_this.isEnd()) { Events.emit('run.end', _this.move); } if (_this.isOffset('<') || _this.isOffset('>')) { _this._o = false; Events.emit('run.offset', _this.move); } Events.emit('run.after', _this.move); Glide.enable(); }); } }
javascript
function make(move) { var _this = this; if (!Glide.disabled) { Glide.disable(); this.move = move; Events.emit('run.before', this.move); this.calculate(); Events.emit('run', this.move); Components.Transition.after(function () { if (_this.isStart()) { Events.emit('run.start', _this.move); } if (_this.isEnd()) { Events.emit('run.end', _this.move); } if (_this.isOffset('<') || _this.isOffset('>')) { _this._o = false; Events.emit('run.offset', _this.move); } Events.emit('run.after', _this.move); Glide.enable(); }); } }
[ "function", "make", "(", "move", ")", "{", "var", "_this", "=", "this", ";", "if", "(", "!", "Glide", ".", "disabled", ")", "{", "Glide", ".", "disable", "(", ")", ";", "this", ".", "move", "=", "move", ";", "Events", ".", "emit", "(", "'run.before'", ",", "this", ".", "move", ")", ";", "this", ".", "calculate", "(", ")", ";", "Events", ".", "emit", "(", "'run'", ",", "this", ".", "move", ")", ";", "Components", ".", "Transition", ".", "after", "(", "function", "(", ")", "{", "if", "(", "_this", ".", "isStart", "(", ")", ")", "{", "Events", ".", "emit", "(", "'run.start'", ",", "_this", ".", "move", ")", ";", "}", "if", "(", "_this", ".", "isEnd", "(", ")", ")", "{", "Events", ".", "emit", "(", "'run.end'", ",", "_this", ".", "move", ")", ";", "}", "if", "(", "_this", ".", "isOffset", "(", "'<'", ")", "||", "_this", ".", "isOffset", "(", "'>'", ")", ")", "{", "_this", ".", "_o", "=", "false", ";", "Events", ".", "emit", "(", "'run.offset'", ",", "_this", ".", "move", ")", ";", "}", "Events", ".", "emit", "(", "'run.after'", ",", "_this", ".", "move", ")", ";", "Glide", ".", "enable", "(", ")", ";", "}", ")", ";", "}", "}" ]
Makes glides running based on the passed moving schema. @param {String} move
[ "Makes", "glides", "running", "based", "on", "the", "passed", "moving", "schema", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L897-L931
6,520
glidejs/glide
dist/glide.esm.js
calculate
function calculate() { var move = this.move, length = this.length; var steps = move.steps, direction = move.direction; var countableSteps = isNumber(toInt(steps)) && toInt(steps) !== 0; switch (direction) { case '>': if (steps === '>') { Glide.index = length; } else if (this.isEnd()) { if (!(Glide.isType('slider') && !Glide.settings.rewind)) { this._o = true; Glide.index = 0; } } else if (countableSteps) { Glide.index += Math.min(length - Glide.index, -toInt(steps)); } else { Glide.index++; } break; case '<': if (steps === '<') { Glide.index = 0; } else if (this.isStart()) { if (!(Glide.isType('slider') && !Glide.settings.rewind)) { this._o = true; Glide.index = length; } } else if (countableSteps) { Glide.index -= Math.min(Glide.index, toInt(steps)); } else { Glide.index--; } break; case '=': Glide.index = steps; break; default: warn('Invalid direction pattern [' + direction + steps + '] has been used'); break; } }
javascript
function calculate() { var move = this.move, length = this.length; var steps = move.steps, direction = move.direction; var countableSteps = isNumber(toInt(steps)) && toInt(steps) !== 0; switch (direction) { case '>': if (steps === '>') { Glide.index = length; } else if (this.isEnd()) { if (!(Glide.isType('slider') && !Glide.settings.rewind)) { this._o = true; Glide.index = 0; } } else if (countableSteps) { Glide.index += Math.min(length - Glide.index, -toInt(steps)); } else { Glide.index++; } break; case '<': if (steps === '<') { Glide.index = 0; } else if (this.isStart()) { if (!(Glide.isType('slider') && !Glide.settings.rewind)) { this._o = true; Glide.index = length; } } else if (countableSteps) { Glide.index -= Math.min(Glide.index, toInt(steps)); } else { Glide.index--; } break; case '=': Glide.index = steps; break; default: warn('Invalid direction pattern [' + direction + steps + '] has been used'); break; } }
[ "function", "calculate", "(", ")", "{", "var", "move", "=", "this", ".", "move", ",", "length", "=", "this", ".", "length", ";", "var", "steps", "=", "move", ".", "steps", ",", "direction", "=", "move", ".", "direction", ";", "var", "countableSteps", "=", "isNumber", "(", "toInt", "(", "steps", ")", ")", "&&", "toInt", "(", "steps", ")", "!==", "0", ";", "switch", "(", "direction", ")", "{", "case", "'>'", ":", "if", "(", "steps", "===", "'>'", ")", "{", "Glide", ".", "index", "=", "length", ";", "}", "else", "if", "(", "this", ".", "isEnd", "(", ")", ")", "{", "if", "(", "!", "(", "Glide", ".", "isType", "(", "'slider'", ")", "&&", "!", "Glide", ".", "settings", ".", "rewind", ")", ")", "{", "this", ".", "_o", "=", "true", ";", "Glide", ".", "index", "=", "0", ";", "}", "}", "else", "if", "(", "countableSteps", ")", "{", "Glide", ".", "index", "+=", "Math", ".", "min", "(", "length", "-", "Glide", ".", "index", ",", "-", "toInt", "(", "steps", ")", ")", ";", "}", "else", "{", "Glide", ".", "index", "++", ";", "}", "break", ";", "case", "'<'", ":", "if", "(", "steps", "===", "'<'", ")", "{", "Glide", ".", "index", "=", "0", ";", "}", "else", "if", "(", "this", ".", "isStart", "(", ")", ")", "{", "if", "(", "!", "(", "Glide", ".", "isType", "(", "'slider'", ")", "&&", "!", "Glide", ".", "settings", ".", "rewind", ")", ")", "{", "this", ".", "_o", "=", "true", ";", "Glide", ".", "index", "=", "length", ";", "}", "}", "else", "if", "(", "countableSteps", ")", "{", "Glide", ".", "index", "-=", "Math", ".", "min", "(", "Glide", ".", "index", ",", "toInt", "(", "steps", ")", ")", ";", "}", "else", "{", "Glide", ".", "index", "--", ";", "}", "break", ";", "case", "'='", ":", "Glide", ".", "index", "=", "steps", ";", "break", ";", "default", ":", "warn", "(", "'Invalid direction pattern ['", "+", "direction", "+", "steps", "+", "'] has been used'", ")", ";", "break", ";", "}", "}" ]
Calculates current index based on defined move. @return {Void}
[ "Calculates", "current", "index", "based", "on", "defined", "move", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L939-L989
6,521
glidejs/glide
dist/glide.esm.js
set
function set(value) { var step = value.substr(1); this._m = { direction: value.substr(0, 1), steps: step ? toInt(step) ? toInt(step) : step : 0 }; }
javascript
function set(value) { var step = value.substr(1); this._m = { direction: value.substr(0, 1), steps: step ? toInt(step) ? toInt(step) : step : 0 }; }
[ "function", "set", "(", "value", ")", "{", "var", "step", "=", "value", ".", "substr", "(", "1", ")", ";", "this", ".", "_m", "=", "{", "direction", ":", "value", ".", "substr", "(", "0", ",", "1", ")", ",", "steps", ":", "step", "?", "toInt", "(", "step", ")", "?", "toInt", "(", "step", ")", ":", "step", ":", "0", "}", ";", "}" ]
Sets value of the move schema. @returns {Object}
[ "Sets", "value", "of", "the", "move", "schema", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1039-L1046
6,522
glidejs/glide
dist/glide.esm.js
get
function get() { var settings = Glide.settings; var length = Components.Html.slides.length; // If the `bound` option is acitve, a maximum running distance should be // reduced by `perView` and `focusAt` settings. Running distance // should end before creating an empty space after instance. if (Glide.isType('slider') && settings.focusAt !== 'center' && settings.bound) { return length - 1 - (toInt(settings.perView) - 1) + toInt(settings.focusAt); } return length - 1; }
javascript
function get() { var settings = Glide.settings; var length = Components.Html.slides.length; // If the `bound` option is acitve, a maximum running distance should be // reduced by `perView` and `focusAt` settings. Running distance // should end before creating an empty space after instance. if (Glide.isType('slider') && settings.focusAt !== 'center' && settings.bound) { return length - 1 - (toInt(settings.perView) - 1) + toInt(settings.focusAt); } return length - 1; }
[ "function", "get", "(", ")", "{", "var", "settings", "=", "Glide", ".", "settings", ";", "var", "length", "=", "Components", ".", "Html", ".", "slides", ".", "length", ";", "// If the `bound` option is acitve, a maximum running distance should be", "// reduced by `perView` and `focusAt` settings. Running distance", "// should end before creating an empty space after instance.", "if", "(", "Glide", ".", "isType", "(", "'slider'", ")", "&&", "settings", ".", "focusAt", "!==", "'center'", "&&", "settings", ".", "bound", ")", "{", "return", "length", "-", "1", "-", "(", "toInt", "(", "settings", ".", "perView", ")", "-", "1", ")", "+", "toInt", "(", "settings", ".", "focusAt", ")", ";", "}", "return", "length", "-", "1", ";", "}" ]
Gets value of the running distance based on zero-indexing number of slides. @return {Number}
[ "Gets", "value", "of", "the", "running", "distance", "based", "on", "zero", "-", "indexing", "number", "of", "slides", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1056-L1069
6,523
glidejs/glide
dist/glide.esm.js
apply
function apply(slides) { for (var i = 0, len = slides.length; i < len; i++) { var style = slides[i].style; var direction = Components.Direction.value; if (i !== 0) { style[MARGIN_TYPE[direction][0]] = this.value / 2 + 'px'; } else { style[MARGIN_TYPE[direction][0]] = ''; } if (i !== slides.length - 1) { style[MARGIN_TYPE[direction][1]] = this.value / 2 + 'px'; } else { style[MARGIN_TYPE[direction][1]] = ''; } } }
javascript
function apply(slides) { for (var i = 0, len = slides.length; i < len; i++) { var style = slides[i].style; var direction = Components.Direction.value; if (i !== 0) { style[MARGIN_TYPE[direction][0]] = this.value / 2 + 'px'; } else { style[MARGIN_TYPE[direction][0]] = ''; } if (i !== slides.length - 1) { style[MARGIN_TYPE[direction][1]] = this.value / 2 + 'px'; } else { style[MARGIN_TYPE[direction][1]] = ''; } } }
[ "function", "apply", "(", "slides", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "slides", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "style", "=", "slides", "[", "i", "]", ".", "style", ";", "var", "direction", "=", "Components", ".", "Direction", ".", "value", ";", "if", "(", "i", "!==", "0", ")", "{", "style", "[", "MARGIN_TYPE", "[", "direction", "]", "[", "0", "]", "]", "=", "this", ".", "value", "/", "2", "+", "'px'", ";", "}", "else", "{", "style", "[", "MARGIN_TYPE", "[", "direction", "]", "[", "0", "]", "]", "=", "''", ";", "}", "if", "(", "i", "!==", "slides", ".", "length", "-", "1", ")", "{", "style", "[", "MARGIN_TYPE", "[", "direction", "]", "[", "1", "]", "]", "=", "this", ".", "value", "/", "2", "+", "'px'", ";", "}", "else", "{", "style", "[", "MARGIN_TYPE", "[", "direction", "]", "[", "1", "]", "]", "=", "''", ";", "}", "}", "}" ]
Applies gaps between slides. First and last slides do not receive it's edge margins. @param {HTMLCollection} slides @return {Void}
[ "Applies", "gaps", "between", "slides", ".", "First", "and", "last", "slides", "do", "not", "receive", "it", "s", "edge", "margins", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1164-L1181
6,524
glidejs/glide
dist/glide.esm.js
remove
function remove(slides) { for (var i = 0, len = slides.length; i < len; i++) { var style = slides[i].style; style.marginLeft = ''; style.marginRight = ''; } }
javascript
function remove(slides) { for (var i = 0, len = slides.length; i < len; i++) { var style = slides[i].style; style.marginLeft = ''; style.marginRight = ''; } }
[ "function", "remove", "(", "slides", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "slides", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "style", "=", "slides", "[", "i", "]", ".", "style", ";", "style", ".", "marginLeft", "=", "''", ";", "style", ".", "marginRight", "=", "''", ";", "}", "}" ]
Removes gaps from the slides. @param {HTMLCollection} slides @returns {Void}
[ "Removes", "gaps", "from", "the", "slides", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1190-L1197
6,525
glidejs/glide
dist/glide.esm.js
siblings
function siblings(node) { if (node && node.parentNode) { var n = node.parentNode.firstChild; var matched = []; for (; n; n = n.nextSibling) { if (n.nodeType === 1 && n !== node) { matched.push(n); } } return matched; } return []; }
javascript
function siblings(node) { if (node && node.parentNode) { var n = node.parentNode.firstChild; var matched = []; for (; n; n = n.nextSibling) { if (n.nodeType === 1 && n !== node) { matched.push(n); } } return matched; } return []; }
[ "function", "siblings", "(", "node", ")", "{", "if", "(", "node", "&&", "node", ".", "parentNode", ")", "{", "var", "n", "=", "node", ".", "parentNode", ".", "firstChild", ";", "var", "matched", "=", "[", "]", ";", "for", "(", ";", "n", ";", "n", "=", "n", ".", "nextSibling", ")", "{", "if", "(", "n", ".", "nodeType", "===", "1", "&&", "n", "!==", "node", ")", "{", "matched", ".", "push", "(", "n", ")", ";", "}", "}", "return", "matched", ";", "}", "return", "[", "]", ";", "}" ]
Finds siblings nodes of the passed node. @param {Element} node @return {Array}
[ "Finds", "siblings", "nodes", "of", "the", "passed", "node", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1263-L1278
6,526
glidejs/glide
dist/glide.esm.js
mount
function mount() { this.root = Glide.selector; this.track = this.root.querySelector(TRACK_SELECTOR); this.slides = Array.prototype.slice.call(this.wrapper.children).filter(function (slide) { return !slide.classList.contains(Glide.settings.classes.cloneSlide); }); }
javascript
function mount() { this.root = Glide.selector; this.track = this.root.querySelector(TRACK_SELECTOR); this.slides = Array.prototype.slice.call(this.wrapper.children).filter(function (slide) { return !slide.classList.contains(Glide.settings.classes.cloneSlide); }); }
[ "function", "mount", "(", ")", "{", "this", ".", "root", "=", "Glide", ".", "selector", ";", "this", ".", "track", "=", "this", ".", "root", ".", "querySelector", "(", "TRACK_SELECTOR", ")", ";", "this", ".", "slides", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "this", ".", "wrapper", ".", "children", ")", ".", "filter", "(", "function", "(", "slide", ")", "{", "return", "!", "slide", ".", "classList", ".", "contains", "(", "Glide", ".", "settings", ".", "classes", ".", "cloneSlide", ")", ";", "}", ")", ";", "}" ]
Setup slider HTML nodes. @param {Glide} glide
[ "Setup", "slider", "HTML", "nodes", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1303-L1309
6,527
glidejs/glide
dist/glide.esm.js
set
function set(r) { if (isString(r)) { r = document.querySelector(r); } if (exist(r)) { Html._r = r; } else { warn('Root element must be a existing Html node'); } }
javascript
function set(r) { if (isString(r)) { r = document.querySelector(r); } if (exist(r)) { Html._r = r; } else { warn('Root element must be a existing Html node'); } }
[ "function", "set", "(", "r", ")", "{", "if", "(", "isString", "(", "r", ")", ")", "{", "r", "=", "document", ".", "querySelector", "(", "r", ")", ";", "}", "if", "(", "exist", "(", "r", ")", ")", "{", "Html", ".", "_r", "=", "r", ";", "}", "else", "{", "warn", "(", "'Root element must be a existing Html node'", ")", ";", "}", "}" ]
Sets node of the glide main element. @return {Object}
[ "Sets", "node", "of", "the", "glide", "main", "element", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1328-L1338
6,528
glidejs/glide
dist/glide.esm.js
set
function set(value) { if (isObject(value)) { value.before = toInt(value.before); value.after = toInt(value.after); } else { value = toInt(value); } Peek._v = value; }
javascript
function set(value) { if (isObject(value)) { value.before = toInt(value.before); value.after = toInt(value.after); } else { value = toInt(value); } Peek._v = value; }
[ "function", "set", "(", "value", ")", "{", "if", "(", "isObject", "(", "value", ")", ")", "{", "value", ".", "before", "=", "toInt", "(", "value", ".", "before", ")", ";", "value", ".", "after", "=", "toInt", "(", "value", ".", "after", ")", ";", "}", "else", "{", "value", "=", "toInt", "(", "value", ")", ";", "}", "Peek", ".", "_v", "=", "value", ";", "}" ]
Sets value of the peek. @param {Number|Object} value @return {Void}
[ "Sets", "value", "of", "the", "peek", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1409-L1418
6,529
glidejs/glide
dist/glide.esm.js
get
function get() { var value = Peek.value; var perView = Glide.settings.perView; if (isObject(value)) { return value.before / perView + value.after / perView; } return value * 2 / perView; }
javascript
function get() { var value = Peek.value; var perView = Glide.settings.perView; if (isObject(value)) { return value.before / perView + value.after / perView; } return value * 2 / perView; }
[ "function", "get", "(", ")", "{", "var", "value", "=", "Peek", ".", "value", ";", "var", "perView", "=", "Glide", ".", "settings", ".", "perView", ";", "if", "(", "isObject", "(", "value", ")", ")", "{", "return", "value", ".", "before", "/", "perView", "+", "value", ".", "after", "/", "perView", ";", "}", "return", "value", "*", "2", "/", "perView", ";", "}" ]
Gets reduction value caused by peek. @returns {Number}
[ "Gets", "reduction", "value", "caused", "by", "peek", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1427-L1436
6,530
glidejs/glide
dist/glide.esm.js
make
function make() { var _this = this; var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; this.offset = offset; Events.emit('move', { movement: this.value }); Components.Transition.after(function () { Events.emit('move.after', { movement: _this.value }); }); }
javascript
function make() { var _this = this; var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; this.offset = offset; Events.emit('move', { movement: this.value }); Components.Transition.after(function () { Events.emit('move.after', { movement: _this.value }); }); }
[ "function", "make", "(", ")", "{", "var", "_this", "=", "this", ";", "var", "offset", "=", "arguments", ".", "length", ">", "0", "&&", "arguments", "[", "0", "]", "!==", "undefined", "?", "arguments", "[", "0", "]", ":", "0", ";", "this", ".", "offset", "=", "offset", ";", "Events", ".", "emit", "(", "'move'", ",", "{", "movement", ":", "this", ".", "value", "}", ")", ";", "Components", ".", "Transition", ".", "after", "(", "function", "(", ")", "{", "Events", ".", "emit", "(", "'move.after'", ",", "{", "movement", ":", "_this", ".", "value", "}", ")", ";", "}", ")", ";", "}" ]
Calculates a movement value based on passed offset and currently active index. @param {Number} offset @return {Void}
[ "Calculates", "a", "movement", "value", "based", "on", "passed", "offset", "and", "currently", "active", "index", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1468-L1484
6,531
glidejs/glide
dist/glide.esm.js
get
function get() { var offset = this.offset; var translate = this.translate; if (Components.Direction.is('rtl')) { return translate + offset; } return translate - offset; }
javascript
function get() { var offset = this.offset; var translate = this.translate; if (Components.Direction.is('rtl')) { return translate + offset; } return translate - offset; }
[ "function", "get", "(", ")", "{", "var", "offset", "=", "this", ".", "offset", ";", "var", "translate", "=", "this", ".", "translate", ";", "if", "(", "Components", ".", "Direction", ".", "is", "(", "'rtl'", ")", ")", "{", "return", "translate", "+", "offset", ";", "}", "return", "translate", "-", "offset", ";", "}" ]
Gets an actual movement value corrected by offset. @return {Number}
[ "Gets", "an", "actual", "movement", "value", "corrected", "by", "offset", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1525-L1534
6,532
glidejs/glide
dist/glide.esm.js
setupSlides
function setupSlides() { var width = this.slideWidth + 'px'; var slides = Components.Html.slides; for (var i = 0; i < slides.length; i++) { slides[i].style.width = width; } }
javascript
function setupSlides() { var width = this.slideWidth + 'px'; var slides = Components.Html.slides; for (var i = 0; i < slides.length; i++) { slides[i].style.width = width; } }
[ "function", "setupSlides", "(", ")", "{", "var", "width", "=", "this", ".", "slideWidth", "+", "'px'", ";", "var", "slides", "=", "Components", ".", "Html", ".", "slides", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "slides", ".", "length", ";", "i", "++", ")", "{", "slides", "[", "i", "]", ".", "style", ".", "width", "=", "width", ";", "}", "}" ]
Setups dimentions of slides. @return {Void}
[ "Setups", "dimentions", "of", "slides", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1556-L1563
6,533
glidejs/glide
dist/glide.esm.js
remove
function remove() { var slides = Components.Html.slides; for (var i = 0; i < slides.length; i++) { slides[i].style.width = ''; } Components.Html.wrapper.style.width = ''; }
javascript
function remove() { var slides = Components.Html.slides; for (var i = 0; i < slides.length; i++) { slides[i].style.width = ''; } Components.Html.wrapper.style.width = ''; }
[ "function", "remove", "(", ")", "{", "var", "slides", "=", "Components", ".", "Html", ".", "slides", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "slides", ".", "length", ";", "i", "++", ")", "{", "slides", "[", "i", "]", ".", "style", ".", "width", "=", "''", ";", "}", "Components", ".", "Html", ".", "wrapper", ".", "style", ".", "width", "=", "''", ";", "}" ]
Removes applied styles from HTML elements. @returns {Void}
[ "Removes", "applied", "styles", "from", "HTML", "elements", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1581-L1589
6,534
glidejs/glide
dist/glide.esm.js
get
function get() { return Sizes.slideWidth * Sizes.length + Components.Gaps.grow + Components.Clones.grow; }
javascript
function get() { return Sizes.slideWidth * Sizes.length + Components.Gaps.grow + Components.Clones.grow; }
[ "function", "get", "(", ")", "{", "return", "Sizes", ".", "slideWidth", "*", "Sizes", ".", "length", "+", "Components", ".", "Gaps", ".", "grow", "+", "Components", ".", "Clones", ".", "grow", ";", "}" ]
Gets size of the slides wrapper. @return {Number}
[ "Gets", "size", "of", "the", "slides", "wrapper", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1620-L1622
6,535
glidejs/glide
dist/glide.esm.js
get
function get() { return Sizes.width / Glide.settings.perView - Components.Peek.reductor - Components.Gaps.reductor; }
javascript
function get() { return Sizes.width / Glide.settings.perView - Components.Peek.reductor - Components.Gaps.reductor; }
[ "function", "get", "(", ")", "{", "return", "Sizes", ".", "width", "/", "Glide", ".", "settings", ".", "perView", "-", "Components", ".", "Peek", ".", "reductor", "-", "Components", ".", "Gaps", ".", "reductor", ";", "}" ]
Gets width value of the single slide. @return {Number}
[ "Gets", "width", "value", "of", "the", "single", "slide", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1631-L1633
6,536
glidejs/glide
dist/glide.esm.js
typeClass
function typeClass() { Components.Html.root.classList.add(Glide.settings.classes[Glide.settings.type]); }
javascript
function typeClass() { Components.Html.root.classList.add(Glide.settings.classes[Glide.settings.type]); }
[ "function", "typeClass", "(", ")", "{", "Components", ".", "Html", ".", "root", ".", "classList", ".", "add", "(", "Glide", ".", "settings", ".", "classes", "[", "Glide", ".", "settings", ".", "type", "]", ")", ";", "}" ]
Adds `type` class to the glide element. @return {Void}
[ "Adds", "type", "class", "to", "the", "glide", "element", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1681-L1683
6,537
glidejs/glide
dist/glide.esm.js
removeClasses
function removeClasses() { var classes = Glide.settings.classes; Components.Html.root.classList.remove(classes[Glide.settings.type]); Components.Html.slides.forEach(function (sibling) { sibling.classList.remove(classes.activeSlide); }); }
javascript
function removeClasses() { var classes = Glide.settings.classes; Components.Html.root.classList.remove(classes[Glide.settings.type]); Components.Html.slides.forEach(function (sibling) { sibling.classList.remove(classes.activeSlide); }); }
[ "function", "removeClasses", "(", ")", "{", "var", "classes", "=", "Glide", ".", "settings", ".", "classes", ";", "Components", ".", "Html", ".", "root", ".", "classList", ".", "remove", "(", "classes", "[", "Glide", ".", "settings", ".", "type", "]", ")", ";", "Components", ".", "Html", ".", "slides", ".", "forEach", "(", "function", "(", "sibling", ")", "{", "sibling", ".", "classList", ".", "remove", "(", "classes", ".", "activeSlide", ")", ";", "}", ")", ";", "}" ]
Removes HTML classes applied at building. @return {Void}
[ "Removes", "HTML", "classes", "applied", "at", "building", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1710-L1718
6,538
glidejs/glide
dist/glide.esm.js
collect
function collect() { var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var slides = Components.Html.slides; var _Glide$settings = Glide.settings, perView = _Glide$settings.perView, classes = _Glide$settings.classes; var peekIncrementer = +!!Glide.settings.peek; var part = perView + peekIncrementer; var start = slides.slice(0, part); var end = slides.slice(-part); for (var r = 0; r < Math.max(1, Math.floor(perView / slides.length)); r++) { for (var i = 0; i < start.length; i++) { var clone = start[i].cloneNode(true); clone.classList.add(classes.cloneSlide); items.push(clone); } for (var _i = 0; _i < end.length; _i++) { var _clone = end[_i].cloneNode(true); _clone.classList.add(classes.cloneSlide); items.unshift(_clone); } } return items; }
javascript
function collect() { var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var slides = Components.Html.slides; var _Glide$settings = Glide.settings, perView = _Glide$settings.perView, classes = _Glide$settings.classes; var peekIncrementer = +!!Glide.settings.peek; var part = perView + peekIncrementer; var start = slides.slice(0, part); var end = slides.slice(-part); for (var r = 0; r < Math.max(1, Math.floor(perView / slides.length)); r++) { for (var i = 0; i < start.length; i++) { var clone = start[i].cloneNode(true); clone.classList.add(classes.cloneSlide); items.push(clone); } for (var _i = 0; _i < end.length; _i++) { var _clone = end[_i].cloneNode(true); _clone.classList.add(classes.cloneSlide); items.unshift(_clone); } } return items; }
[ "function", "collect", "(", ")", "{", "var", "items", "=", "arguments", ".", "length", ">", "0", "&&", "arguments", "[", "0", "]", "!==", "undefined", "?", "arguments", "[", "0", "]", ":", "[", "]", ";", "var", "slides", "=", "Components", ".", "Html", ".", "slides", ";", "var", "_Glide$settings", "=", "Glide", ".", "settings", ",", "perView", "=", "_Glide$settings", ".", "perView", ",", "classes", "=", "_Glide$settings", ".", "classes", ";", "var", "peekIncrementer", "=", "+", "!", "!", "Glide", ".", "settings", ".", "peek", ";", "var", "part", "=", "perView", "+", "peekIncrementer", ";", "var", "start", "=", "slides", ".", "slice", "(", "0", ",", "part", ")", ";", "var", "end", "=", "slides", ".", "slice", "(", "-", "part", ")", ";", "for", "(", "var", "r", "=", "0", ";", "r", "<", "Math", ".", "max", "(", "1", ",", "Math", ".", "floor", "(", "perView", "/", "slides", ".", "length", ")", ")", ";", "r", "++", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "start", ".", "length", ";", "i", "++", ")", "{", "var", "clone", "=", "start", "[", "i", "]", ".", "cloneNode", "(", "true", ")", ";", "clone", ".", "classList", ".", "add", "(", "classes", ".", "cloneSlide", ")", ";", "items", ".", "push", "(", "clone", ")", ";", "}", "for", "(", "var", "_i", "=", "0", ";", "_i", "<", "end", ".", "length", ";", "_i", "++", ")", "{", "var", "_clone", "=", "end", "[", "_i", "]", ".", "cloneNode", "(", "true", ")", ";", "_clone", ".", "classList", ".", "add", "(", "classes", ".", "cloneSlide", ")", ";", "items", ".", "unshift", "(", "_clone", ")", ";", "}", "}", "return", "items", ";", "}" ]
Collect clones with pattern. @return {Void}
[ "Collect", "clones", "with", "pattern", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1769-L1801
6,539
glidejs/glide
dist/glide.esm.js
append
function append() { var items = this.items; var _Components$Html = Components.Html, wrapper = _Components$Html.wrapper, slides = _Components$Html.slides; var half = Math.floor(items.length / 2); var prepend = items.slice(0, half).reverse(); var append = items.slice(half, items.length); var width = Components.Sizes.slideWidth + 'px'; for (var i = 0; i < append.length; i++) { wrapper.appendChild(append[i]); } for (var _i2 = 0; _i2 < prepend.length; _i2++) { wrapper.insertBefore(prepend[_i2], slides[0]); } for (var _i3 = 0; _i3 < items.length; _i3++) { items[_i3].style.width = width; } }
javascript
function append() { var items = this.items; var _Components$Html = Components.Html, wrapper = _Components$Html.wrapper, slides = _Components$Html.slides; var half = Math.floor(items.length / 2); var prepend = items.slice(0, half).reverse(); var append = items.slice(half, items.length); var width = Components.Sizes.slideWidth + 'px'; for (var i = 0; i < append.length; i++) { wrapper.appendChild(append[i]); } for (var _i2 = 0; _i2 < prepend.length; _i2++) { wrapper.insertBefore(prepend[_i2], slides[0]); } for (var _i3 = 0; _i3 < items.length; _i3++) { items[_i3].style.width = width; } }
[ "function", "append", "(", ")", "{", "var", "items", "=", "this", ".", "items", ";", "var", "_Components$Html", "=", "Components", ".", "Html", ",", "wrapper", "=", "_Components$Html", ".", "wrapper", ",", "slides", "=", "_Components$Html", ".", "slides", ";", "var", "half", "=", "Math", ".", "floor", "(", "items", ".", "length", "/", "2", ")", ";", "var", "prepend", "=", "items", ".", "slice", "(", "0", ",", "half", ")", ".", "reverse", "(", ")", ";", "var", "append", "=", "items", ".", "slice", "(", "half", ",", "items", ".", "length", ")", ";", "var", "width", "=", "Components", ".", "Sizes", ".", "slideWidth", "+", "'px'", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "append", ".", "length", ";", "i", "++", ")", "{", "wrapper", ".", "appendChild", "(", "append", "[", "i", "]", ")", ";", "}", "for", "(", "var", "_i2", "=", "0", ";", "_i2", "<", "prepend", ".", "length", ";", "_i2", "++", ")", "{", "wrapper", ".", "insertBefore", "(", "prepend", "[", "_i2", "]", ",", "slides", "[", "0", "]", ")", ";", "}", "for", "(", "var", "_i3", "=", "0", ";", "_i3", "<", "items", ".", "length", ";", "_i3", "++", ")", "{", "items", "[", "_i3", "]", ".", "style", ".", "width", "=", "width", ";", "}", "}" ]
Append cloned slides with generated pattern. @return {Void}
[ "Append", "cloned", "slides", "with", "generated", "pattern", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1809-L1832
6,540
glidejs/glide
dist/glide.esm.js
remove
function remove() { var items = this.items; for (var i = 0; i < items.length; i++) { Components.Html.wrapper.removeChild(items[i]); } }
javascript
function remove() { var items = this.items; for (var i = 0; i < items.length; i++) { Components.Html.wrapper.removeChild(items[i]); } }
[ "function", "remove", "(", ")", "{", "var", "items", "=", "this", ".", "items", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "++", ")", "{", "Components", ".", "Html", ".", "wrapper", ".", "removeChild", "(", "items", "[", "i", "]", ")", ";", "}", "}" ]
Remove all cloned slides. @return {Void}
[ "Remove", "all", "cloned", "slides", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1840-L1847
6,541
glidejs/glide
dist/glide.esm.js
get
function get() { return (Components.Sizes.slideWidth + Components.Gaps.value) * Clones.items.length; }
javascript
function get() { return (Components.Sizes.slideWidth + Components.Gaps.value) * Clones.items.length; }
[ "function", "get", "(", ")", "{", "return", "(", "Components", ".", "Sizes", ".", "slideWidth", "+", "Components", ".", "Gaps", ".", "value", ")", "*", "Clones", ".", "items", ".", "length", ";", "}" ]
Gets additional dimentions value caused by clones. @return {Number}
[ "Gets", "additional", "dimentions", "value", "caused", "by", "clones", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1856-L1858
6,542
glidejs/glide
dist/glide.esm.js
EventsBinder
function EventsBinder() { var listeners = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; classCallCheck(this, EventsBinder); this.listeners = listeners; }
javascript
function EventsBinder() { var listeners = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; classCallCheck(this, EventsBinder); this.listeners = listeners; }
[ "function", "EventsBinder", "(", ")", "{", "var", "listeners", "=", "arguments", ".", "length", ">", "0", "&&", "arguments", "[", "0", "]", "!==", "undefined", "?", "arguments", "[", "0", "]", ":", "{", "}", ";", "classCallCheck", "(", "this", ",", "EventsBinder", ")", ";", "this", ".", "listeners", "=", "listeners", ";", "}" ]
Construct a EventsBinder instance.
[ "Construct", "a", "EventsBinder", "instance", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1896-L1901
6,543
glidejs/glide
dist/glide.esm.js
bind
function bind() { Binder.on('resize', window, throttle(function () { Events.emit('resize'); }, Glide.settings.throttle)); }
javascript
function bind() { Binder.on('resize', window, throttle(function () { Events.emit('resize'); }, Glide.settings.throttle)); }
[ "function", "bind", "(", ")", "{", "Binder", ".", "on", "(", "'resize'", ",", "window", ",", "throttle", "(", "function", "(", ")", "{", "Events", ".", "emit", "(", "'resize'", ")", ";", "}", ",", "Glide", ".", "settings", ".", "throttle", ")", ")", ";", "}" ]
Binds `rezsize` listener to the window. It's a costly event, so we are debouncing it. @return {Void}
[ "Binds", "rezsize", "listener", "to", "the", "window", ".", "It", "s", "a", "costly", "event", "so", "we", "are", "debouncing", "it", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L1991-L1995
6,544
glidejs/glide
dist/glide.esm.js
resolve
function resolve(pattern) { var token = pattern.slice(0, 1); if (this.is('rtl')) { return pattern.split(token).join(FLIPED_MOVEMENTS[token]); } return pattern; }
javascript
function resolve(pattern) { var token = pattern.slice(0, 1); if (this.is('rtl')) { return pattern.split(token).join(FLIPED_MOVEMENTS[token]); } return pattern; }
[ "function", "resolve", "(", "pattern", ")", "{", "var", "token", "=", "pattern", ".", "slice", "(", "0", ",", "1", ")", ";", "if", "(", "this", ".", "is", "(", "'rtl'", ")", ")", "{", "return", "pattern", ".", "split", "(", "token", ")", ".", "join", "(", "FLIPED_MOVEMENTS", "[", "token", "]", ")", ";", "}", "return", "pattern", ";", "}" ]
Resolves pattern based on direction value @param {String} pattern @returns {String}
[ "Resolves", "pattern", "based", "on", "direction", "value" ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2045-L2053
6,545
glidejs/glide
dist/glide.esm.js
addClass
function addClass() { Components.Html.root.classList.add(Glide.settings.classes.direction[this.value]); }
javascript
function addClass() { Components.Html.root.classList.add(Glide.settings.classes.direction[this.value]); }
[ "function", "addClass", "(", ")", "{", "Components", ".", "Html", ".", "root", ".", "classList", ".", "add", "(", "Glide", ".", "settings", ".", "classes", ".", "direction", "[", "this", ".", "value", "]", ")", ";", "}" ]
Applies direction class to the root HTML element. @return {Void}
[ "Applies", "direction", "class", "to", "the", "root", "HTML", "element", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2072-L2074
6,546
glidejs/glide
dist/glide.esm.js
removeClass
function removeClass() { Components.Html.root.classList.remove(Glide.settings.classes.direction[this.value]); }
javascript
function removeClass() { Components.Html.root.classList.remove(Glide.settings.classes.direction[this.value]); }
[ "function", "removeClass", "(", ")", "{", "Components", ".", "Html", ".", "root", ".", "classList", ".", "remove", "(", "Glide", ".", "settings", ".", "classes", ".", "direction", "[", "this", ".", "value", "]", ")", ";", "}" ]
Removes direction class from the root HTML element. @return {Void}
[ "Removes", "direction", "class", "from", "the", "root", "HTML", "element", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2082-L2084
6,547
glidejs/glide
dist/glide.esm.js
Rtl
function Rtl (Glide, Components) { return { /** * Negates the passed translate if glide is in RTL option. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { if (Components.Direction.is('rtl')) { return -translate; } return translate; } }; }
javascript
function Rtl (Glide, Components) { return { /** * Negates the passed translate if glide is in RTL option. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { if (Components.Direction.is('rtl')) { return -translate; } return translate; } }; }
[ "function", "Rtl", "(", "Glide", ",", "Components", ")", "{", "return", "{", "/**\n * Negates the passed translate if glide is in RTL option.\n *\n * @param {Number} translate\n * @return {Number}\n */", "modify", ":", "function", "modify", "(", "translate", ")", "{", "if", "(", "Components", ".", "Direction", ".", "is", "(", "'rtl'", ")", ")", "{", "return", "-", "translate", ";", "}", "return", "translate", ";", "}", "}", ";", "}" ]
Reflects value of glide movement. @param {Object} Glide @param {Object} Components @return {Object}
[ "Reflects", "value", "of", "glide", "movement", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2149-L2165
6,548
glidejs/glide
dist/glide.esm.js
Gap
function Gap (Glide, Components) { return { /** * Modifies passed translate value with number in the `gap` settings. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { return translate + Components.Gaps.value * Glide.index; } }; }
javascript
function Gap (Glide, Components) { return { /** * Modifies passed translate value with number in the `gap` settings. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { return translate + Components.Gaps.value * Glide.index; } }; }
[ "function", "Gap", "(", "Glide", ",", "Components", ")", "{", "return", "{", "/**\n * Modifies passed translate value with number in the `gap` settings.\n *\n * @param {Number} translate\n * @return {Number}\n */", "modify", ":", "function", "modify", "(", "translate", ")", "{", "return", "translate", "+", "Components", ".", "Gaps", ".", "value", "*", "Glide", ".", "index", ";", "}", "}", ";", "}" ]
Updates glide movement with a `gap` settings. @param {Object} Glide @param {Object} Components @return {Object}
[ "Updates", "glide", "movement", "with", "a", "gap", "settings", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2174-L2186
6,549
glidejs/glide
dist/glide.esm.js
Grow
function Grow (Glide, Components) { return { /** * Adds to the passed translate width of the half of clones. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { return translate + Components.Clones.grow / 2; } }; }
javascript
function Grow (Glide, Components) { return { /** * Adds to the passed translate width of the half of clones. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { return translate + Components.Clones.grow / 2; } }; }
[ "function", "Grow", "(", "Glide", ",", "Components", ")", "{", "return", "{", "/**\n * Adds to the passed translate width of the half of clones.\n *\n * @param {Number} translate\n * @return {Number}\n */", "modify", ":", "function", "modify", "(", "translate", ")", "{", "return", "translate", "+", "Components", ".", "Clones", ".", "grow", "/", "2", ";", "}", "}", ";", "}" ]
Updates glide movement with width of additional clones width. @param {Object} Glide @param {Object} Components @return {Object}
[ "Updates", "glide", "movement", "with", "width", "of", "additional", "clones", "width", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2195-L2207
6,550
glidejs/glide
dist/glide.esm.js
modify
function modify(translate) { if (Glide.settings.focusAt >= 0) { var peek = Components.Peek.value; if (isObject(peek)) { return translate - peek.before; } return translate - peek; } return translate; }
javascript
function modify(translate) { if (Glide.settings.focusAt >= 0) { var peek = Components.Peek.value; if (isObject(peek)) { return translate - peek.before; } return translate - peek; } return translate; }
[ "function", "modify", "(", "translate", ")", "{", "if", "(", "Glide", ".", "settings", ".", "focusAt", ">=", "0", ")", "{", "var", "peek", "=", "Components", ".", "Peek", ".", "value", ";", "if", "(", "isObject", "(", "peek", ")", ")", "{", "return", "translate", "-", "peek", ".", "before", ";", "}", "return", "translate", "-", "peek", ";", "}", "return", "translate", ";", "}" ]
Modifies passed translate value with a `peek` setting. @param {Number} translate @return {Number}
[ "Modifies", "passed", "translate", "value", "with", "a", "peek", "setting", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2224-L2236
6,551
glidejs/glide
dist/glide.esm.js
Focusing
function Focusing (Glide, Components) { return { /** * Modifies passed translate value with index in the `focusAt` setting. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { var gap = Components.Gaps.value; var width = Components.Sizes.width; var focusAt = Glide.settings.focusAt; var slideWidth = Components.Sizes.slideWidth; if (focusAt === 'center') { return translate - (width / 2 - slideWidth / 2); } return translate - slideWidth * focusAt - gap * focusAt; } }; }
javascript
function Focusing (Glide, Components) { return { /** * Modifies passed translate value with index in the `focusAt` setting. * * @param {Number} translate * @return {Number} */ modify: function modify(translate) { var gap = Components.Gaps.value; var width = Components.Sizes.width; var focusAt = Glide.settings.focusAt; var slideWidth = Components.Sizes.slideWidth; if (focusAt === 'center') { return translate - (width / 2 - slideWidth / 2); } return translate - slideWidth * focusAt - gap * focusAt; } }; }
[ "function", "Focusing", "(", "Glide", ",", "Components", ")", "{", "return", "{", "/**\n * Modifies passed translate value with index in the `focusAt` setting.\n *\n * @param {Number} translate\n * @return {Number}\n */", "modify", ":", "function", "modify", "(", "translate", ")", "{", "var", "gap", "=", "Components", ".", "Gaps", ".", "value", ";", "var", "width", "=", "Components", ".", "Sizes", ".", "width", ";", "var", "focusAt", "=", "Glide", ".", "settings", ".", "focusAt", ";", "var", "slideWidth", "=", "Components", ".", "Sizes", ".", "slideWidth", ";", "if", "(", "focusAt", "===", "'center'", ")", "{", "return", "translate", "-", "(", "width", "/", "2", "-", "slideWidth", "/", "2", ")", ";", "}", "return", "translate", "-", "slideWidth", "*", "focusAt", "-", "gap", "*", "focusAt", ";", "}", "}", ";", "}" ]
Updates glide movement with a `focusAt` settings. @param {Object} Glide @param {Object} Components @return {Object}
[ "Updates", "glide", "movement", "with", "a", "focusAt", "settings", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2247-L2268
6,552
glidejs/glide
dist/glide.esm.js
mutator
function mutator (Glide, Components, Events) { /** * Merge instance transformers with collection of default transformers. * It's important that the Rtl component be last on the list, * so it reflects all previous transformations. * * @type {Array} */ var TRANSFORMERS = [Gap, Grow, Peeking, Focusing].concat(Glide._t, [Rtl]); return { /** * Piplines translate value with registered transformers. * * @param {Number} translate * @return {Number} */ mutate: function mutate(translate) { for (var i = 0; i < TRANSFORMERS.length; i++) { var transformer = TRANSFORMERS[i]; if (isFunction(transformer) && isFunction(transformer().modify)) { translate = transformer(Glide, Components, Events).modify(translate); } else { warn('Transformer should be a function that returns an object with `modify()` method'); } } return translate; } }; }
javascript
function mutator (Glide, Components, Events) { /** * Merge instance transformers with collection of default transformers. * It's important that the Rtl component be last on the list, * so it reflects all previous transformations. * * @type {Array} */ var TRANSFORMERS = [Gap, Grow, Peeking, Focusing].concat(Glide._t, [Rtl]); return { /** * Piplines translate value with registered transformers. * * @param {Number} translate * @return {Number} */ mutate: function mutate(translate) { for (var i = 0; i < TRANSFORMERS.length; i++) { var transformer = TRANSFORMERS[i]; if (isFunction(transformer) && isFunction(transformer().modify)) { translate = transformer(Glide, Components, Events).modify(translate); } else { warn('Transformer should be a function that returns an object with `modify()` method'); } } return translate; } }; }
[ "function", "mutator", "(", "Glide", ",", "Components", ",", "Events", ")", "{", "/**\n * Merge instance transformers with collection of default transformers.\n * It's important that the Rtl component be last on the list,\n * so it reflects all previous transformations.\n *\n * @type {Array}\n */", "var", "TRANSFORMERS", "=", "[", "Gap", ",", "Grow", ",", "Peeking", ",", "Focusing", "]", ".", "concat", "(", "Glide", ".", "_t", ",", "[", "Rtl", "]", ")", ";", "return", "{", "/**\n * Piplines translate value with registered transformers.\n *\n * @param {Number} translate\n * @return {Number}\n */", "mutate", ":", "function", "mutate", "(", "translate", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "TRANSFORMERS", ".", "length", ";", "i", "++", ")", "{", "var", "transformer", "=", "TRANSFORMERS", "[", "i", "]", ";", "if", "(", "isFunction", "(", "transformer", ")", "&&", "isFunction", "(", "transformer", "(", ")", ".", "modify", ")", ")", "{", "translate", "=", "transformer", "(", "Glide", ",", "Components", ",", "Events", ")", ".", "modify", "(", "translate", ")", ";", "}", "else", "{", "warn", "(", "'Transformer should be a function that returns an object with `modify()` method'", ")", ";", "}", "}", "return", "translate", ";", "}", "}", ";", "}" ]
Applies diffrent transformers on translate value. @param {Object} Glide @param {Object} Components @return {Object}
[ "Applies", "diffrent", "transformers", "on", "translate", "value", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2277-L2308
6,553
glidejs/glide
dist/glide.esm.js
mutate
function mutate(translate) { for (var i = 0; i < TRANSFORMERS.length; i++) { var transformer = TRANSFORMERS[i]; if (isFunction(transformer) && isFunction(transformer().modify)) { translate = transformer(Glide, Components, Events).modify(translate); } else { warn('Transformer should be a function that returns an object with `modify()` method'); } } return translate; }
javascript
function mutate(translate) { for (var i = 0; i < TRANSFORMERS.length; i++) { var transformer = TRANSFORMERS[i]; if (isFunction(transformer) && isFunction(transformer().modify)) { translate = transformer(Glide, Components, Events).modify(translate); } else { warn('Transformer should be a function that returns an object with `modify()` method'); } } return translate; }
[ "function", "mutate", "(", "translate", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "TRANSFORMERS", ".", "length", ";", "i", "++", ")", "{", "var", "transformer", "=", "TRANSFORMERS", "[", "i", "]", ";", "if", "(", "isFunction", "(", "transformer", ")", "&&", "isFunction", "(", "transformer", "(", ")", ".", "modify", ")", ")", "{", "translate", "=", "transformer", "(", "Glide", ",", "Components", ",", "Events", ")", ".", "modify", "(", "translate", ")", ";", "}", "else", "{", "warn", "(", "'Transformer should be a function that returns an object with `modify()` method'", ")", ";", "}", "}", "return", "translate", ";", "}" ]
Piplines translate value with registered transformers. @param {Number} translate @return {Number}
[ "Piplines", "translate", "value", "with", "registered", "transformers", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2294-L2306
6,554
glidejs/glide
dist/glide.esm.js
set
function set(value) { var transform = mutator(Glide, Components).mutate(value); Components.Html.wrapper.style.transform = 'translate3d(' + -1 * transform + 'px, 0px, 0px)'; }
javascript
function set(value) { var transform = mutator(Glide, Components).mutate(value); Components.Html.wrapper.style.transform = 'translate3d(' + -1 * transform + 'px, 0px, 0px)'; }
[ "function", "set", "(", "value", ")", "{", "var", "transform", "=", "mutator", "(", "Glide", ",", "Components", ")", ".", "mutate", "(", "value", ")", ";", "Components", ".", "Html", ".", "wrapper", ".", "style", ".", "transform", "=", "'translate3d('", "+", "-", "1", "*", "transform", "+", "'px, 0px, 0px)'", ";", "}" ]
Sets value of translate on HTML element. @param {Number} value @return {Void}
[ "Sets", "value", "of", "translate", "on", "HTML", "element", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2318-L2322
6,555
glidejs/glide
dist/glide.esm.js
compose
function compose(property) { var settings = Glide.settings; if (!disabled) { return property + ' ' + this.duration + 'ms ' + settings.animationTimingFunc; } return property + ' 0ms ' + settings.animationTimingFunc; }
javascript
function compose(property) { var settings = Glide.settings; if (!disabled) { return property + ' ' + this.duration + 'ms ' + settings.animationTimingFunc; } return property + ' 0ms ' + settings.animationTimingFunc; }
[ "function", "compose", "(", "property", ")", "{", "var", "settings", "=", "Glide", ".", "settings", ";", "if", "(", "!", "disabled", ")", "{", "return", "property", "+", "' '", "+", "this", ".", "duration", "+", "'ms '", "+", "settings", ".", "animationTimingFunc", ";", "}", "return", "property", "+", "' 0ms '", "+", "settings", ".", "animationTimingFunc", ";", "}" ]
Composes string of the CSS transition. @param {String} property @return {String}
[ "Composes", "string", "of", "the", "CSS", "transition", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2395-L2403
6,556
glidejs/glide
dist/glide.esm.js
set
function set() { var property = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'transform'; Components.Html.wrapper.style.transition = this.compose(property); }
javascript
function set() { var property = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'transform'; Components.Html.wrapper.style.transition = this.compose(property); }
[ "function", "set", "(", ")", "{", "var", "property", "=", "arguments", ".", "length", ">", "0", "&&", "arguments", "[", "0", "]", "!==", "undefined", "?", "arguments", "[", "0", "]", ":", "'transform'", ";", "Components", ".", "Html", ".", "wrapper", ".", "style", ".", "transition", "=", "this", ".", "compose", "(", "property", ")", ";", "}" ]
Sets value of transition on HTML element. @param {String=} property @return {Void}
[ "Sets", "value", "of", "transition", "on", "HTML", "element", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2412-L2416
6,557
glidejs/glide
dist/glide.esm.js
get
function get() { var settings = Glide.settings; if (Glide.isType('slider') && Components.Run.offset) { return settings.rewindDuration; } return settings.animationDuration; }
javascript
function get() { var settings = Glide.settings; if (Glide.isType('slider') && Components.Run.offset) { return settings.rewindDuration; } return settings.animationDuration; }
[ "function", "get", "(", ")", "{", "var", "settings", "=", "Glide", ".", "settings", ";", "if", "(", "Glide", ".", "isType", "(", "'slider'", ")", "&&", "Components", ".", "Run", ".", "offset", ")", "{", "return", "settings", ".", "rewindDuration", ";", "}", "return", "settings", ".", "animationDuration", ";", "}" ]
Gets duration of the transition based on currently running animation type. @return {Number}
[ "Gets", "duration", "of", "the", "transition", "based", "on", "currently", "running", "animation", "type", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2473-L2481
6,558
glidejs/glide
dist/glide.esm.js
start
function start(event) { if (!disabled && !Glide.disabled) { this.disable(); var swipe = this.touches(event); swipeSin = null; swipeStartX = toInt(swipe.pageX); swipeStartY = toInt(swipe.pageY); this.bindSwipeMove(); this.bindSwipeEnd(); Events.emit('swipe.start'); } }
javascript
function start(event) { if (!disabled && !Glide.disabled) { this.disable(); var swipe = this.touches(event); swipeSin = null; swipeStartX = toInt(swipe.pageX); swipeStartY = toInt(swipe.pageY); this.bindSwipeMove(); this.bindSwipeEnd(); Events.emit('swipe.start'); } }
[ "function", "start", "(", "event", ")", "{", "if", "(", "!", "disabled", "&&", "!", "Glide", ".", "disabled", ")", "{", "this", ".", "disable", "(", ")", ";", "var", "swipe", "=", "this", ".", "touches", "(", "event", ")", ";", "swipeSin", "=", "null", ";", "swipeStartX", "=", "toInt", "(", "swipe", ".", "pageX", ")", ";", "swipeStartY", "=", "toInt", "(", "swipe", ".", "pageY", ")", ";", "this", ".", "bindSwipeMove", "(", ")", ";", "this", ".", "bindSwipeEnd", "(", ")", ";", "Events", ".", "emit", "(", "'swipe.start'", ")", ";", "}", "}" ]
Handler for `swipestart` event. Calculates entry points of the user's tap. @param {Object} event @return {Void}
[ "Handler", "for", "swipestart", "event", ".", "Calculates", "entry", "points", "of", "the", "user", "s", "tap", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2579-L2594
6,559
glidejs/glide
dist/glide.esm.js
move
function move(event) { if (!Glide.disabled) { var _Glide$settings = Glide.settings, touchAngle = _Glide$settings.touchAngle, touchRatio = _Glide$settings.touchRatio, classes = _Glide$settings.classes; var swipe = this.touches(event); var subExSx = toInt(swipe.pageX) - swipeStartX; var subEySy = toInt(swipe.pageY) - swipeStartY; var powEX = Math.abs(subExSx << 2); var powEY = Math.abs(subEySy << 2); var swipeHypotenuse = Math.sqrt(powEX + powEY); var swipeCathetus = Math.sqrt(powEY); swipeSin = Math.asin(swipeCathetus / swipeHypotenuse); if (swipeSin * 180 / Math.PI < touchAngle) { event.stopPropagation(); Components.Move.make(subExSx * toFloat(touchRatio)); Components.Html.root.classList.add(classes.dragging); Events.emit('swipe.move'); } else { return false; } } }
javascript
function move(event) { if (!Glide.disabled) { var _Glide$settings = Glide.settings, touchAngle = _Glide$settings.touchAngle, touchRatio = _Glide$settings.touchRatio, classes = _Glide$settings.classes; var swipe = this.touches(event); var subExSx = toInt(swipe.pageX) - swipeStartX; var subEySy = toInt(swipe.pageY) - swipeStartY; var powEX = Math.abs(subExSx << 2); var powEY = Math.abs(subEySy << 2); var swipeHypotenuse = Math.sqrt(powEX + powEY); var swipeCathetus = Math.sqrt(powEY); swipeSin = Math.asin(swipeCathetus / swipeHypotenuse); if (swipeSin * 180 / Math.PI < touchAngle) { event.stopPropagation(); Components.Move.make(subExSx * toFloat(touchRatio)); Components.Html.root.classList.add(classes.dragging); Events.emit('swipe.move'); } else { return false; } } }
[ "function", "move", "(", "event", ")", "{", "if", "(", "!", "Glide", ".", "disabled", ")", "{", "var", "_Glide$settings", "=", "Glide", ".", "settings", ",", "touchAngle", "=", "_Glide$settings", ".", "touchAngle", ",", "touchRatio", "=", "_Glide$settings", ".", "touchRatio", ",", "classes", "=", "_Glide$settings", ".", "classes", ";", "var", "swipe", "=", "this", ".", "touches", "(", "event", ")", ";", "var", "subExSx", "=", "toInt", "(", "swipe", ".", "pageX", ")", "-", "swipeStartX", ";", "var", "subEySy", "=", "toInt", "(", "swipe", ".", "pageY", ")", "-", "swipeStartY", ";", "var", "powEX", "=", "Math", ".", "abs", "(", "subExSx", "<<", "2", ")", ";", "var", "powEY", "=", "Math", ".", "abs", "(", "subEySy", "<<", "2", ")", ";", "var", "swipeHypotenuse", "=", "Math", ".", "sqrt", "(", "powEX", "+", "powEY", ")", ";", "var", "swipeCathetus", "=", "Math", ".", "sqrt", "(", "powEY", ")", ";", "swipeSin", "=", "Math", ".", "asin", "(", "swipeCathetus", "/", "swipeHypotenuse", ")", ";", "if", "(", "swipeSin", "*", "180", "/", "Math", ".", "PI", "<", "touchAngle", ")", "{", "event", ".", "stopPropagation", "(", ")", ";", "Components", ".", "Move", ".", "make", "(", "subExSx", "*", "toFloat", "(", "touchRatio", ")", ")", ";", "Components", ".", "Html", ".", "root", ".", "classList", ".", "add", "(", "classes", ".", "dragging", ")", ";", "Events", ".", "emit", "(", "'swipe.move'", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}", "}" ]
Handler for `swipemove` event. Calculates user's tap angle and distance. @param {Object} event
[ "Handler", "for", "swipemove", "event", ".", "Calculates", "user", "s", "tap", "angle", "and", "distance", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2602-L2633
6,560
glidejs/glide
dist/glide.esm.js
end
function end(event) { if (!Glide.disabled) { var settings = Glide.settings; var swipe = this.touches(event); var threshold = this.threshold(event); var swipeDistance = swipe.pageX - swipeStartX; var swipeDeg = swipeSin * 180 / Math.PI; var steps = Math.round(swipeDistance / Components.Sizes.slideWidth); this.enable(); if (swipeDistance > threshold && swipeDeg < settings.touchAngle) { // While swipe is positive and greater than threshold move backward. if (settings.perTouch) { steps = Math.min(steps, toInt(settings.perTouch)); } if (Components.Direction.is('rtl')) { steps = -steps; } Components.Run.make(Components.Direction.resolve('<' + steps)); } else if (swipeDistance < -threshold && swipeDeg < settings.touchAngle) { // While swipe is negative and lower than negative threshold move forward. if (settings.perTouch) { steps = Math.max(steps, -toInt(settings.perTouch)); } if (Components.Direction.is('rtl')) { steps = -steps; } Components.Run.make(Components.Direction.resolve('>' + steps)); } else { // While swipe don't reach distance apply previous transform. Components.Move.make(); } Components.Html.root.classList.remove(settings.classes.dragging); this.unbindSwipeMove(); this.unbindSwipeEnd(); Events.emit('swipe.end'); } }
javascript
function end(event) { if (!Glide.disabled) { var settings = Glide.settings; var swipe = this.touches(event); var threshold = this.threshold(event); var swipeDistance = swipe.pageX - swipeStartX; var swipeDeg = swipeSin * 180 / Math.PI; var steps = Math.round(swipeDistance / Components.Sizes.slideWidth); this.enable(); if (swipeDistance > threshold && swipeDeg < settings.touchAngle) { // While swipe is positive and greater than threshold move backward. if (settings.perTouch) { steps = Math.min(steps, toInt(settings.perTouch)); } if (Components.Direction.is('rtl')) { steps = -steps; } Components.Run.make(Components.Direction.resolve('<' + steps)); } else if (swipeDistance < -threshold && swipeDeg < settings.touchAngle) { // While swipe is negative and lower than negative threshold move forward. if (settings.perTouch) { steps = Math.max(steps, -toInt(settings.perTouch)); } if (Components.Direction.is('rtl')) { steps = -steps; } Components.Run.make(Components.Direction.resolve('>' + steps)); } else { // While swipe don't reach distance apply previous transform. Components.Move.make(); } Components.Html.root.classList.remove(settings.classes.dragging); this.unbindSwipeMove(); this.unbindSwipeEnd(); Events.emit('swipe.end'); } }
[ "function", "end", "(", "event", ")", "{", "if", "(", "!", "Glide", ".", "disabled", ")", "{", "var", "settings", "=", "Glide", ".", "settings", ";", "var", "swipe", "=", "this", ".", "touches", "(", "event", ")", ";", "var", "threshold", "=", "this", ".", "threshold", "(", "event", ")", ";", "var", "swipeDistance", "=", "swipe", ".", "pageX", "-", "swipeStartX", ";", "var", "swipeDeg", "=", "swipeSin", "*", "180", "/", "Math", ".", "PI", ";", "var", "steps", "=", "Math", ".", "round", "(", "swipeDistance", "/", "Components", ".", "Sizes", ".", "slideWidth", ")", ";", "this", ".", "enable", "(", ")", ";", "if", "(", "swipeDistance", ">", "threshold", "&&", "swipeDeg", "<", "settings", ".", "touchAngle", ")", "{", "// While swipe is positive and greater than threshold move backward.", "if", "(", "settings", ".", "perTouch", ")", "{", "steps", "=", "Math", ".", "min", "(", "steps", ",", "toInt", "(", "settings", ".", "perTouch", ")", ")", ";", "}", "if", "(", "Components", ".", "Direction", ".", "is", "(", "'rtl'", ")", ")", "{", "steps", "=", "-", "steps", ";", "}", "Components", ".", "Run", ".", "make", "(", "Components", ".", "Direction", ".", "resolve", "(", "'<'", "+", "steps", ")", ")", ";", "}", "else", "if", "(", "swipeDistance", "<", "-", "threshold", "&&", "swipeDeg", "<", "settings", ".", "touchAngle", ")", "{", "// While swipe is negative and lower than negative threshold move forward.", "if", "(", "settings", ".", "perTouch", ")", "{", "steps", "=", "Math", ".", "max", "(", "steps", ",", "-", "toInt", "(", "settings", ".", "perTouch", ")", ")", ";", "}", "if", "(", "Components", ".", "Direction", ".", "is", "(", "'rtl'", ")", ")", "{", "steps", "=", "-", "steps", ";", "}", "Components", ".", "Run", ".", "make", "(", "Components", ".", "Direction", ".", "resolve", "(", "'>'", "+", "steps", ")", ")", ";", "}", "else", "{", "// While swipe don't reach distance apply previous transform.", "Components", ".", "Move", ".", "make", "(", ")", ";", "}", "Components", ".", "Html", ".", "root", ".", "classList", ".", "remove", "(", "settings", ".", "classes", ".", "dragging", ")", ";", "this", ".", "unbindSwipeMove", "(", ")", ";", "this", ".", "unbindSwipeEnd", "(", ")", ";", "Events", ".", "emit", "(", "'swipe.end'", ")", ";", "}", "}" ]
Handler for `swipeend` event. Finitializes user's tap and decides about glide move. @param {Object} event @return {Void}
[ "Handler", "for", "swipeend", "event", ".", "Finitializes", "user", "s", "tap", "and", "decides", "about", "glide", "move", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2642-L2689
6,561
glidejs/glide
dist/glide.esm.js
bindSwipeStart
function bindSwipeStart() { var _this = this; var settings = Glide.settings; if (settings.swipeThreshold) { Binder.on(START_EVENTS[0], Components.Html.wrapper, function (event) { _this.start(event); }, capture); } if (settings.dragThreshold) { Binder.on(START_EVENTS[1], Components.Html.wrapper, function (event) { _this.start(event); }, capture); } }
javascript
function bindSwipeStart() { var _this = this; var settings = Glide.settings; if (settings.swipeThreshold) { Binder.on(START_EVENTS[0], Components.Html.wrapper, function (event) { _this.start(event); }, capture); } if (settings.dragThreshold) { Binder.on(START_EVENTS[1], Components.Html.wrapper, function (event) { _this.start(event); }, capture); } }
[ "function", "bindSwipeStart", "(", ")", "{", "var", "_this", "=", "this", ";", "var", "settings", "=", "Glide", ".", "settings", ";", "if", "(", "settings", ".", "swipeThreshold", ")", "{", "Binder", ".", "on", "(", "START_EVENTS", "[", "0", "]", ",", "Components", ".", "Html", ".", "wrapper", ",", "function", "(", "event", ")", "{", "_this", ".", "start", "(", "event", ")", ";", "}", ",", "capture", ")", ";", "}", "if", "(", "settings", ".", "dragThreshold", ")", "{", "Binder", ".", "on", "(", "START_EVENTS", "[", "1", "]", ",", "Components", ".", "Html", ".", "wrapper", ",", "function", "(", "event", ")", "{", "_this", ".", "start", "(", "event", ")", ";", "}", ",", "capture", ")", ";", "}", "}" ]
Binds swipe's starting event. @return {Void}
[ "Binds", "swipe", "s", "starting", "event", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2697-L2713
6,562
glidejs/glide
dist/glide.esm.js
unbindSwipeStart
function unbindSwipeStart() { Binder.off(START_EVENTS[0], Components.Html.wrapper, capture); Binder.off(START_EVENTS[1], Components.Html.wrapper, capture); }
javascript
function unbindSwipeStart() { Binder.off(START_EVENTS[0], Components.Html.wrapper, capture); Binder.off(START_EVENTS[1], Components.Html.wrapper, capture); }
[ "function", "unbindSwipeStart", "(", ")", "{", "Binder", ".", "off", "(", "START_EVENTS", "[", "0", "]", ",", "Components", ".", "Html", ".", "wrapper", ",", "capture", ")", ";", "Binder", ".", "off", "(", "START_EVENTS", "[", "1", "]", ",", "Components", ".", "Html", ".", "wrapper", ",", "capture", ")", ";", "}" ]
Unbinds swipe's starting event. @return {Void}
[ "Unbinds", "swipe", "s", "starting", "event", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2721-L2724
6,563
glidejs/glide
dist/glide.esm.js
bindSwipeMove
function bindSwipeMove() { var _this2 = this; Binder.on(MOVE_EVENTS, Components.Html.wrapper, throttle(function (event) { _this2.move(event); }, Glide.settings.throttle), capture); }
javascript
function bindSwipeMove() { var _this2 = this; Binder.on(MOVE_EVENTS, Components.Html.wrapper, throttle(function (event) { _this2.move(event); }, Glide.settings.throttle), capture); }
[ "function", "bindSwipeMove", "(", ")", "{", "var", "_this2", "=", "this", ";", "Binder", ".", "on", "(", "MOVE_EVENTS", ",", "Components", ".", "Html", ".", "wrapper", ",", "throttle", "(", "function", "(", "event", ")", "{", "_this2", ".", "move", "(", "event", ")", ";", "}", ",", "Glide", ".", "settings", ".", "throttle", ")", ",", "capture", ")", ";", "}" ]
Binds swipe's moving event. @return {Void}
[ "Binds", "swipe", "s", "moving", "event", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2732-L2738
6,564
glidejs/glide
dist/glide.esm.js
bindSwipeEnd
function bindSwipeEnd() { var _this3 = this; Binder.on(END_EVENTS, Components.Html.wrapper, function (event) { _this3.end(event); }); }
javascript
function bindSwipeEnd() { var _this3 = this; Binder.on(END_EVENTS, Components.Html.wrapper, function (event) { _this3.end(event); }); }
[ "function", "bindSwipeEnd", "(", ")", "{", "var", "_this3", "=", "this", ";", "Binder", ".", "on", "(", "END_EVENTS", ",", "Components", ".", "Html", ".", "wrapper", ",", "function", "(", "event", ")", "{", "_this3", ".", "end", "(", "event", ")", ";", "}", ")", ";", "}" ]
Binds swipe's ending event. @return {Void}
[ "Binds", "swipe", "s", "ending", "event", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2756-L2762
6,565
glidejs/glide
dist/glide.esm.js
touches
function touches(event) { if (MOUSE_EVENTS.indexOf(event.type) > -1) { return event; } return event.touches[0] || event.changedTouches[0]; }
javascript
function touches(event) { if (MOUSE_EVENTS.indexOf(event.type) > -1) { return event; } return event.touches[0] || event.changedTouches[0]; }
[ "function", "touches", "(", "event", ")", "{", "if", "(", "MOUSE_EVENTS", ".", "indexOf", "(", "event", ".", "type", ")", ">", "-", "1", ")", "{", "return", "event", ";", "}", "return", "event", ".", "touches", "[", "0", "]", "||", "event", ".", "changedTouches", "[", "0", "]", ";", "}" ]
Normalizes event touches points accorting to different types. @param {Object} event
[ "Normalizes", "event", "touches", "points", "accorting", "to", "different", "types", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2780-L2786
6,566
glidejs/glide
dist/glide.esm.js
threshold
function threshold(event) { var settings = Glide.settings; if (MOUSE_EVENTS.indexOf(event.type) > -1) { return settings.dragThreshold; } return settings.swipeThreshold; }
javascript
function threshold(event) { var settings = Glide.settings; if (MOUSE_EVENTS.indexOf(event.type) > -1) { return settings.dragThreshold; } return settings.swipeThreshold; }
[ "function", "threshold", "(", "event", ")", "{", "var", "settings", "=", "Glide", ".", "settings", ";", "if", "(", "MOUSE_EVENTS", ".", "indexOf", "(", "event", ".", "type", ")", ">", "-", "1", ")", "{", "return", "settings", ".", "dragThreshold", ";", "}", "return", "settings", ".", "swipeThreshold", ";", "}" ]
Gets value of minimum swipe distance settings based on event type. @return {Number}
[ "Gets", "value", "of", "minimum", "swipe", "distance", "settings", "based", "on", "event", "type", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L2794-L2802
6,567
glidejs/glide
dist/glide.esm.js
detach
function detach() { prevented = true; if (!detached) { for (var i = 0; i < this.items.length; i++) { this.items[i].draggable = false; this.items[i].setAttribute('data-href', this.items[i].getAttribute('href')); this.items[i].removeAttribute('href'); } detached = true; } return this; }
javascript
function detach() { prevented = true; if (!detached) { for (var i = 0; i < this.items.length; i++) { this.items[i].draggable = false; this.items[i].setAttribute('data-href', this.items[i].getAttribute('href')); this.items[i].removeAttribute('href'); } detached = true; } return this; }
[ "function", "detach", "(", ")", "{", "prevented", "=", "true", ";", "if", "(", "!", "detached", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "items", ".", "length", ";", "i", "++", ")", "{", "this", ".", "items", "[", "i", "]", ".", "draggable", "=", "false", ";", "this", ".", "items", "[", "i", "]", ".", "setAttribute", "(", "'data-href'", ",", "this", ".", "items", "[", "i", "]", ".", "getAttribute", "(", "'href'", ")", ")", ";", "this", ".", "items", "[", "i", "]", ".", "removeAttribute", "(", "'href'", ")", ";", "}", "detached", "=", "true", ";", "}", "return", "this", ";", "}" ]
Detaches anchors click event inside glide. @return {self}
[ "Detaches", "anchors", "click", "event", "inside", "glide", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3000-L3016
6,568
glidejs/glide
dist/glide.esm.js
attach
function attach() { prevented = false; if (detached) { for (var i = 0; i < this.items.length; i++) { this.items[i].draggable = true; this.items[i].setAttribute('href', this.items[i].getAttribute('data-href')); } detached = false; } return this; }
javascript
function attach() { prevented = false; if (detached) { for (var i = 0; i < this.items.length; i++) { this.items[i].draggable = true; this.items[i].setAttribute('href', this.items[i].getAttribute('data-href')); } detached = false; } return this; }
[ "function", "attach", "(", ")", "{", "prevented", "=", "false", ";", "if", "(", "detached", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "items", ".", "length", ";", "i", "++", ")", "{", "this", ".", "items", "[", "i", "]", ".", "draggable", "=", "true", ";", "this", ".", "items", "[", "i", "]", ".", "setAttribute", "(", "'href'", ",", "this", ".", "items", "[", "i", "]", ".", "getAttribute", "(", "'data-href'", ")", ")", ";", "}", "detached", "=", "false", ";", "}", "return", "this", ";", "}" ]
Attaches anchors click events inside glide. @return {self}
[ "Attaches", "anchors", "click", "events", "inside", "glide", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3024-L3038
6,569
glidejs/glide
dist/glide.esm.js
mount
function mount() { /** * Collection of navigation HTML elements. * * @private * @type {HTMLCollection} */ this._n = Components.Html.root.querySelectorAll(NAV_SELECTOR); /** * Collection of controls HTML elements. * * @private * @type {HTMLCollection} */ this._c = Components.Html.root.querySelectorAll(CONTROLS_SELECTOR); this.addBindings(); }
javascript
function mount() { /** * Collection of navigation HTML elements. * * @private * @type {HTMLCollection} */ this._n = Components.Html.root.querySelectorAll(NAV_SELECTOR); /** * Collection of controls HTML elements. * * @private * @type {HTMLCollection} */ this._c = Components.Html.root.querySelectorAll(CONTROLS_SELECTOR); this.addBindings(); }
[ "function", "mount", "(", ")", "{", "/**\n * Collection of navigation HTML elements.\n *\n * @private\n * @type {HTMLCollection}\n */", "this", ".", "_n", "=", "Components", ".", "Html", ".", "root", ".", "querySelectorAll", "(", "NAV_SELECTOR", ")", ";", "/**\n * Collection of controls HTML elements.\n *\n * @private\n * @type {HTMLCollection}\n */", "this", ".", "_c", "=", "Components", ".", "Html", ".", "root", ".", "querySelectorAll", "(", "CONTROLS_SELECTOR", ")", ";", "this", ".", "addBindings", "(", ")", ";", "}" ]
Inits arrows. Binds events listeners to the arrows HTML elements. @return {Void}
[ "Inits", "arrows", ".", "Binds", "events", "listeners", "to", "the", "arrows", "HTML", "elements", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3103-L3121
6,570
glidejs/glide
dist/glide.esm.js
removeActive
function removeActive() { for (var i = 0; i < this._n.length; i++) { this.removeClass(this._n[i].children); } }
javascript
function removeActive() { for (var i = 0; i < this._n.length; i++) { this.removeClass(this._n[i].children); } }
[ "function", "removeActive", "(", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "_n", ".", "length", ";", "i", "++", ")", "{", "this", ".", "removeClass", "(", "this", ".", "_n", "[", "i", "]", ".", "children", ")", ";", "}", "}" ]
Removes active class to current slide. @return {Void}
[ "Removes", "active", "class", "to", "current", "slide", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3141-L3145
6,571
glidejs/glide
dist/glide.esm.js
addClass
function addClass(controls) { var settings = Glide.settings; var item = controls[Glide.index]; if (item) { item.classList.add(settings.classes.activeNav); siblings(item).forEach(function (sibling) { sibling.classList.remove(settings.classes.activeNav); }); } }
javascript
function addClass(controls) { var settings = Glide.settings; var item = controls[Glide.index]; if (item) { item.classList.add(settings.classes.activeNav); siblings(item).forEach(function (sibling) { sibling.classList.remove(settings.classes.activeNav); }); } }
[ "function", "addClass", "(", "controls", ")", "{", "var", "settings", "=", "Glide", ".", "settings", ";", "var", "item", "=", "controls", "[", "Glide", ".", "index", "]", ";", "if", "(", "item", ")", "{", "item", ".", "classList", ".", "add", "(", "settings", ".", "classes", ".", "activeNav", ")", ";", "siblings", "(", "item", ")", ".", "forEach", "(", "function", "(", "sibling", ")", "{", "sibling", ".", "classList", ".", "remove", "(", "settings", ".", "classes", ".", "activeNav", ")", ";", "}", ")", ";", "}", "}" ]
Toggles active class on items inside navigation. @param {HTMLElement} controls @return {Void}
[ "Toggles", "active", "class", "on", "items", "inside", "navigation", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3154-L3165
6,572
glidejs/glide
dist/glide.esm.js
removeClass
function removeClass(controls) { var item = controls[Glide.index]; if (item) { item.classList.remove(Glide.settings.classes.activeNav); } }
javascript
function removeClass(controls) { var item = controls[Glide.index]; if (item) { item.classList.remove(Glide.settings.classes.activeNav); } }
[ "function", "removeClass", "(", "controls", ")", "{", "var", "item", "=", "controls", "[", "Glide", ".", "index", "]", ";", "if", "(", "item", ")", "{", "item", ".", "classList", ".", "remove", "(", "Glide", ".", "settings", ".", "classes", ".", "activeNav", ")", ";", "}", "}" ]
Removes active class from active control. @param {HTMLElement} controls @return {Void}
[ "Removes", "active", "class", "from", "active", "control", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3174-L3180
6,573
glidejs/glide
dist/glide.esm.js
addBindings
function addBindings() { for (var i = 0; i < this._c.length; i++) { this.bind(this._c[i].children); } }
javascript
function addBindings() { for (var i = 0; i < this._c.length; i++) { this.bind(this._c[i].children); } }
[ "function", "addBindings", "(", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "_c", ".", "length", ";", "i", "++", ")", "{", "this", ".", "bind", "(", "this", ".", "_c", "[", "i", "]", ".", "children", ")", ";", "}", "}" ]
Adds handles to the each group of controls. @return {Void}
[ "Adds", "handles", "to", "the", "each", "group", "of", "controls", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3188-L3192
6,574
glidejs/glide
dist/glide.esm.js
removeBindings
function removeBindings() { for (var i = 0; i < this._c.length; i++) { this.unbind(this._c[i].children); } }
javascript
function removeBindings() { for (var i = 0; i < this._c.length; i++) { this.unbind(this._c[i].children); } }
[ "function", "removeBindings", "(", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "_c", ".", "length", ";", "i", "++", ")", "{", "this", ".", "unbind", "(", "this", ".", "_c", "[", "i", "]", ".", "children", ")", ";", "}", "}" ]
Removes handles from the each group of controls. @return {Void}
[ "Removes", "handles", "from", "the", "each", "group", "of", "controls", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3200-L3204
6,575
glidejs/glide
dist/glide.esm.js
bind
function bind(elements) { for (var i = 0; i < elements.length; i++) { Binder.on('click', elements[i], this.click); Binder.on('touchstart', elements[i], this.click, capture); } }
javascript
function bind(elements) { for (var i = 0; i < elements.length; i++) { Binder.on('click', elements[i], this.click); Binder.on('touchstart', elements[i], this.click, capture); } }
[ "function", "bind", "(", "elements", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "elements", ".", "length", ";", "i", "++", ")", "{", "Binder", ".", "on", "(", "'click'", ",", "elements", "[", "i", "]", ",", "this", ".", "click", ")", ";", "Binder", ".", "on", "(", "'touchstart'", ",", "elements", "[", "i", "]", ",", "this", ".", "click", ",", "capture", ")", ";", "}", "}" ]
Binds events to arrows HTML elements. @param {HTMLCollection} elements @return {Void}
[ "Binds", "events", "to", "arrows", "HTML", "elements", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3213-L3218
6,576
glidejs/glide
dist/glide.esm.js
unbind
function unbind(elements) { for (var i = 0; i < elements.length; i++) { Binder.off(['click', 'touchstart'], elements[i]); } }
javascript
function unbind(elements) { for (var i = 0; i < elements.length; i++) { Binder.off(['click', 'touchstart'], elements[i]); } }
[ "function", "unbind", "(", "elements", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "elements", ".", "length", ";", "i", "++", ")", "{", "Binder", ".", "off", "(", "[", "'click'", ",", "'touchstart'", "]", ",", "elements", "[", "i", "]", ")", ";", "}", "}" ]
Unbinds events binded to the arrows HTML elements. @param {HTMLCollection} elements @return {Void}
[ "Unbinds", "events", "binded", "to", "the", "arrows", "HTML", "elements", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3227-L3231
6,577
glidejs/glide
dist/glide.esm.js
click
function click(event) { event.preventDefault(); Components.Run.make(Components.Direction.resolve(event.currentTarget.getAttribute('data-glide-dir'))); }
javascript
function click(event) { event.preventDefault(); Components.Run.make(Components.Direction.resolve(event.currentTarget.getAttribute('data-glide-dir'))); }
[ "function", "click", "(", "event", ")", "{", "event", ".", "preventDefault", "(", ")", ";", "Components", ".", "Run", ".", "make", "(", "Components", ".", "Direction", ".", "resolve", "(", "event", ".", "currentTarget", ".", "getAttribute", "(", "'data-glide-dir'", ")", ")", ")", ";", "}" ]
Handles `click` event on the arrows HTML elements. Moves slider in driection precised in `data-glide-dir` attribute. @param {Object} event @return {Void}
[ "Handles", "click", "event", "on", "the", "arrows", "HTML", "elements", ".", "Moves", "slider", "in", "driection", "precised", "in", "data", "-", "glide", "-", "dir", "attribute", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3242-L3246
6,578
glidejs/glide
dist/glide.esm.js
press
function press(event) { if (event.keyCode === 39) { Components.Run.make(Components.Direction.resolve('>')); } if (event.keyCode === 37) { Components.Run.make(Components.Direction.resolve('<')); } }
javascript
function press(event) { if (event.keyCode === 39) { Components.Run.make(Components.Direction.resolve('>')); } if (event.keyCode === 37) { Components.Run.make(Components.Direction.resolve('<')); } }
[ "function", "press", "(", "event", ")", "{", "if", "(", "event", ".", "keyCode", "===", "39", ")", "{", "Components", ".", "Run", ".", "make", "(", "Components", ".", "Direction", ".", "resolve", "(", "'>'", ")", ")", ";", "}", "if", "(", "event", ".", "keyCode", "===", "37", ")", "{", "Components", ".", "Run", ".", "make", "(", "Components", ".", "Direction", ".", "resolve", "(", "'<'", ")", ")", ";", "}", "}" ]
Handles keyboard's arrows press and moving glide foward and backward. @param {Object} event @return {Void}
[ "Handles", "keyboard", "s", "arrows", "press", "and", "moving", "glide", "foward", "and", "backward", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3329-L3337
6,579
glidejs/glide
dist/glide.esm.js
start
function start() { var _this = this; if (Glide.settings.autoplay) { if (isUndefined(this._i)) { this._i = setInterval(function () { _this.stop(); Components.Run.make('>'); _this.start(); }, this.time); } } }
javascript
function start() { var _this = this; if (Glide.settings.autoplay) { if (isUndefined(this._i)) { this._i = setInterval(function () { _this.stop(); Components.Run.make('>'); _this.start(); }, this.time); } } }
[ "function", "start", "(", ")", "{", "var", "_this", "=", "this", ";", "if", "(", "Glide", ".", "settings", ".", "autoplay", ")", "{", "if", "(", "isUndefined", "(", "this", ".", "_i", ")", ")", "{", "this", ".", "_i", "=", "setInterval", "(", "function", "(", ")", "{", "_this", ".", "stop", "(", ")", ";", "Components", ".", "Run", ".", "make", "(", "'>'", ")", ";", "_this", ".", "start", "(", ")", ";", "}", ",", "this", ".", "time", ")", ";", "}", "}", "}" ]
Starts autoplaying in configured interval. @param {Boolean|Number} force Run autoplaying with passed interval regardless of `autoplay` settings @return {Void}
[ "Starts", "autoplaying", "in", "configured", "interval", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3397-L3411
6,580
glidejs/glide
dist/glide.esm.js
bind
function bind() { var _this2 = this; Binder.on('mouseover', Components.Html.root, function () { _this2.stop(); }); Binder.on('mouseout', Components.Html.root, function () { _this2.start(); }); }
javascript
function bind() { var _this2 = this; Binder.on('mouseover', Components.Html.root, function () { _this2.stop(); }); Binder.on('mouseout', Components.Html.root, function () { _this2.start(); }); }
[ "function", "bind", "(", ")", "{", "var", "_this2", "=", "this", ";", "Binder", ".", "on", "(", "'mouseover'", ",", "Components", ".", "Html", ".", "root", ",", "function", "(", ")", "{", "_this2", ".", "stop", "(", ")", ";", "}", ")", ";", "Binder", ".", "on", "(", "'mouseout'", ",", "Components", ".", "Html", ".", "root", ",", "function", "(", ")", "{", "_this2", ".", "start", "(", ")", ";", "}", ")", ";", "}" ]
Stops autoplaying while mouse is over glide's area. @return {Void}
[ "Stops", "autoplaying", "while", "mouse", "is", "over", "glide", "s", "area", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3429-L3439
6,581
glidejs/glide
dist/glide.esm.js
get
function get() { var autoplay = Components.Html.slides[Glide.index].getAttribute('data-glide-autoplay'); if (autoplay) { return toInt(autoplay); } return toInt(Glide.settings.autoplay); }
javascript
function get() { var autoplay = Components.Html.slides[Glide.index].getAttribute('data-glide-autoplay'); if (autoplay) { return toInt(autoplay); } return toInt(Glide.settings.autoplay); }
[ "function", "get", "(", ")", "{", "var", "autoplay", "=", "Components", ".", "Html", ".", "slides", "[", "Glide", ".", "index", "]", ".", "getAttribute", "(", "'data-glide-autoplay'", ")", ";", "if", "(", "autoplay", ")", "{", "return", "toInt", "(", "autoplay", ")", ";", "}", "return", "toInt", "(", "Glide", ".", "settings", ".", "autoplay", ")", ";", "}" ]
Gets time period value for the autoplay interval. Prioritizes times in `data-glide-autoplay` attrubutes over options. @return {Number}
[ "Gets", "time", "period", "value", "for", "the", "autoplay", "interval", ".", "Prioritizes", "times", "in", "data", "-", "glide", "-", "autoplay", "attrubutes", "over", "options", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3459-L3467
6,582
glidejs/glide
dist/glide.esm.js
match
function match(points) { if (typeof window.matchMedia !== 'undefined') { for (var point in points) { if (points.hasOwnProperty(point)) { if (window.matchMedia('(max-width: ' + point + 'px)').matches) { return points[point]; } } } } return defaults; }
javascript
function match(points) { if (typeof window.matchMedia !== 'undefined') { for (var point in points) { if (points.hasOwnProperty(point)) { if (window.matchMedia('(max-width: ' + point + 'px)').matches) { return points[point]; } } } } return defaults; }
[ "function", "match", "(", "points", ")", "{", "if", "(", "typeof", "window", ".", "matchMedia", "!==", "'undefined'", ")", "{", "for", "(", "var", "point", "in", "points", ")", "{", "if", "(", "points", ".", "hasOwnProperty", "(", "point", ")", ")", "{", "if", "(", "window", ".", "matchMedia", "(", "'(max-width: '", "+", "point", "+", "'px)'", ")", ".", "matches", ")", "{", "return", "points", "[", "point", "]", ";", "}", "}", "}", "}", "return", "defaults", ";", "}" ]
Matches settings for currectly matching media breakpoint. @param {Object} points @returns {Object}
[ "Matches", "settings", "for", "currectly", "matching", "media", "breakpoint", "." ]
593ad78d0f85bd7bcb6ac6ef487c607718605a89
https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L3574-L3586
6,583
ariutta/svg-pan-zoom
src/uniwheel.js
createCallback
function createCallback(element,callback) { var fn = function(originalEvent) { !originalEvent && ( originalEvent = window.event ); // create a normalized event object var event = { // keep a ref to the original event object originalEvent: originalEvent, target: originalEvent.target || originalEvent.srcElement, type: "wheel", deltaMode: originalEvent.type == "MozMousePixelScroll" ? 0 : 1, deltaX: 0, delatZ: 0, preventDefault: function() { originalEvent.preventDefault ? originalEvent.preventDefault() : originalEvent.returnValue = false; } }; // calculate deltaY (and deltaX) according to the event if ( support == "mousewheel" ) { event.deltaY = - 1/40 * originalEvent.wheelDelta; // Webkit also support wheelDeltaX originalEvent.wheelDeltaX && ( event.deltaX = - 1/40 * originalEvent.wheelDeltaX ); } else { event.deltaY = originalEvent.detail; } // it's time to fire the callback return callback( event ); }; fns.push({ element: element, fn: fn, }); return fn; }
javascript
function createCallback(element,callback) { var fn = function(originalEvent) { !originalEvent && ( originalEvent = window.event ); // create a normalized event object var event = { // keep a ref to the original event object originalEvent: originalEvent, target: originalEvent.target || originalEvent.srcElement, type: "wheel", deltaMode: originalEvent.type == "MozMousePixelScroll" ? 0 : 1, deltaX: 0, delatZ: 0, preventDefault: function() { originalEvent.preventDefault ? originalEvent.preventDefault() : originalEvent.returnValue = false; } }; // calculate deltaY (and deltaX) according to the event if ( support == "mousewheel" ) { event.deltaY = - 1/40 * originalEvent.wheelDelta; // Webkit also support wheelDeltaX originalEvent.wheelDeltaX && ( event.deltaX = - 1/40 * originalEvent.wheelDeltaX ); } else { event.deltaY = originalEvent.detail; } // it's time to fire the callback return callback( event ); }; fns.push({ element: element, fn: fn, }); return fn; }
[ "function", "createCallback", "(", "element", ",", "callback", ")", "{", "var", "fn", "=", "function", "(", "originalEvent", ")", "{", "!", "originalEvent", "&&", "(", "originalEvent", "=", "window", ".", "event", ")", ";", "// create a normalized event object", "var", "event", "=", "{", "// keep a ref to the original event object", "originalEvent", ":", "originalEvent", ",", "target", ":", "originalEvent", ".", "target", "||", "originalEvent", ".", "srcElement", ",", "type", ":", "\"wheel\"", ",", "deltaMode", ":", "originalEvent", ".", "type", "==", "\"MozMousePixelScroll\"", "?", "0", ":", "1", ",", "deltaX", ":", "0", ",", "delatZ", ":", "0", ",", "preventDefault", ":", "function", "(", ")", "{", "originalEvent", ".", "preventDefault", "?", "originalEvent", ".", "preventDefault", "(", ")", ":", "originalEvent", ".", "returnValue", "=", "false", ";", "}", "}", ";", "// calculate deltaY (and deltaX) according to the event", "if", "(", "support", "==", "\"mousewheel\"", ")", "{", "event", ".", "deltaY", "=", "-", "1", "/", "40", "*", "originalEvent", ".", "wheelDelta", ";", "// Webkit also support wheelDeltaX", "originalEvent", ".", "wheelDeltaX", "&&", "(", "event", ".", "deltaX", "=", "-", "1", "/", "40", "*", "originalEvent", ".", "wheelDeltaX", ")", ";", "}", "else", "{", "event", ".", "deltaY", "=", "originalEvent", ".", "detail", ";", "}", "// it's time to fire the callback", "return", "callback", "(", "event", ")", ";", "}", ";", "fns", ".", "push", "(", "{", "element", ":", "element", ",", "fn", ":", "fn", ",", "}", ")", ";", "return", "fn", ";", "}" ]
let's assume that remaining browsers are older Firefox
[ "let", "s", "assume", "that", "remaining", "browsers", "are", "older", "Firefox" ]
51cabbf6006729d40a214f79000166371e934e40
https://github.com/ariutta/svg-pan-zoom/blob/51cabbf6006729d40a214f79000166371e934e40/src/uniwheel.js#L28-L70
6,584
imba/imba
lib/compiler/nodes.js
subclass$
function subclass$(obj,sup) { for (var k in sup) { if (sup.hasOwnProperty(k)) obj[k] = sup[k]; }; // obj.__super__ = sup; obj.prototype = Object.create(sup.prototype); obj.__super__ = obj.prototype.__super__ = sup.prototype; obj.prototype.initialize = obj.prototype.constructor = obj; }
javascript
function subclass$(obj,sup) { for (var k in sup) { if (sup.hasOwnProperty(k)) obj[k] = sup[k]; }; // obj.__super__ = sup; obj.prototype = Object.create(sup.prototype); obj.__super__ = obj.prototype.__super__ = sup.prototype; obj.prototype.initialize = obj.prototype.constructor = obj; }
[ "function", "subclass$", "(", "obj", ",", "sup", ")", "{", "for", "(", "var", "k", "in", "sup", ")", "{", "if", "(", "sup", ".", "hasOwnProperty", "(", "k", ")", ")", "obj", "[", "k", "]", "=", "sup", "[", "k", "]", ";", "}", ";", "// obj.__super__ = sup;", "obj", ".", "prototype", "=", "Object", ".", "create", "(", "sup", ".", "prototype", ")", ";", "obj", ".", "__super__", "=", "obj", ".", "prototype", ".", "__super__", "=", "sup", ".", "prototype", ";", "obj", ".", "prototype", ".", "initialize", "=", "obj", ".", "prototype", ".", "constructor", "=", "obj", ";", "}" ]
helper for subclassing
[ "helper", "for", "subclassing" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L5-L13
6,585
imba/imba
lib/compiler/nodes.js
Parens
function Parens(value,open,close){ this.setup(); this._open = open; this._close = close; this._value = this.load(value); }
javascript
function Parens(value,open,close){ this.setup(); this._open = open; this._close = close; this._value = this.load(value); }
[ "function", "Parens", "(", "value", ",", "open", ",", "close", ")", "{", "this", ".", "setup", "(", ")", ";", "this", ".", "_open", "=", "open", ";", "this", ".", "_close", "=", "close", ";", "this", ".", "_value", "=", "this", ".", "load", "(", "value", ")", ";", "}" ]
Could inherit from valueNode
[ "Could", "inherit", "from", "valueNode" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L1689-L1694
6,586
imba/imba
lib/compiler/nodes.js
Param
function Param(name,defaults,typ){ // could have introduced bugs by moving back to identifier here this._traversed = false; this._name = name; this._defaults = defaults; this._typ = typ; this._variable = null; }
javascript
function Param(name,defaults,typ){ // could have introduced bugs by moving back to identifier here this._traversed = false; this._name = name; this._defaults = defaults; this._typ = typ; this._variable = null; }
[ "function", "Param", "(", "name", ",", "defaults", ",", "typ", ")", "{", "// could have introduced bugs by moving back to identifier here", "this", ".", "_traversed", "=", "false", ";", "this", ".", "_name", "=", "name", ";", "this", ".", "_defaults", "=", "defaults", ";", "this", ".", "_typ", "=", "typ", ";", "this", ".", "_variable", "=", "null", ";", "}" ]
export class PARAMS
[ "export", "class", "PARAMS" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L1921-L1928
6,587
imba/imba
lib/compiler/nodes.js
Root
function Root(body,opts){ this._traversed = false; this._body = AST.blk(body); this._scope = new RootScope(this,null); this._options = {}; }
javascript
function Root(body,opts){ this._traversed = false; this._body = AST.blk(body); this._scope = new RootScope(this,null); this._options = {}; }
[ "function", "Root", "(", "body", ",", "opts", ")", "{", "this", ".", "_traversed", "=", "false", ";", "this", ".", "_body", "=", "AST", ".", "blk", "(", "body", ")", ";", "this", ".", "_scope", "=", "new", "RootScope", "(", "this", ",", "null", ")", ";", "this", ".", "_options", "=", "{", "}", ";", "}" ]
Rename to Program?
[ "Rename", "to", "Program?" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L2630-L2635
6,588
imba/imba
lib/compiler/nodes.js
Literal
function Literal(v){ this._traversed = false; this._expression = true; this._cache = null; this._raw = null; this._value = this.load(v); }
javascript
function Literal(v){ this._traversed = false; this._expression = true; this._cache = null; this._raw = null; this._value = this.load(v); }
[ "function", "Literal", "(", "v", ")", "{", "this", ".", "_traversed", "=", "false", ";", "this", ".", "_expression", "=", "true", ";", "this", ".", "_cache", "=", "null", ";", "this", ".", "_raw", "=", "null", ";", "this", ".", "_value", "=", "this", ".", "load", "(", "v", ")", ";", "}" ]
Literals should probably not inherit from the same parent as arrays, tuples, objects would be better off inheriting from listnode.
[ "Literals", "should", "probably", "not", "inherit", "from", "the", "same", "parent", "as", "arrays", "tuples", "objects", "would", "be", "better", "off", "inheriting", "from", "listnode", "." ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L3676-L3682
6,589
imba/imba
lib/compiler/nodes.js
Str
function Str(v){ this._traversed = false; this._expression = true; this._cache = null; this._value = v; // should grab the actual value immediately? }
javascript
function Str(v){ this._traversed = false; this._expression = true; this._cache = null; this._value = v; // should grab the actual value immediately? }
[ "function", "Str", "(", "v", ")", "{", "this", ".", "_traversed", "=", "false", ";", "this", ".", "_expression", "=", "true", ";", "this", ".", "_cache", "=", "null", ";", "this", ".", "_value", "=", "v", ";", "// should grab the actual value immediately?", "}" ]
should be quoted no? what about strings in object-literals? we want to be able to see if the values are allowed
[ "should", "be", "quoted", "no?", "what", "about", "strings", "in", "object", "-", "literals?", "we", "want", "to", "be", "able", "to", "see", "if", "the", "values", "are", "allowed" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L3863-L3869
6,590
imba/imba
lib/compiler/nodes.js
InterpolatedString
function InterpolatedString(nodes,o){ if(o === undefined) o = {}; this._nodes = nodes; this._options = o; this; }
javascript
function InterpolatedString(nodes,o){ if(o === undefined) o = {}; this._nodes = nodes; this._options = o; this; }
[ "function", "InterpolatedString", "(", "nodes", ",", "o", ")", "{", "if", "(", "o", "===", "undefined", ")", "o", "=", "{", "}", ";", "this", ".", "_nodes", "=", "nodes", ";", "this", ".", "_options", "=", "o", ";", "this", ";", "}" ]
Currently not used - it would be better to use this for real interpolated strings though, than to break them up into their parts before parsing
[ "Currently", "not", "used", "-", "it", "would", "be", "better", "to", "use", "this", "for", "real", "interpolated", "strings", "though", "than", "to", "break", "them", "up", "into", "their", "parts", "before", "parsing" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L3913-L3918
6,591
imba/imba
lib/compiler/nodes.js
Identifier
function Identifier(value){ this._value = this.load(value); this._symbol = null; this._setter = null; if (("" + value).indexOf("?") >= 0) { this._safechain = true; }; // @safechain = ("" + value).indexOf("?") >= 0 this; }
javascript
function Identifier(value){ this._value = this.load(value); this._symbol = null; this._setter = null; if (("" + value).indexOf("?") >= 0) { this._safechain = true; }; // @safechain = ("" + value).indexOf("?") >= 0 this; }
[ "function", "Identifier", "(", "value", ")", "{", "this", ".", "_value", "=", "this", ".", "load", "(", "value", ")", ";", "this", ".", "_symbol", "=", "null", ";", "this", ".", "_setter", "=", "null", ";", "if", "(", "(", "\"\"", "+", "value", ")", ".", "indexOf", "(", "\"?\"", ")", ">=", "0", ")", "{", "this", ".", "_safechain", "=", "true", ";", "}", ";", "// @safechain = (\"\" + value).indexOf(\"?\") >= 0", "this", ";", "}" ]
really need to clean this up Drop the token?
[ "really", "need", "to", "clean", "this", "up", "Drop", "the", "token?" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L5859-L5869
6,592
imba/imba
lib/compiler/nodes.js
For
function For(o){ if(o === undefined) o = {}; this._traversed = false; this._options = o; this._scope = new ForScope(this); this._catcher = null; }
javascript
function For(o){ if(o === undefined) o = {}; this._traversed = false; this._options = o; this._scope = new ForScope(this); this._catcher = null; }
[ "function", "For", "(", "o", ")", "{", "if", "(", "o", "===", "undefined", ")", "o", "=", "{", "}", ";", "this", ".", "_traversed", "=", "false", ";", "this", ".", "_options", "=", "o", ";", "this", ".", "_scope", "=", "new", "ForScope", "(", "this", ")", ";", "this", ".", "_catcher", "=", "null", ";", "}" ]
This should define an open scope should rather
[ "This", "should", "define", "an", "open", "scope", "should", "rather" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L6816-L6822
6,593
imba/imba
lib/compiler/nodes.js
TagTree
function TagTree(owner,list,options){ if(options === undefined) options = {}; this._owner = owner; this._nodes = this.load(list); this._options = options; this._conditions = []; this._blocks = [this]; this._counter = 0; this; }
javascript
function TagTree(owner,list,options){ if(options === undefined) options = {}; this._owner = owner; this._nodes = this.load(list); this._options = options; this._conditions = []; this._blocks = [this]; this._counter = 0; this; }
[ "function", "TagTree", "(", "owner", ",", "list", ",", "options", ")", "{", "if", "(", "options", "===", "undefined", ")", "options", "=", "{", "}", ";", "this", ".", "_owner", "=", "owner", ";", "this", ".", "_nodes", "=", "this", ".", "load", "(", "list", ")", ";", "this", ".", "_options", "=", "options", ";", "this", ".", "_conditions", "=", "[", "]", ";", "this", ".", "_blocks", "=", "[", "this", "]", ";", "this", ".", "_counter", "=", "0", ";", "this", ";", "}" ]
This is a helper-node Should probably use the same type of listnode everywhere and simply flag the type as TagTree instead
[ "This", "is", "a", "helper", "-", "node", "Should", "probably", "use", "the", "same", "type", "of", "listnode", "everywhere", "and", "simply", "flag", "the", "type", "as", "TagTree", "instead" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L8268-L8277
6,594
imba/imba
lib/compiler/nodes.js
RootScope
function RootScope(){ RootScope.prototype.__super__.constructor.apply(this,arguments); this.register('global',this,{type: 'global'}); this.register('module',this,{type: 'global'}); this.register('window',this,{type: 'global'}); this.register('document',this,{type: 'global'}); this.register('exports',this,{type: 'global'}); this.register('console',this,{type: 'global'}); this.register('process',this,{type: 'global'}); this.register('parseInt',this,{type: 'global'}); this.register('parseFloat',this,{type: 'global'}); this.register('setTimeout',this,{type: 'global'}); this.register('setInterval',this,{type: 'global'}); this.register('setImmediate',this,{type: 'global'}); this.register('clearTimeout',this,{type: 'global'}); this.register('clearInterval',this,{type: 'global'}); this.register('clearImmediate',this,{type: 'global'}); this.register('isNaN',this,{type: 'global'}); this.register('isFinite',this,{type: 'global'}); this.register('__dirname',this,{type: 'global'}); this.register('__filename',this,{type: 'global'}); this.register('_',this,{type: 'global'}); // preregister global special variables here this._requires = {}; this._warnings = []; this._scopes = []; this._helpers = []; this._selfless = false; this._entities = new Entities(this); this._object = Obj.wrap({}); this._head = [this._vars]; }
javascript
function RootScope(){ RootScope.prototype.__super__.constructor.apply(this,arguments); this.register('global',this,{type: 'global'}); this.register('module',this,{type: 'global'}); this.register('window',this,{type: 'global'}); this.register('document',this,{type: 'global'}); this.register('exports',this,{type: 'global'}); this.register('console',this,{type: 'global'}); this.register('process',this,{type: 'global'}); this.register('parseInt',this,{type: 'global'}); this.register('parseFloat',this,{type: 'global'}); this.register('setTimeout',this,{type: 'global'}); this.register('setInterval',this,{type: 'global'}); this.register('setImmediate',this,{type: 'global'}); this.register('clearTimeout',this,{type: 'global'}); this.register('clearInterval',this,{type: 'global'}); this.register('clearImmediate',this,{type: 'global'}); this.register('isNaN',this,{type: 'global'}); this.register('isFinite',this,{type: 'global'}); this.register('__dirname',this,{type: 'global'}); this.register('__filename',this,{type: 'global'}); this.register('_',this,{type: 'global'}); // preregister global special variables here this._requires = {}; this._warnings = []; this._scopes = []; this._helpers = []; this._selfless = false; this._entities = new Entities(this); this._object = Obj.wrap({}); this._head = [this._vars]; }
[ "function", "RootScope", "(", ")", "{", "RootScope", ".", "prototype", ".", "__super__", ".", "constructor", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "register", "(", "'global'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'module'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'window'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'document'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'exports'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'console'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'process'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'parseInt'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'parseFloat'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'setTimeout'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'setInterval'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'setImmediate'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'clearTimeout'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'clearInterval'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'clearImmediate'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'isNaN'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'isFinite'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'__dirname'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'__filename'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "this", ".", "register", "(", "'_'", ",", "this", ",", "{", "type", ":", "'global'", "}", ")", ";", "// preregister global special variables here", "this", ".", "_requires", "=", "{", "}", ";", "this", ".", "_warnings", "=", "[", "]", ";", "this", ".", "_scopes", "=", "[", "]", ";", "this", ".", "_helpers", "=", "[", "]", ";", "this", ".", "_selfless", "=", "false", ";", "this", ".", "_entities", "=", "new", "Entities", "(", "this", ")", ";", "this", ".", "_object", "=", "Obj", ".", "wrap", "(", "{", "}", ")", ";", "this", ".", "_head", "=", "[", "this", ".", "_vars", "]", ";", "}" ]
RootScope is wrong? Rather TopScope or ProgramScope
[ "RootScope", "is", "wrong?", "Rather", "TopScope", "or", "ProgramScope" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/nodes.js#L9501-L9534
6,595
imba/imba
lib/imba/dom/reconciler.js
function(root,node,before) { if (node instanceof Array) { var i = 0; var c = node.taglen; var k = (c != null) ? ((node.domlen = c)) : node.length; while (i < k){ insertNestedBefore(root,node[i++],before); }; } else if (node && node._dom) { root.insertBefore(node,before); } else if (node != null && node !== false) { root.insertBefore(Imba.createTextNode(node),before); }; return before; }
javascript
function(root,node,before) { if (node instanceof Array) { var i = 0; var c = node.taglen; var k = (c != null) ? ((node.domlen = c)) : node.length; while (i < k){ insertNestedBefore(root,node[i++],before); }; } else if (node && node._dom) { root.insertBefore(node,before); } else if (node != null && node !== false) { root.insertBefore(Imba.createTextNode(node),before); }; return before; }
[ "function", "(", "root", ",", "node", ",", "before", ")", "{", "if", "(", "node", "instanceof", "Array", ")", "{", "var", "i", "=", "0", ";", "var", "c", "=", "node", ".", "taglen", ";", "var", "k", "=", "(", "c", "!=", "null", ")", "?", "(", "(", "node", ".", "domlen", "=", "c", ")", ")", ":", "node", ".", "length", ";", "while", "(", "i", "<", "k", ")", "{", "insertNestedBefore", "(", "root", ",", "node", "[", "i", "++", "]", ",", "before", ")", ";", "}", ";", "}", "else", "if", "(", "node", "&&", "node", ".", "_dom", ")", "{", "root", ".", "insertBefore", "(", "node", ",", "before", ")", ";", "}", "else", "if", "(", "node", "!=", "null", "&&", "node", "!==", "false", ")", "{", "root", ".", "insertBefore", "(", "Imba", ".", "createTextNode", "(", "node", ")", ",", "before", ")", ";", "}", ";", "return", "before", ";", "}" ]
insert nodes before a certain node does not need to return any tail, as before will still be correct there before must be an actual domnode
[ "insert", "nodes", "before", "a", "certain", "node", "does", "not", "need", "to", "return", "any", "tail", "as", "before", "will", "still", "be", "correct", "there", "before", "must", "be", "an", "actual", "domnode" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/imba/dom/reconciler.js#L53-L68
6,596
imba/imba
lib/imba/dom/reconciler.js
function(root,new$,old,caret) { var nl = new$.length; var ol = old.length; var cl = new$.cache.i$; // cache-length var i = 0,d = nl - ol; // TODO support caret // find the first index that is different while (i < ol && i < nl && new$[i] === old[i]){ i++; }; // conditionally prune cache if (cl > 1000 && (cl - nl) > 500) { new$.cache.$prune(new$); }; if (d > 0 && i == ol) { // added at end while (i < nl){ root.appendChild(new$[i++]); }; return; } else if (d > 0) { var i1 = nl; while (i1 > i && new$[i1 - 1] === old[i1 - 1 - d]){ i1--; }; if (d == (i1 - i)) { var before = old[i]._slot_; while (i < i1){ root.insertBefore(new$[i++],before); }; return; }; } else if (d < 0 && i == nl) { // removed at end while (i < ol){ root.removeChild(old[i++]); }; return; } else if (d < 0) { var i11 = ol; while (i11 > i && new$[i11 - 1 + d] === old[i11 - 1]){ i11--; }; if (d == (i - i11)) { while (i < i11){ root.removeChild(old[i++]); }; return; }; } else if (i == nl) { return; }; return reconcileCollectionChanges(root,new$,old,caret); }
javascript
function(root,new$,old,caret) { var nl = new$.length; var ol = old.length; var cl = new$.cache.i$; // cache-length var i = 0,d = nl - ol; // TODO support caret // find the first index that is different while (i < ol && i < nl && new$[i] === old[i]){ i++; }; // conditionally prune cache if (cl > 1000 && (cl - nl) > 500) { new$.cache.$prune(new$); }; if (d > 0 && i == ol) { // added at end while (i < nl){ root.appendChild(new$[i++]); }; return; } else if (d > 0) { var i1 = nl; while (i1 > i && new$[i1 - 1] === old[i1 - 1 - d]){ i1--; }; if (d == (i1 - i)) { var before = old[i]._slot_; while (i < i1){ root.insertBefore(new$[i++],before); }; return; }; } else if (d < 0 && i == nl) { // removed at end while (i < ol){ root.removeChild(old[i++]); }; return; } else if (d < 0) { var i11 = ol; while (i11 > i && new$[i11 - 1 + d] === old[i11 - 1]){ i11--; }; if (d == (i - i11)) { while (i < i11){ root.removeChild(old[i++]); }; return; }; } else if (i == nl) { return; }; return reconcileCollectionChanges(root,new$,old,caret); }
[ "function", "(", "root", ",", "new$", ",", "old", ",", "caret", ")", "{", "var", "nl", "=", "new$", ".", "length", ";", "var", "ol", "=", "old", ".", "length", ";", "var", "cl", "=", "new$", ".", "cache", ".", "i$", ";", "// cache-length", "var", "i", "=", "0", ",", "d", "=", "nl", "-", "ol", ";", "// TODO support caret", "// find the first index that is different", "while", "(", "i", "<", "ol", "&&", "i", "<", "nl", "&&", "new$", "[", "i", "]", "===", "old", "[", "i", "]", ")", "{", "i", "++", ";", "}", ";", "// conditionally prune cache", "if", "(", "cl", ">", "1000", "&&", "(", "cl", "-", "nl", ")", ">", "500", ")", "{", "new$", ".", "cache", ".", "$prune", "(", "new$", ")", ";", "}", ";", "if", "(", "d", ">", "0", "&&", "i", "==", "ol", ")", "{", "// added at end", "while", "(", "i", "<", "nl", ")", "{", "root", ".", "appendChild", "(", "new$", "[", "i", "++", "]", ")", ";", "}", ";", "return", ";", "}", "else", "if", "(", "d", ">", "0", ")", "{", "var", "i1", "=", "nl", ";", "while", "(", "i1", ">", "i", "&&", "new$", "[", "i1", "-", "1", "]", "===", "old", "[", "i1", "-", "1", "-", "d", "]", ")", "{", "i1", "--", ";", "}", ";", "if", "(", "d", "==", "(", "i1", "-", "i", ")", ")", "{", "var", "before", "=", "old", "[", "i", "]", ".", "_slot_", ";", "while", "(", "i", "<", "i1", ")", "{", "root", ".", "insertBefore", "(", "new$", "[", "i", "++", "]", ",", "before", ")", ";", "}", ";", "return", ";", "}", ";", "}", "else", "if", "(", "d", "<", "0", "&&", "i", "==", "nl", ")", "{", "// removed at end", "while", "(", "i", "<", "ol", ")", "{", "root", ".", "removeChild", "(", "old", "[", "i", "++", "]", ")", ";", "}", ";", "return", ";", "}", "else", "if", "(", "d", "<", "0", ")", "{", "var", "i11", "=", "ol", ";", "while", "(", "i11", ">", "i", "&&", "new$", "[", "i11", "-", "1", "+", "d", "]", "===", "old", "[", "i11", "-", "1", "]", ")", "{", "i11", "--", ";", "}", ";", "if", "(", "d", "==", "(", "i", "-", "i11", ")", ")", "{", "while", "(", "i", "<", "i11", ")", "{", "root", ".", "removeChild", "(", "old", "[", "i", "++", "]", ")", ";", "}", ";", "return", ";", "}", ";", "}", "else", "if", "(", "i", "==", "nl", ")", "{", "return", ";", "}", ";", "return", "reconcileCollectionChanges", "(", "root", ",", "new$", ",", "old", ",", "caret", ")", ";", "}" ]
TYPE 5 - we know that we are dealing with a single array of keyed tags - and root has no other children
[ "TYPE", "5", "-", "we", "know", "that", "we", "are", "dealing", "with", "a", "single", "array", "of", "keyed", "tags", "-", "and", "root", "has", "no", "other", "children" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/imba/dom/reconciler.js#L223-L283
6,597
imba/imba
lib/imba/dom/reconciler.js
function(root,new$,old,caret) { // var skipnew = new == null or new === false or new === true var newIsNull = new$ == null || new$ === false; var oldIsNull = old == null || old === false; if (new$ === old) { // remember that the caret must be an actual dom element // we should instead move the actual caret? - trust if (newIsNull) { return caret; } else if (new$._slot_) { return new$._slot_; } else if ((new$ instanceof Array) && new$.taglen != null) { return reconcileIndexedArray(root,new$,old,caret); } else { return caret ? caret.nextSibling : root._dom.firstChild; }; } else if (new$ instanceof Array) { if (old instanceof Array) { // look for slot instead? var typ = new$.static; if (typ || old.static) { // if the static is not nested - we could get a hint from compiler // and just skip it if (typ == old.static) { // should also include a reference? for (var i = 0, items = iter$(new$), len = items.length; i < len; i++) { // this is where we could do the triple equal directly caret = reconcileNested(root,items[i],old[i],caret); }; return caret; } else { removeNested(root,old,caret); }; // if they are not the same we continue through to the default } else { // Could use optimized loop if we know that it only consists of nodes return reconcileCollection(root,new$,old,caret); }; } else if (!oldIsNull) { if (old._slot_) { root.removeChild(old); } else { // old was a string-like object? root.removeChild(caret ? caret.nextSibling : root._dom.firstChild); }; }; return self.insertNestedAfter(root,new$,caret); // remove old } else if (!newIsNull && new$._slot_) { if (!oldIsNull) { removeNested(root,old,caret) }; return self.insertNestedAfter(root,new$,caret); } else if (newIsNull) { if (!oldIsNull) { removeNested(root,old,caret) }; return caret; } else { // if old did not exist we need to add a new directly var nextNode; // if old was array or imbatag we need to remove it and then add if (old instanceof Array) { removeNested(root,old,caret); } else if (old && old._slot_) { root.removeChild(old); } else if (!oldIsNull) { // ... nextNode = caret ? caret.nextSibling : root._dom.firstChild; if ((nextNode instanceof Text) && nextNode.textContent != new$) { nextNode.textContent = new$; return nextNode; }; }; // now add the textnode return self.insertNestedAfter(root,new$,caret); }; }
javascript
function(root,new$,old,caret) { // var skipnew = new == null or new === false or new === true var newIsNull = new$ == null || new$ === false; var oldIsNull = old == null || old === false; if (new$ === old) { // remember that the caret must be an actual dom element // we should instead move the actual caret? - trust if (newIsNull) { return caret; } else if (new$._slot_) { return new$._slot_; } else if ((new$ instanceof Array) && new$.taglen != null) { return reconcileIndexedArray(root,new$,old,caret); } else { return caret ? caret.nextSibling : root._dom.firstChild; }; } else if (new$ instanceof Array) { if (old instanceof Array) { // look for slot instead? var typ = new$.static; if (typ || old.static) { // if the static is not nested - we could get a hint from compiler // and just skip it if (typ == old.static) { // should also include a reference? for (var i = 0, items = iter$(new$), len = items.length; i < len; i++) { // this is where we could do the triple equal directly caret = reconcileNested(root,items[i],old[i],caret); }; return caret; } else { removeNested(root,old,caret); }; // if they are not the same we continue through to the default } else { // Could use optimized loop if we know that it only consists of nodes return reconcileCollection(root,new$,old,caret); }; } else if (!oldIsNull) { if (old._slot_) { root.removeChild(old); } else { // old was a string-like object? root.removeChild(caret ? caret.nextSibling : root._dom.firstChild); }; }; return self.insertNestedAfter(root,new$,caret); // remove old } else if (!newIsNull && new$._slot_) { if (!oldIsNull) { removeNested(root,old,caret) }; return self.insertNestedAfter(root,new$,caret); } else if (newIsNull) { if (!oldIsNull) { removeNested(root,old,caret) }; return caret; } else { // if old did not exist we need to add a new directly var nextNode; // if old was array or imbatag we need to remove it and then add if (old instanceof Array) { removeNested(root,old,caret); } else if (old && old._slot_) { root.removeChild(old); } else if (!oldIsNull) { // ... nextNode = caret ? caret.nextSibling : root._dom.firstChild; if ((nextNode instanceof Text) && nextNode.textContent != new$) { nextNode.textContent = new$; return nextNode; }; }; // now add the textnode return self.insertNestedAfter(root,new$,caret); }; }
[ "function", "(", "root", ",", "new$", ",", "old", ",", "caret", ")", "{", "// var skipnew = new == null or new === false or new === true", "var", "newIsNull", "=", "new$", "==", "null", "||", "new$", "===", "false", ";", "var", "oldIsNull", "=", "old", "==", "null", "||", "old", "===", "false", ";", "if", "(", "new$", "===", "old", ")", "{", "// remember that the caret must be an actual dom element", "// we should instead move the actual caret? - trust", "if", "(", "newIsNull", ")", "{", "return", "caret", ";", "}", "else", "if", "(", "new$", ".", "_slot_", ")", "{", "return", "new$", ".", "_slot_", ";", "}", "else", "if", "(", "(", "new$", "instanceof", "Array", ")", "&&", "new$", ".", "taglen", "!=", "null", ")", "{", "return", "reconcileIndexedArray", "(", "root", ",", "new$", ",", "old", ",", "caret", ")", ";", "}", "else", "{", "return", "caret", "?", "caret", ".", "nextSibling", ":", "root", ".", "_dom", ".", "firstChild", ";", "}", ";", "}", "else", "if", "(", "new$", "instanceof", "Array", ")", "{", "if", "(", "old", "instanceof", "Array", ")", "{", "// look for slot instead?", "var", "typ", "=", "new$", ".", "static", ";", "if", "(", "typ", "||", "old", ".", "static", ")", "{", "// if the static is not nested - we could get a hint from compiler", "// and just skip it", "if", "(", "typ", "==", "old", ".", "static", ")", "{", "// should also include a reference?", "for", "(", "var", "i", "=", "0", ",", "items", "=", "iter$", "(", "new$", ")", ",", "len", "=", "items", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "// this is where we could do the triple equal directly", "caret", "=", "reconcileNested", "(", "root", ",", "items", "[", "i", "]", ",", "old", "[", "i", "]", ",", "caret", ")", ";", "}", ";", "return", "caret", ";", "}", "else", "{", "removeNested", "(", "root", ",", "old", ",", "caret", ")", ";", "}", ";", "// if they are not the same we continue through to the default", "}", "else", "{", "// Could use optimized loop if we know that it only consists of nodes", "return", "reconcileCollection", "(", "root", ",", "new$", ",", "old", ",", "caret", ")", ";", "}", ";", "}", "else", "if", "(", "!", "oldIsNull", ")", "{", "if", "(", "old", ".", "_slot_", ")", "{", "root", ".", "removeChild", "(", "old", ")", ";", "}", "else", "{", "// old was a string-like object?", "root", ".", "removeChild", "(", "caret", "?", "caret", ".", "nextSibling", ":", "root", ".", "_dom", ".", "firstChild", ")", ";", "}", ";", "}", ";", "return", "self", ".", "insertNestedAfter", "(", "root", ",", "new$", ",", "caret", ")", ";", "// remove old", "}", "else", "if", "(", "!", "newIsNull", "&&", "new$", ".", "_slot_", ")", "{", "if", "(", "!", "oldIsNull", ")", "{", "removeNested", "(", "root", ",", "old", ",", "caret", ")", "}", ";", "return", "self", ".", "insertNestedAfter", "(", "root", ",", "new$", ",", "caret", ")", ";", "}", "else", "if", "(", "newIsNull", ")", "{", "if", "(", "!", "oldIsNull", ")", "{", "removeNested", "(", "root", ",", "old", ",", "caret", ")", "}", ";", "return", "caret", ";", "}", "else", "{", "// if old did not exist we need to add a new directly", "var", "nextNode", ";", "// if old was array or imbatag we need to remove it and then add", "if", "(", "old", "instanceof", "Array", ")", "{", "removeNested", "(", "root", ",", "old", ",", "caret", ")", ";", "}", "else", "if", "(", "old", "&&", "old", ".", "_slot_", ")", "{", "root", ".", "removeChild", "(", "old", ")", ";", "}", "else", "if", "(", "!", "oldIsNull", ")", "{", "// ...", "nextNode", "=", "caret", "?", "caret", ".", "nextSibling", ":", "root", ".", "_dom", ".", "firstChild", ";", "if", "(", "(", "nextNode", "instanceof", "Text", ")", "&&", "nextNode", ".", "textContent", "!=", "new$", ")", "{", "nextNode", ".", "textContent", "=", "new$", ";", "return", "nextNode", ";", "}", ";", "}", ";", "// now add the textnode", "return", "self", ".", "insertNestedAfter", "(", "root", ",", "new$", ",", "caret", ")", ";", "}", ";", "}" ]
the general reconciler that respects conditions etc caret is the current node we want to insert things after
[ "the", "general", "reconciler", "that", "respects", "conditions", "etc", "caret", "is", "the", "current", "node", "we", "want", "to", "insert", "things", "after" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/imba/dom/reconciler.js#L315-L393
6,598
imba/imba
lib/compiler/rewriter.js
function(token,i,tokens) { var type = token._type; if (!seenSingle && token.fromThen) { return true; }; var ifelse = type == 'IF' || type == 'UNLESS' || type == 'ELSE'; if (ifelse || type === 'CATCH') { seenSingle = true; }; if (ifelse || type === 'SWITCH' || type == 'TRY') { seenControl = true; }; var prev = self.tokenType(i - 1); if ((type == '.' || type == '?.' || type == '::') && prev === OUTDENT) { return true; }; if (endCallAtTerminator && (type === INDENT || type === TERMINATOR)) { return true; }; if ((type == 'WHEN' || type == 'BY') && !seenFor) { // console.log "dont close implicit call outside for" return false; }; var post = (tokens.length > (i + 1)) ? tokens[i + 1] : null; var postTyp = post && post._type; if (token.generated || prev === ',') { return false; }; var cond1 = (IMPLICIT_END_MAP[type] || (type == INDENT && !seenControl) || (type == 'DOS' && prev != '=')); if (!cond1) { return false; }; if (type !== INDENT) { return true; }; if (!IMPLICIT_BLOCK_MAP[prev] && self.tokenType(i - 2) != 'CLASS' && !(post && ((post.generated && postTyp == '{') || IMPLICIT_CALL_MAP[postTyp]))) { return true; }; return false; }
javascript
function(token,i,tokens) { var type = token._type; if (!seenSingle && token.fromThen) { return true; }; var ifelse = type == 'IF' || type == 'UNLESS' || type == 'ELSE'; if (ifelse || type === 'CATCH') { seenSingle = true; }; if (ifelse || type === 'SWITCH' || type == 'TRY') { seenControl = true; }; var prev = self.tokenType(i - 1); if ((type == '.' || type == '?.' || type == '::') && prev === OUTDENT) { return true; }; if (endCallAtTerminator && (type === INDENT || type === TERMINATOR)) { return true; }; if ((type == 'WHEN' || type == 'BY') && !seenFor) { // console.log "dont close implicit call outside for" return false; }; var post = (tokens.length > (i + 1)) ? tokens[i + 1] : null; var postTyp = post && post._type; if (token.generated || prev === ',') { return false; }; var cond1 = (IMPLICIT_END_MAP[type] || (type == INDENT && !seenControl) || (type == 'DOS' && prev != '=')); if (!cond1) { return false; }; if (type !== INDENT) { return true; }; if (!IMPLICIT_BLOCK_MAP[prev] && self.tokenType(i - 2) != 'CLASS' && !(post && ((post.generated && postTyp == '{') || IMPLICIT_CALL_MAP[postTyp]))) { return true; }; return false; }
[ "function", "(", "token", ",", "i", ",", "tokens", ")", "{", "var", "type", "=", "token", ".", "_type", ";", "if", "(", "!", "seenSingle", "&&", "token", ".", "fromThen", ")", "{", "return", "true", ";", "}", ";", "var", "ifelse", "=", "type", "==", "'IF'", "||", "type", "==", "'UNLESS'", "||", "type", "==", "'ELSE'", ";", "if", "(", "ifelse", "||", "type", "===", "'CATCH'", ")", "{", "seenSingle", "=", "true", ";", "}", ";", "if", "(", "ifelse", "||", "type", "===", "'SWITCH'", "||", "type", "==", "'TRY'", ")", "{", "seenControl", "=", "true", ";", "}", ";", "var", "prev", "=", "self", ".", "tokenType", "(", "i", "-", "1", ")", ";", "if", "(", "(", "type", "==", "'.'", "||", "type", "==", "'?.'", "||", "type", "==", "'::'", ")", "&&", "prev", "===", "OUTDENT", ")", "{", "return", "true", ";", "}", ";", "if", "(", "endCallAtTerminator", "&&", "(", "type", "===", "INDENT", "||", "type", "===", "TERMINATOR", ")", ")", "{", "return", "true", ";", "}", ";", "if", "(", "(", "type", "==", "'WHEN'", "||", "type", "==", "'BY'", ")", "&&", "!", "seenFor", ")", "{", "// console.log \"dont close implicit call outside for\"", "return", "false", ";", "}", ";", "var", "post", "=", "(", "tokens", ".", "length", ">", "(", "i", "+", "1", ")", ")", "?", "tokens", "[", "i", "+", "1", "]", ":", "null", ";", "var", "postTyp", "=", "post", "&&", "post", ".", "_type", ";", "if", "(", "token", ".", "generated", "||", "prev", "===", "','", ")", "{", "return", "false", ";", "}", ";", "var", "cond1", "=", "(", "IMPLICIT_END_MAP", "[", "type", "]", "||", "(", "type", "==", "INDENT", "&&", "!", "seenControl", ")", "||", "(", "type", "==", "'DOS'", "&&", "prev", "!=", "'='", ")", ")", ";", "if", "(", "!", "cond1", ")", "{", "return", "false", ";", "}", ";", "if", "(", "type", "!==", "INDENT", ")", "{", "return", "true", ";", "}", ";", "if", "(", "!", "IMPLICIT_BLOCK_MAP", "[", "prev", "]", "&&", "self", ".", "tokenType", "(", "i", "-", "2", ")", "!=", "'CLASS'", "&&", "!", "(", "post", "&&", "(", "(", "post", ".", "generated", "&&", "postTyp", "==", "'{'", ")", "||", "IMPLICIT_CALL_MAP", "[", "postTyp", "]", ")", ")", ")", "{", "return", "true", ";", "}", ";", "return", "false", ";", "}" ]
function will not be optimized in single run could tro to move this out
[ "function", "will", "not", "be", "optimized", "in", "single", "run", "could", "tro", "to", "move", "this", "out" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/compiler/rewriter.js#L768-L823
6,599
imba/imba
lib/jison/jison.js
processOperators
function processOperators (ops) { if (!ops) return {}; var operators = {}; for (var i=0,k,prec;prec=ops[i]; i++) { for (k=1;k < prec.length;k++) { operators[prec[k]] = {precedence: i+1, assoc: prec[0]}; } } return operators; }
javascript
function processOperators (ops) { if (!ops) return {}; var operators = {}; for (var i=0,k,prec;prec=ops[i]; i++) { for (k=1;k < prec.length;k++) { operators[prec[k]] = {precedence: i+1, assoc: prec[0]}; } } return operators; }
[ "function", "processOperators", "(", "ops", ")", "{", "if", "(", "!", "ops", ")", "return", "{", "}", ";", "var", "operators", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ",", "k", ",", "prec", ";", "prec", "=", "ops", "[", "i", "]", ";", "i", "++", ")", "{", "for", "(", "k", "=", "1", ";", "k", "<", "prec", ".", "length", ";", "k", "++", ")", "{", "operators", "[", "prec", "[", "k", "]", "]", "=", "{", "precedence", ":", "i", "+", "1", ",", "assoc", ":", "prec", "[", "0", "]", "}", ";", "}", "}", "return", "operators", ";", "}" ]
set precedence and associativity of operators
[ "set", "precedence", "and", "associativity", "of", "operators" ]
cbf24f7ba961c33c105a8fd5a9fff18286d119bb
https://github.com/imba/imba/blob/cbf24f7ba961c33c105a8fd5a9fff18286d119bb/lib/jison/jison.js#L161-L170