code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
traverse = function (attrib, callback, condition) { if (typeof attrib === 'function') { callback = attrib; for (x = 0; x <= last; x++) { if (!condition()) continue; self.bindToDomElement(collection[x]); if (false === callback(collection[x])...
Augments a collection of DOM elements with some helpful methods. Methods: - filter(selector) - each(callback) -OR- each(attribute, callback) - first(), last(), even(), odd() - has(selector) @param {Array} collection @api public
traverse
javascript
node-js-libs/node.io
lib/node.io/dom.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/dom.js
MIT
rawtext = function () { var text = ''; if (hasChildren) { for (x = 0; x <= last; x++) { if (elem.children[x].type === 'text') { text += elem.children[x].data; } } } return text; }
Augments a DOM element with some helpful methods / getters. Getters: - innerHTML - rawtext - returns text immediately inside the selected element - rawfulltext - same as rawtext, but also includes text inside nested elems - text - rawtext but trimmed, BR's replaced with \n, and entities decoded - f...
rawtext
javascript
node-js-libs/node.io
lib/node.io/dom.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/dom.js
MIT
text = function () { var text = ''; if (hasChildren) { for (x = 0; x <= last; x++) { if (elem.children[x].type === 'text') { text += elem.children[x].data.trim(); } else if (elem.children[x].name === 'br') { text += '\n'...
Augments a DOM element with some helpful methods / getters. Getters: - innerHTML - rawtext - returns text immediately inside the selected element - rawfulltext - same as rawtext, but also includes text inside nested elems - text - rawtext but trimmed, BR's replaced with \n, and entities decoded - f...
text
javascript
node-js-libs/node.io
lib/node.io/dom.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/dom.js
MIT
rawfulltext = function (elem) { var text = ''; if (elem.children && elem.children.length > 0) { for (var i = 0, l = elem.children.length; i < l; i++) { if (elem.children[i].type === 'text') { text += elem.children[i].data; } else if (elem.c...
Augments a DOM element with some helpful methods / getters. Getters: - innerHTML - rawtext - returns text immediately inside the selected element - rawfulltext - same as rawtext, but also includes text inside nested elems - text - rawtext but trimmed, BR's replaced with \n, and entities decoded - f...
rawfulltext
javascript
node-js-libs/node.io
lib/node.io/dom.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/dom.js
MIT
fulltext = function (elem) { var text = ''; if (elem.children && elem.children.length > 0) { for (var i = 0, l = elem.children.length; i < l; i++) { if (elem.children[i].type === 'text') { text += elem.children[i].data.trim(); } else if (el...
Augments a DOM element with some helpful methods / getters. Getters: - innerHTML - rawtext - returns text immediately inside the selected element - rawfulltext - same as rawtext, but also includes text inside nested elems - text - rawtext but trimmed, BR's replaced with \n, and entities decoded - f...
fulltext
javascript
node-js-libs/node.io
lib/node.io/dom.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/dom.js
MIT
innerHTML = function (elem) { var text; switch (elem.type) { case 'tag': case 'script': case 'style': text = '<' + elem.raw + '>'; //Skip if the tag is <short /> if (elem.raw[elem.raw.length-1] !== '/') { if (elem.children && e...
Augments a DOM element with some helpful methods / getters. Getters: - innerHTML - rawtext - returns text immediately inside the selected element - rawfulltext - same as rawtext, but also includes text inside nested elems - text - rawtext but trimmed, BR's replaced with \n, and entities decoded - f...
innerHTML
javascript
node-js-libs/node.io
lib/node.io/dom.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/dom.js
MIT
trim_slash = function (path) { if (path[path.length - 1] === '/') { path = path.substr(0, path.length - 1); } return path; }
Finds all files in the specified directory and returns each file path as input. To recurse subdirectories, set the `recurse` op. @param {String} path @api public
trim_slash
javascript
node-js-libs/node.io
lib/node.io/io.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/io.js
MIT
return_lines = function () { if (read_id !== last_read_id && !self.input_stream.end) { //Wait for a previous request to return lines utils.tick(return_lines); } else { last_read_id++; callback(self.input_stream.lines.length ? self.i...
Returns lines (\n or \r\n terminated) from the input stream. Lines are returned in the same order as they are requested. @param {Number} start @param {Number} num @param {Function} callback @api public
return_lines
javascript
node-js-libs/node.io
lib/node.io/io.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/io.js
MIT
write_lines = function () { if (write_id !== last_write_id) { //Wait for a previous requests utils.tick(write_lines); } else { last_write_id++; var str = utils.dataToString(data, self.options.newline); var written = self.output_streams[file]...
Writes data to the specified file. Writes are performed in the same order as write() is called. @param {String} file @param {String} data @param {Function} callback (optional) @api public
write_lines
javascript
node-js-libs/node.io
lib/node.io/io.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/io.js
MIT
wait_for_drain = function () { var keep_waiting = false; for (var i in self.output_streams) { var stream = self.output_streams[i]; if (stream._queue) { if (stream._queue.length === 0) { stream.end(); } else { ...
Waits for all output streams to drain before calling `callback`. @param {Function} callback @api public
wait_for_drain
javascript
node-js-libs/node.io
lib/node.io/io.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/io.js
MIT
__extends = function (child, parent) { for (var key in parent) { if (parent.hasOwnProperty(key)) child[key] = parent[key] } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }
Creates a new Job with the specified options @param {Number} options (optional) @api public
__extends
javascript
node-js-libs/node.io
lib/node.io/job.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/job.js
MIT
JobClass = function (options , methods) { //Job.apply(this, [options]); JobClass.__super__.constructor.apply(this, arguments); //Handle special input / output cases (see io.js) this.handleSpecialIO(); }
Creates a new Job with the specified options @param {Number} options (optional) @api public
JobClass
javascript
node-js-libs/node.io
lib/node.io/job.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/job.js
MIT
function Child () { Child.__super__.constructor.apply(this, arguments); }
Creates a new Job with the specified options @param {Number} options (optional) @api public
Child
javascript
node-js-libs/node.io
lib/node.io/job.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/job.js
MIT
Processor = function (options, start_as_slave) { isSlave = start_as_slave && !process.env._CHILD_ID_; isMaster = !start_as_slave && !process.env._CHILD_ID_; this.options = options || {}; this.jobs = {}; }
Create a new Processor with the specified options. @param {Object} options (optional) @param {Bool} start_as_slave (optional) @api public
Processor
javascript
node-js-libs/node.io
lib/node.io/processor.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/processor.js
MIT
onload = function (job_name, job_obj) { //If we're capturing output, we need to explicitly override job.output() if (isMaster && capture_output) { var output = []; job_obj.output = function (out) { if (out instanceof Array && job_obj.options.flatten) { ...
exports.start Starts a job with the specified options and callback. `job` can be a string (path) or an instance of nodeio.Job. `callback` takes (err) or (err, output) if `capture_output` is true. @param {Object|String} job @param {Object} options (optional) @param {Function} callback (optional) @param {Bool} capture_...
onload
javascript
node-js-libs/node.io
lib/node.io/processor.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/processor.js
MIT
areWorkersComplete = function () { if (job.pull_requests < worker_count) { return false; } for (var i = 0; i < worker_count; i++) { if (!job.worker_complete[i]) { return false; } } return true; }
Sets up job events to be handled by the master process. @param {Object} job @param {Array} workers (optional) @api public
areWorkersComplete
javascript
node-js-libs/node.io
lib/node.io/process_master.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/process_master.js
MIT
handle_input = function (input) { if (typeof input !== 'undefined' && input !== null && input !== false) { master.emit('input', input, for_worker); } else { //No input? We might be done.. var isComplete = function () { //Check...
Sets up job events to be handled by the master process. @param {Object} job @param {Array} workers (optional) @api public
handle_input
javascript
node-js-libs/node.io
lib/node.io/process_master.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/process_master.js
MIT
isComplete = function () { //Check if any input was added dynamically if (job.input.length > 0) { job.is_complete = false; return false; } //Wait for workers or instances that are still worki...
Sets up job events to be handled by the master process. @param {Object} job @param {Array} workers (optional) @api public
isComplete
javascript
node-js-libs/node.io
lib/node.io/process_master.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/process_master.js
MIT
oncomplete = function () { //Output information about job running time, benchmarks, etc. if //the `benchmark` op is set var time; if (job.options.benchmark) { var mb_read, mb_written, MB = 1024 * 1024, now = new Date(); var round = functi...
Sets up job events to be handled by the master process. @param {Object} job @param {Array} workers (optional) @api public
oncomplete
javascript
node-js-libs/node.io
lib/node.io/process_master.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/process_master.js
MIT
round = function (val) { return Math.round(val * 1000) / 1000; }
Sets up job events to be handled by the master process. @param {Object} job @param {Array} workers (optional) @api public
round
javascript
node-js-libs/node.io
lib/node.io/process_master.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/process_master.js
MIT
createInstance = function () { var instance = new JobClass(job.options, {}); //We only need a subset of the methods instance.run = job.obj.run; instance.fail = job.obj.fail; instance.debug = job.obj.debug; instance.status = job.obj.status; instance.exit = job.ob...
Sets up job events to be handled by the slave or child process. @param {Object} job @param {Object} master (optional) @api public
createInstance
javascript
node-js-libs/node.io
lib/node.io/process_worker.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/process_worker.js
MIT
emit = function () { job.instances--; //Reuse the instance later on job.instance_pool.push(instance); worker.emit('process'); }
Sets up job events to be handled by the slave or child process. @param {Object} job @param {Object} master (optional) @api public
emit
javascript
node-js-libs/node.io
lib/node.io/process_worker.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/process_worker.js
MIT
parse_callback = function (err, data) { callback(err, data, response.headers, response); }
Makes a request to the specified resource and returns the response body response headers. `callback` takes (err, data, headers). `parse` is an optional callback which can be used to filter or decode the body before `callback` is called. @param {String} method @param {String} resource @param {Object} body (optional) @...
parse_callback
javascript
node-js-libs/node.io
lib/node.io/request.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/request.js
MIT
status = function (msg, type) { var cmd = type; switch (type) { case 'info': msg = '\x1B[33mINFO\x1B[0m: ' + msg; break; case 'debug': cmd = 'info'; msg = '\x1B[36mDEBUG\x1B[0m: ' + msg; break; case 'error': case 'fatal': cmd = 'error'; ...
Outputs a styled message to the console. @param {String} msg @param {String} type (optional) @api public
status
javascript
node-js-libs/node.io
lib/node.io/utils.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/utils.js
MIT
removeFile = function () { try { fs.unlinkSync(file); } catch (e) {} try { process.exit(); } catch (e) {} }
Removes the specified file on exit. @param {String} file @api public
removeFile
javascript
node-js-libs/node.io
lib/node.io/utils.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/utils.js
MIT
start = function () { daemon.daemonize(log_file, lock_file, function (err) { if (err) return status('Error starting daemon: ' + err, 'error'); callback(); }); }
A method for creating and controlling a node.io daemon. `arg` can be: start = daemonizes the process stop = stops the daemon if it is running restart = alias for stop -> start pid = outputs the daemon's PID if it is running log = outputs the daemon's log file (stdout & stderr) @param {String...
start
javascript
node-js-libs/node.io
lib/node.io/utils.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/utils.js
MIT
stop = function () { try { fs.readFileSync(lock_file); } catch (e) { return status('Daemon is not running', 'error'); }; daemon.kill(lock_file, function (err, pid) { if (err && err.errno === 3) { return status('Daemon is not running', '...
A method for creating and controlling a node.io daemon. `arg` can be: start = daemonizes the process stop = stops the daemon if it is running restart = alias for stop -> start pid = outputs the daemon's PID if it is running log = outputs the daemon's log file (stdout & stderr) @param {String...
stop
javascript
node-js-libs/node.io
lib/node.io/utils.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/utils.js
MIT
check_complete = function () { if (i === 0) { callback(files); } }
Recursively find all files in a directory (async). `callback` receives an array of files. @param {String} path @param {Function} callback @api public
check_complete
javascript
node-js-libs/node.io
lib/node.io/utils.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/utils.js
MIT
start_job = function (params, res) { if (typeof params.job === 'undefined') { res.writeHead(400); res.end(); return; } if (params.job.indexOf('../') >= 0) { res.writeHead(403); res.end(); return; } var meth...
exports.web Run node.io through a web interface. @param {Array} args @api public
start_job
javascript
node-js-libs/node.io
lib/node.io/interfaces/web.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/interfaces/web.js
MIT
handle = function (req, res) { if (req.url === '/') { res.writeHead(200, {'Content-Type': 'text/html'}); utils.getFiles(module_dir, function(files) { res.write(interface_a); files.sort(); var file_name; files.forEach(functio...
exports.web Run node.io through a web interface. @param {Array} args @api public
handle
javascript
node-js-libs/node.io
lib/node.io/interfaces/web.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/interfaces/web.js
MIT
start_server = function () { http.createServer(handle).listen(port); console.log('\x1B[33mINFO\x1B[0m: Listening on port ' + port + '\n'); }
exports.web Run node.io through a web interface. @param {Array} args @api public
start_server
javascript
node-js-libs/node.io
lib/node.io/interfaces/web.js
https://github.com/node-js-libs/node.io/blob/master/lib/node.io/interfaces/web.js
MIT
createNewContext = defaultContext => { const { parameterize, escape, mapKey, build } = defaultContext return (inherit = {}) => { const { params = [], unparameterized = false } = inherit const whr = [] return { // properties set by the sqorn instance parameterize, escape, mapKey...
Returns a function the creates a new context
createNewContext
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/context.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/context.js
MIT
createNewContext = defaultContext => { const { parameterize, escape, mapKey, build } = defaultContext return (inherit = {}) => { const { params = [], unparameterized = false } = inherit const whr = [] return { // properties set by the sqorn instance parameterize, escape, mapKey...
Returns a function the creates a new context
createNewContext
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/context.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/context.js
MIT
createReducers = methods => { const reducers = {} for (const name in methods) { const { updateContext, properties = {} } = methods[name] reducers[name] = updateContext // some methods have subproperties, e.g. .unionAll for (const key in properties) { reducers[`${name}.${key}`] = properties[key...
Creates an object containing all method reducers
createReducers
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
createReducers = methods => { const reducers = {} for (const name in methods) { const { updateContext, properties = {} } = methods[name] reducers[name] = updateContext // some methods have subproperties, e.g. .unionAll for (const key in properties) { reducers[`${name}.${key}`] = properties[key...
Creates an object containing all method reducers
createReducers
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
applyReducers = reducers => (method, ctx) => { // follow method links to construct methods array (in reverse) const methods = [] for (; method !== undefined; method = method.prev) { methods.push(method) } // build methods object by processing methods in call order const express = { id: 0 } for (let i ...
Follows a method chain, applying each method's reducer, to ctx
applyReducers
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
applyReducers = reducers => (method, ctx) => { // follow method links to construct methods array (in reverse) const methods = [] for (; method !== undefined; method = method.prev) { methods.push(method) } // build methods object by processing methods in call order const express = { id: 0 } for (let i ...
Follows a method chain, applying each method's reducer, to ctx
applyReducers
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
builderProperties = ({ chain, newContext, updateContext, queries }) => ({ _build: { value: function(inheritedContext) { const ctx = updateContext(this.method, newContext(inheritedContext)) return queries[ctx.type](ctx) } }, query: { get: function() { return this._build() } }, ...
Default properties of all SQL Query Builders
builderProperties
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
builderProperties = ({ chain, newContext, updateContext, queries }) => ({ _build: { value: function(inheritedContext) { const ctx = updateContext(this.method, newContext(inheritedContext)) return queries[ctx.type](ctx) } }, query: { get: function() { return this._build() } }, ...
Default properties of all SQL Query Builders
builderProperties
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
adapterProperties = ({ client, config: { thenable = true, mapOutputKeys = camelCase } }) => { const mapKey = memoize(mapOutputKeys) return { end: { value: async function() { return client.end() } }, one: { value: async function(trx) { const rows = await client.query...
Default properties of all SQL Query Builders
adapterProperties
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
adapterProperties = ({ client, config: { thenable = true, mapOutputKeys = camelCase } }) => { const mapKey = memoize(mapOutputKeys) return { end: { value: async function() { return client.end() } }, one: { value: async function(trx) { const rows = await client.query...
Default properties of all SQL Query Builders
adapterProperties
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
mapRowKeys = (rows, fn) => rows.length === 0 ? rows : rows.length === 1 ? mapOneRowKeys(rows, fn) : mapMultipleRowsKeys(rows, fn)
Default properties of all SQL Query Builders
mapRowKeys
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
mapRowKeys = (rows, fn) => rows.length === 0 ? rows : rows.length === 1 ? mapOneRowKeys(rows, fn) : mapMultipleRowsKeys(rows, fn)
Default properties of all SQL Query Builders
mapRowKeys
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
mapOneRowKeys = (rows, fn) => { const [row] = rows const out = {} for (const key in row) { out[fn(key)] = row[key] } return [out] }
Default properties of all SQL Query Builders
mapOneRowKeys
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
mapOneRowKeys = (rows, fn) => { const [row] = rows const out = {} for (const key in row) { out[fn(key)] = row[key] } return [out] }
Default properties of all SQL Query Builders
mapOneRowKeys
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
mapMultipleRowsKeys = (rows, fn) => { const mapping = {} for (const key in rows[0]) { mapping[key] = fn(key) } return rows.map(row => { const mapped = {} for (const key in mapping) { mapped[mapping[key]] = row[key] } return mapped }) }
Default properties of all SQL Query Builders
mapMultipleRowsKeys
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
mapMultipleRowsKeys = (rows, fn) => { const mapping = {} for (const key in rows[0]) { mapping[key] = fn(key) } return rows.map(row => { const mapped = {} for (const key in mapping) { mapped[mapping[key]] = row[key] } return mapped }) }
Default properties of all SQL Query Builders
mapMultipleRowsKeys
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
methodProperties = ({ methods, chain }) => { const properties = {} for (const name in methods) { const { getter } = methods[name] if (getter) { // add getter methods properties[name] = { get: function() { return chain({ name, prev: this.method }) } } } else { ...
Builds object containing a property for every query building method
methodProperties
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
methodProperties = ({ methods, chain }) => { const properties = {} for (const name in methods) { const { getter } = methods[name] if (getter) { // add getter methods properties[name] = { get: function() { return chain({ name, prev: this.method }) } } } else { ...
Builds object containing a property for every query building method
methodProperties
javascript
sqorn/sqorn
packages/sqorn-builder-sq/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-builder-sq/src/index.js
MIT
escape = arg => { if (arg === undefined) throw Error('Error: parameter is undefined') if (arg === null) return 'null' if (typeof arg === 'string') return escapeLiteral(arg) if ( typeof arg === 'number' || typeof arg == 'bigint' || typeof arg == 'boolean' ) return '' + arg if (typeof arg === ...
Escapes an argument for use in UNPARAMETERIZED queries. NOT SAFE AT ALL.
escape
javascript
sqorn/sqorn
packages/sqorn-dialect-postgres/src/parameterize.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-dialect-postgres/src/parameterize.js
MIT
escape = arg => { if (arg === undefined) throw Error('Error: parameter is undefined') if (arg === null) return 'null' if (typeof arg === 'string') return escapeLiteral(arg) if ( typeof arg === 'number' || typeof arg == 'bigint' || typeof arg == 'boolean' ) return '' + arg if (typeof arg === ...
Escapes an argument for use in UNPARAMETERIZED queries. NOT SAFE AT ALL.
escape
javascript
sqorn/sqorn
packages/sqorn-dialect-postgres/src/parameterize.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-dialect-postgres/src/parameterize.js
MIT
escapeLiteral = str => { let hasBackslash = false let escaped = "'" for (let i = 0; i < str.length; i++) { const c = str[i] if (c === "'") { escaped += c + c } else if (c === '\\') { escaped += c + c hasBackslash = true } else { escaped += c } } escaped += "'" if ...
Escapes an argument for use in UNPARAMETERIZED queries. NOT SAFE AT ALL.
escapeLiteral
javascript
sqorn/sqorn
packages/sqorn-dialect-postgres/src/parameterize.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-dialect-postgres/src/parameterize.js
MIT
escapeLiteral = str => { let hasBackslash = false let escaped = "'" for (let i = 0; i < str.length; i++) { const c = str[i] if (c === "'") { escaped += c + c } else if (c === '\\') { escaped += c + c hasBackslash = true } else { escaped += c } } escaped += "'" if ...
Escapes an argument for use in UNPARAMETERIZED queries. NOT SAFE AT ALL.
escapeLiteral
javascript
sqorn/sqorn
packages/sqorn-dialect-postgres/src/parameterize.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-dialect-postgres/src/parameterize.js
MIT
createSqorn = ({ dialect, adapter }) => (config = {}) => { const { query, expression, parameterize, escape } = dialect // 1. Create default context properties passed through build tree const mapKey = memoize(config.mapInputKeys || snakeCase) const defaultContext = { parameterize, escape, mapKey, build } // ...
Creates a version of Sqorn for the given SQL dialect and database adapter. A dialect is variant of the SQL language, while an adapter is the driver that communicates with the database. This design makes it easy to swap drivers, e.g. mysql vs mysql2 or add new databases just by connecting a new adapter to an existing ...
createSqorn
javascript
sqorn/sqorn
packages/sqorn-lib-core/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-lib-core/src/index.js
MIT
createSqorn = ({ dialect, adapter }) => (config = {}) => { const { query, expression, parameterize, escape } = dialect // 1. Create default context properties passed through build tree const mapKey = memoize(config.mapInputKeys || snakeCase) const defaultContext = { parameterize, escape, mapKey, build } // ...
Creates a version of Sqorn for the given SQL dialect and database adapter. A dialect is variant of the SQL language, while an adapter is the driver that communicates with the database. This design makes it easy to swap drivers, e.g. mysql vs mysql2 or add new databases just by connecting a new adapter to an existing ...
createSqorn
javascript
sqorn/sqorn
packages/sqorn-lib-core/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-lib-core/src/index.js
MIT
function build(arg) { if (arg === undefined) throw Error('Error: undefined argument') if (typeof arg === 'function') { if (arg._build) { const { type, text } = arg._build(this) if (type === 'expression') return text if (type === 'fragment') return text return `(${text})` } return...
Creates a version of Sqorn for the given SQL dialect and database adapter. A dialect is variant of the SQL language, while an adapter is the driver that communicates with the database. This design makes it easy to swap drivers, e.g. mysql vs mysql2 or add new databases just by connecting a new adapter to an existing ...
build
javascript
sqorn/sqorn
packages/sqorn-lib-core/src/index.js
https://github.com/sqorn/sqorn/blob/master/packages/sqorn-lib-core/src/index.js
MIT
isPrimitive = function isPrimitive(input) { var type = typeof input; return input === null || (type !== 'object' && type !== 'function'); }
Brings an environment as close to ECMAScript 5 compliance as is possible with the facilities of erstwhile engines. Annotated ES5: http://es5.github.com/ (specific links below) ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf Required reading: http://javascriptweblog.wordpress.com/201...
isPrimitive
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
binder = function () { if (this instanceof bound) { // 15.3.4.5.2 [[Construct]] // When the [[Construct]] internal method of a function object, // F that was created using the bind function is called with a // list of arguments ExtraArgs, the ...
Brings an environment as close to ECMAScript 5 compliance as is possible with the facilities of erstwhile engines. Annotated ES5: http://es5.github.com/ (specific links below) ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf Required reading: http://javascriptweblog.wordpress.com/201...
binder
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
properlyBoxesContext = function properlyBoxed(method) { // Check node 0.6.21 bug where third parameter is not boxed var properlyBoxesNonStrict = true; var properlyBoxesStrict = true; var threwException = false; if (method) { try { method.call('foo', function (_, __, context) { ...
Brings an environment as close to ECMAScript 5 compliance as is possible with the facilities of erstwhile engines. Annotated ES5: http://es5.github.com/ (specific links below) ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf Required reading: http://javascriptweblog.wordpress.com/201...
properlyBoxesContext
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
pushShim = function push(item) { var O = ES.ToObject(this); var n = ES.ToUint32(O.length); var i = 0; while (i < arguments.length) { O[n + i] = arguments[i]; i += 1; } O.length = n + i; return n + i; }
Brings an environment as close to ECMAScript 5 compliance as is possible with the facilities of erstwhile engines. Annotated ES5: http://es5.github.com/ (specific links below) ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf Required reading: http://javascriptweblog.wordpress.com/201...
pushShim
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
equalsConstructorPrototype = function (o) { var ctor = o.constructor; return ctor && ctor.prototype === o; }
/ } return false; }()); var sortThrowsOnRegex = (function () { // this is a problem in Firefox 4, in which `typeof /a/ === 'function'` try { [1, 2].sort(/a/); return false; } catch (e) { /*
equalsConstructorPrototype
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
equalsConstructorPrototypeIfNotBuggy = function (object) { if (typeof window === 'undefined' || !hasAutomationEqualityBug) { return equalsConstructorPrototype(object); } try { return equalsConstructorPrototype(object); } catch (e) { return false; } }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
equalsConstructorPrototypeIfNotBuggy
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
isStandardArguments = function isArguments(value) { return toStr(value) === '[object Arguments]'; }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
isStandardArguments
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
isLegacyArguments = function isArguments(value) { return value !== null && typeof value === 'object' && typeof value.length === 'number' && value.length >= 0 && !isArray(value) && isCallable(value.callee); }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
isLegacyArguments
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
daysInMonth = function daysInMonth(month, year) { return originalGetDate(new Date(year, month, 0)); }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
daysInMonth
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
DateShim = function Date(Y, M, D, h, m, s, ms) { var length = arguments.length; var date; if (this instanceof NativeDate) { var seconds = s; var millis = ms; if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) { ...
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
DateShim
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
dayFromMonth = function dayFromMonth(year, month) { var t = month > 1 ? 1 : 0; return ( months[month] + Math.floor((year - 1969 + t) / 4) - Math.floor((year - 1901 + t) / 100) + Math.floor((year - 1601 + t) / 400) + ...
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
dayFromMonth
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
toUTC = function toUTC(t) { var s = 0; var ms = t; if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) { // work around a Safari 8/9 bug where it treats the seconds as signed var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32...
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
toUTC
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
parseShim = function parse(string) { var match = isoDateExpression.exec(string); if (match) { // parse months, days, hours, minutes, seconds, and milliseconds // provide default values if necessary // parse the UTC offset component ...
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
parseShim
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
toFixedShim = function toFixed(fractionDigits) { var f, x, s, m, e, z, j, k; // Test for NaN and round fractionDigits down f = $Number(fractionDigits); f = isActualNaN(f) ? 0 : Math.floor(f); if (f < 0 || f > 20) { throw new RangeError('Number.toFixed called with invalid number of decimals...
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
toFixedShim
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
wrappedReplaceValue = function (match) { var length = arguments.length; var originalLastIndex = searchValue.lastIndex; searchValue.lastIndex = 0; var args = searchValue.exec(match) || []; searchValue.lastIndex = originalLastIndex; ...
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
wrappedReplaceValue
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
errorToStringShim = function toString() { if (typeof this === 'undefined' || this === null) { throw new TypeError("can't convert " + this + ' to object'); } var name = this.name; if (typeof name === 'undefined') { name = 'Error'; } else if (typeof name !==...
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
errorToStringShim
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
ensureNonEnumerable = function (obj, prop) { if (isEnum(obj, prop)) { var desc = Object.getOwnPropertyDescriptor(obj, prop); desc.enumerable = false; Object.defineProperty(obj, prop, desc); } }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
ensureNonEnumerable
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
regexToString = function toString() { var str = '/' + this.source + '/'; if (this.global) { str += 'g'; } if (this.ignoreCase) { str += 'i'; } if (this.multiline) { str += 'm'; } return str; }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
regexToString
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) { try { object.sentinel = 0; return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0; } catch (exception) { return false; } }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
doesGetOwnPropertyDescriptorWork
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
shouldUseActiveX = function shouldUseActiveX() { // return early if document.domain not set if (!document.domain) { return false; } try { return !!new ActiveXObject('htmlfile'); } catch (exception) { return false; } }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
shouldUseActiveX
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
getEmptyViaActiveX = function getEmptyViaActiveX() { var empty; var xDoc; xDoc = new ActiveXObject('htmlfile'); xDoc.write('<script><\/script>'); xDoc.close(); empty = xDoc.parentWindow.Object.prototype; xDoc = null; return empty; }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
getEmptyViaActiveX
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
getEmptyViaIFrame = function getEmptyViaIFrame() { var iframe = document.createElement('iframe'); var parent = document.body || document.documentElement; var empty; iframe.style.display = 'none'; parent.appendChild(iframe); /* eslint-disable no-script-url */ ifra...
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
getEmptyViaIFrame
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
doesDefinePropertyWork = function doesDefinePropertyWork(object) { try { Object.defineProperty(object, 'sentinel', {}); return 'sentinel' in object; } catch (exception) { return false; } }
/ } return false; }()); defineProperties(ArrayPrototype, { sort: function sort(compareFn) { if (typeof compareFn === 'undefined') { return arraySort(this); } if (!isCallable(compareFn)) { throw new TypeError('Array.prototype.sort callback must be a function'); ...
doesDefinePropertyWork
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.ie8polyfill.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.ie8polyfill.js
MIT
later = function() { timeout = null; if (!immediate) { func.apply(context, args); } }
Debounce function @param {function} func Function to be debounced @param {number} wait Function execution threshold in milliseconds @param {bool} immediate Whether the function should be called at the beginning of the delay instead of the end. Default is false. @desc...
later
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
callback = function() { if (!called) { $($el).trigger(UI.support.transition.end); } $el.transitionEndTimmer = undefined; }
Plugin AMUI Component to jQuery @param {String} name - plugin name @param {Function} Component - plugin constructor @param {Object} [pluginOption] @param {String} pluginOption.dataOptions @param {Function} pluginOption.methodCall - custom method call @param {Function} pluginOption.before @param {Function} pluginOption...
callback
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function fireCallBack(e) { callback.call(this, e); endEvent && dom.off(endEvent, fireCallBack); }
Plugin AMUI Component to jQuery @param {String} name - plugin name @param {Function} Component - plugin constructor @param {Object} [pluginOption] @param {String} pluginOption.dataOptions @param {Function} pluginOption.methodCall - custom method call @param {Function} pluginOption.before @param {Function} pluginOption...
fireCallBack
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function bindLoad() { this.one('load', loaded); if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { var src = this.attr('src'); var param = src.match(/\?/) ? '&' : '?'; param += 'random=' + (new Date()).getTime(); this.attr('src', src + param); } }
Plugin AMUI Component to jQuery @param {String} name - plugin name @param {Function} Component - plugin constructor @param {Object} [pluginOption] @param {String} pluginOption.dataOptions @param {Function} pluginOption.methodCall - custom method call @param {Function} pluginOption.before @param {Function} pluginOption...
bindLoad
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function setTimeoutContext(fn, timeout, context) { return setTimeout(bindFn(fn, context), timeout); }
set a timeout with a given scope @param {Function} fn @param {Number} timeout @param {Object} context @returns {number}
setTimeoutContext
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function invokeArrayArg(arg, fn, context) { if (Array.isArray(arg)) { each(arg, context[fn], context); return true; } return false; }
if the argument is an array, we want to execute the fn on each entry if it aint an array we don't want to do a thing. this is used by all the methods that accept a single and array argument. @param {*|Array} arg @param {String} fn @param {Object} [context] @returns {Boolean}
invokeArrayArg
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function each(obj, iterator, context) { var i; if (!obj) { return; } if (obj.forEach) { obj.forEach(iterator, context); } else if (obj.length !== undefined) { i = 0; while (i < obj.length) { iterator.call(context, obj[i], i, obj); i++; } } else { for (i in...
walk objects and arrays @param {Object} obj @param {Function} iterator @param {Object} context
each
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function deprecate(method, name, message) { var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n'; return function() { var e = new Error('get-stack-trace'); var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '') .replace(/^\s+at\s+/gm, '') .replace(/^...
wrap a method with a deprecation warning and stack trace @param {Function} method @param {String} name @param {String} message @returns {Function} A new function wrapping the supplied method.
deprecate
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function inherit(child, base, properties) { var baseP = base.prototype, childP; childP = child.prototype = Object.create(baseP); childP.constructor = child; childP._super = baseP; if (properties) { assign(childP, properties); } }
simple class inheritance @param {Function} child @param {Function} base @param {Object} [properties]
inherit
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function bindFn(fn, context) { return function boundFn() { return fn.apply(context, arguments); }; }
simple function bind @param {Function} fn @param {Object} context @returns {Function}
bindFn
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function boolOrFn(val, args) { if (typeof val == TYPE_FUNCTION) { return val.apply(args ? args[0] || undefined : undefined, args); } return val; }
let a boolean value also be a function that must return a boolean this first item in args will be used as the context @param {Boolean|Function} val @param {Array} [args] @returns {Boolean}
boolOrFn
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function ifUndefined(val1, val2) { return (val1 === undefined) ? val2 : val1; }
use the val2 when val1 is undefined @param {*} val1 @param {*} val2 @returns {*}
ifUndefined
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function addEventListeners(target, types, handler) { each(splitStr(types), function(type) { target.addEventListener(type, handler, false); }); }
addEventListener with multiple events at once @param {EventTarget} target @param {String} types @param {Function} handler
addEventListeners
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function removeEventListeners(target, types, handler) { each(splitStr(types), function(type) { target.removeEventListener(type, handler, false); }); }
removeEventListener with multiple events at once @param {EventTarget} target @param {String} types @param {Function} handler
removeEventListeners
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function hasParent(node, parent) { while (node) { if (node == parent) { return true; } node = node.parentNode; } return false; }
find if a node is in the given parent @method hasParent @param {HTMLElement} node @param {HTMLElement} parent @return {Boolean} found
hasParent
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function inStr(str, find) { return str.indexOf(find) > -1; }
small indexOf wrapper @param {String} str @param {String} find @returns {Boolean} found
inStr
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function splitStr(str) { return str.trim().split(/\s+/g); }
split string on whitespace @param {String} str @returns {Array} words
splitStr
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function inArray(src, find, findByKey) { if (src.indexOf && !findByKey) { return src.indexOf(find); } else { var i = 0; while (i < src.length) { if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) { return i; } i++; } return -1; ...
find if a array contains the object using indexOf or a simple polyFill @param {Array} src @param {String} find @param {String} [findByKey] @return {Boolean|Number} false when not found, or the index
inArray
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function toArray(obj) { return Array.prototype.slice.call(obj, 0); }
convert array-like objects to real arrays @param {Object} obj @returns {Array}
toArray
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function uniqueArray(src, key, sort) { var results = []; var values = []; var i = 0; while (i < src.length) { var val = key ? src[i][key] : src[i]; if (inArray(values, val) < 0) { results.push(src[i]); } values[i] = val; i++; } if (sort) { if (!key) { resu...
unique array with objects based on a key (like 'id') or just by the array's value @param {Array} src [{id:1},{id:2},{id:1}] @param {String} [key] @param {Boolean} [sort=False] @returns {Array} [{id:1},{id:2}]
uniqueArray
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT
function prefixed(obj, property) { var prefix, prop; var camelProp = property[0].toUpperCase() + property.slice(1); var i = 0; while (i < VENDOR_PREFIXES.length) { prefix = VENDOR_PREFIXES[i]; prop = (prefix) ? prefix + camelProp : property; if (prop in obj) { return prop; } ...
get the prefixed property @param {Object} obj @param {String} property @returns {String|Undefined} prefixed
prefixed
javascript
gongfuxiang/shopxo
public/static/common/lib/assets/js/amazeui.js
https://github.com/gongfuxiang/shopxo/blob/master/public/static/common/lib/assets/js/amazeui.js
MIT