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 |
---|---|---|---|---|---|---|---|
addTrigger = function (triggers, currentTrigger, affectedSpecs) {
if (!triggers[currentTrigger]) {
triggers[currentTrigger] = [];
}
triggers[currentTrigger] = _.uniq(triggers[currentTrigger].concat(affectedSpecs));
return triggers;
}
|
affectedFiles
This program outputs a list of files affected by changes in other files that are in the former ones dependency tree.
The problem that inspired this program is to know what test files can be broken because of modifications on
another files in the code base. This way, we'll know the exact test files that we must run to check that
nothing breaks.
It needs a config file called `tree.config.json` with the next properties:
- testsFolder: the folder to build the dependency tree from. In our case, the specs folder.
ex: "testsFolder": "lib/assets/test/spec/builder/"
- filesRegex: the regular expression for knowing what files must be taken into account for building the dependency tree.
ex: "filesRegex": "spec\\.js$"
Input: the program needs a list of files to check against. See example below for an explanation.
Output: it outputs the list of affected files between the tags <affected></affected>
Example:
Say we have two spec files in folder specs/ with its own dependencies.
spec/
+
|-- foo.spec.js - require('lib/component'), require('lib/calendar'), require('lib/tools/dropdown')
|
|-- baz.spec.js - require('lib/whatever'), require('lib/calendar')
Run 1: What spec files are affected by a change in files 'lib/tools/dropdown.js' and 'lib/common/utils.js'? (It's only required in foo.spec.js dependency tree)
> affectedFiles lib/tools/drowndown.js lib/common/utils.js
output
<affected>
spec/foo.spec.js
</affected>
Run 2: What spec files are affected by a change in file 'lib/calendar.js'? (It's required in both specs)
> affectedFiles lib/tools/calendar.js
output
<affected>
spec/foo.spec.js
spec/baz.spec.js
</affected>
|
addTrigger
|
javascript
|
CartoDB/cartodb
|
lib/build/affectedFiles/affectedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/affectedFiles/affectedFiles.js
|
BSD-3-Clause
|
logTriggers = function (triggers) {
var keys = Object.keys(triggers);
keys.forEach(function (key) {
console.log('');
console.log(colors.yellow(key));
console.log(colors.yellow(new Array(key.length + 1).join('-')));
triggers[key].forEach(function (trigger) {
console.log(trigger);
});
});
}
|
affectedFiles
This program outputs a list of files affected by changes in other files that are in the former ones dependency tree.
The problem that inspired this program is to know what test files can be broken because of modifications on
another files in the code base. This way, we'll know the exact test files that we must run to check that
nothing breaks.
It needs a config file called `tree.config.json` with the next properties:
- testsFolder: the folder to build the dependency tree from. In our case, the specs folder.
ex: "testsFolder": "lib/assets/test/spec/builder/"
- filesRegex: the regular expression for knowing what files must be taken into account for building the dependency tree.
ex: "filesRegex": "spec\\.js$"
Input: the program needs a list of files to check against. See example below for an explanation.
Output: it outputs the list of affected files between the tags <affected></affected>
Example:
Say we have two spec files in folder specs/ with its own dependencies.
spec/
+
|-- foo.spec.js - require('lib/component'), require('lib/calendar'), require('lib/tools/dropdown')
|
|-- baz.spec.js - require('lib/whatever'), require('lib/calendar')
Run 1: What spec files are affected by a change in files 'lib/tools/dropdown.js' and 'lib/common/utils.js'? (It's only required in foo.spec.js dependency tree)
> affectedFiles lib/tools/drowndown.js lib/common/utils.js
output
<affected>
spec/foo.spec.js
</affected>
Run 2: What spec files are affected by a change in file 'lib/calendar.js'? (It's required in both specs)
> affectedFiles lib/tools/calendar.js
output
<affected>
spec/foo.spec.js
spec/baz.spec.js
</affected>
|
logTriggers
|
javascript
|
CartoDB/cartodb
|
lib/build/affectedFiles/affectedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/affectedFiles/affectedFiles.js
|
BSD-3-Clause
|
main = function (testsFolder, modifiedFiles, filesRegex) {
filesRegex = filesRegex || 'spec\\.js$';
var onlyTheseFiles = function (file, stats) {
var theRegex = new RegExp(filesRegex);
return !stats.isDirectory() && !theRegex.test(file);
};
function promiseMap (xs, f) {
const reducer = (ysAcc$, x) =>
ysAcc$.then(ysAcc => f(x).then(y => ysAcc.push(y) && ysAcc));
return xs.reduce(reducer, Promise.resolve([]));
}
function readFiles (folder) {
return recursive(folder, [onlyTheseFiles]);
}
function getAffectedFilesFrom (files) {
if (!files || files.length === 0) {
console.error('Spec files not found.');
process.exit(1);
}
console.log('Found ' + files.length + ' spec files.');
var allFilePromises = files.reduce(function (acc, file) {
acc.push(trie.addFileRequires(file));
return acc;
}, []);
Promise.all(allFilePromises)
.then(function () {
console.log('Dependency tree created.');
console.log(colors.magenta('Took ' + (Date.now() - start)));
console.log('Getting reverse spec dependencies...');
var markStart = Date.now();
files.forEach(function (file) {
trie.markSubTree(file);
});
console.log(colors.magenta('Took ' + (Date.now() - markStart)));
var specsInfo = _.chain(modifiedFiles)
.reduce(function (acc, modifiedFile) {
console.log(colors.magenta(acc.affectedSpecs.length));
var node = trie.getNode(modifiedFile);
if (node && node.marks && node.marks.length > 0) {
acc.affectedSpecs = acc.affectedSpecs.concat(node.marks);
acc.triggers = addTrigger(acc.triggers, modifiedFile, node.marks);
return acc;
}
return acc;
}, {
affectedSpecs: [],
triggers: {}
})
.value();
var targetSpecs = _.uniq(specsInfo.affectedSpecs);
logTriggers(specsInfo.triggers);
console.log('');
console.log('<affected>');
targetSpecs.forEach(function (spec) {
console.log(spec);
});
console.log('</affected>');
})
.catch(function (reason) {
console.error(colors.red(reason));
process.exit(-1);
});
}
promiseMap(testsFolder, readFiles)
.then(function (files) {
const flattenFiles = [].concat.apply([], files);
getAffectedFilesFrom(flattenFiles);
})
.catch(function (error) {
console.error(error);
process.exit(1);
});
}
|
affectedFiles
This program outputs a list of files affected by changes in other files that are in the former ones dependency tree.
The problem that inspired this program is to know what test files can be broken because of modifications on
another files in the code base. This way, we'll know the exact test files that we must run to check that
nothing breaks.
It needs a config file called `tree.config.json` with the next properties:
- testsFolder: the folder to build the dependency tree from. In our case, the specs folder.
ex: "testsFolder": "lib/assets/test/spec/builder/"
- filesRegex: the regular expression for knowing what files must be taken into account for building the dependency tree.
ex: "filesRegex": "spec\\.js$"
Input: the program needs a list of files to check against. See example below for an explanation.
Output: it outputs the list of affected files between the tags <affected></affected>
Example:
Say we have two spec files in folder specs/ with its own dependencies.
spec/
+
|-- foo.spec.js - require('lib/component'), require('lib/calendar'), require('lib/tools/dropdown')
|
|-- baz.spec.js - require('lib/whatever'), require('lib/calendar')
Run 1: What spec files are affected by a change in files 'lib/tools/dropdown.js' and 'lib/common/utils.js'? (It's only required in foo.spec.js dependency tree)
> affectedFiles lib/tools/drowndown.js lib/common/utils.js
output
<affected>
spec/foo.spec.js
</affected>
Run 2: What spec files are affected by a change in file 'lib/calendar.js'? (It's required in both specs)
> affectedFiles lib/tools/calendar.js
output
<affected>
spec/foo.spec.js
spec/baz.spec.js
</affected>
|
main
|
javascript
|
CartoDB/cartodb
|
lib/build/affectedFiles/affectedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/affectedFiles/affectedFiles.js
|
BSD-3-Clause
|
onlyTheseFiles = function (file, stats) {
var theRegex = new RegExp(filesRegex);
return !stats.isDirectory() && !theRegex.test(file);
}
|
affectedFiles
This program outputs a list of files affected by changes in other files that are in the former ones dependency tree.
The problem that inspired this program is to know what test files can be broken because of modifications on
another files in the code base. This way, we'll know the exact test files that we must run to check that
nothing breaks.
It needs a config file called `tree.config.json` with the next properties:
- testsFolder: the folder to build the dependency tree from. In our case, the specs folder.
ex: "testsFolder": "lib/assets/test/spec/builder/"
- filesRegex: the regular expression for knowing what files must be taken into account for building the dependency tree.
ex: "filesRegex": "spec\\.js$"
Input: the program needs a list of files to check against. See example below for an explanation.
Output: it outputs the list of affected files between the tags <affected></affected>
Example:
Say we have two spec files in folder specs/ with its own dependencies.
spec/
+
|-- foo.spec.js - require('lib/component'), require('lib/calendar'), require('lib/tools/dropdown')
|
|-- baz.spec.js - require('lib/whatever'), require('lib/calendar')
Run 1: What spec files are affected by a change in files 'lib/tools/dropdown.js' and 'lib/common/utils.js'? (It's only required in foo.spec.js dependency tree)
> affectedFiles lib/tools/drowndown.js lib/common/utils.js
output
<affected>
spec/foo.spec.js
</affected>
Run 2: What spec files are affected by a change in file 'lib/calendar.js'? (It's required in both specs)
> affectedFiles lib/tools/calendar.js
output
<affected>
spec/foo.spec.js
spec/baz.spec.js
</affected>
|
onlyTheseFiles
|
javascript
|
CartoDB/cartodb
|
lib/build/affectedFiles/affectedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/affectedFiles/affectedFiles.js
|
BSD-3-Clause
|
function promiseMap (xs, f) {
const reducer = (ysAcc$, x) =>
ysAcc$.then(ysAcc => f(x).then(y => ysAcc.push(y) && ysAcc));
return xs.reduce(reducer, Promise.resolve([]));
}
|
affectedFiles
This program outputs a list of files affected by changes in other files that are in the former ones dependency tree.
The problem that inspired this program is to know what test files can be broken because of modifications on
another files in the code base. This way, we'll know the exact test files that we must run to check that
nothing breaks.
It needs a config file called `tree.config.json` with the next properties:
- testsFolder: the folder to build the dependency tree from. In our case, the specs folder.
ex: "testsFolder": "lib/assets/test/spec/builder/"
- filesRegex: the regular expression for knowing what files must be taken into account for building the dependency tree.
ex: "filesRegex": "spec\\.js$"
Input: the program needs a list of files to check against. See example below for an explanation.
Output: it outputs the list of affected files between the tags <affected></affected>
Example:
Say we have two spec files in folder specs/ with its own dependencies.
spec/
+
|-- foo.spec.js - require('lib/component'), require('lib/calendar'), require('lib/tools/dropdown')
|
|-- baz.spec.js - require('lib/whatever'), require('lib/calendar')
Run 1: What spec files are affected by a change in files 'lib/tools/dropdown.js' and 'lib/common/utils.js'? (It's only required in foo.spec.js dependency tree)
> affectedFiles lib/tools/drowndown.js lib/common/utils.js
output
<affected>
spec/foo.spec.js
</affected>
Run 2: What spec files are affected by a change in file 'lib/calendar.js'? (It's required in both specs)
> affectedFiles lib/tools/calendar.js
output
<affected>
spec/foo.spec.js
spec/baz.spec.js
</affected>
|
promiseMap
|
javascript
|
CartoDB/cartodb
|
lib/build/affectedFiles/affectedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/affectedFiles/affectedFiles.js
|
BSD-3-Clause
|
reducer = (ysAcc$, x) =>
ysAcc$.then(ysAcc => f(x).then(y => ysAcc.push(y) && ysAcc))
|
affectedFiles
This program outputs a list of files affected by changes in other files that are in the former ones dependency tree.
The problem that inspired this program is to know what test files can be broken because of modifications on
another files in the code base. This way, we'll know the exact test files that we must run to check that
nothing breaks.
It needs a config file called `tree.config.json` with the next properties:
- testsFolder: the folder to build the dependency tree from. In our case, the specs folder.
ex: "testsFolder": "lib/assets/test/spec/builder/"
- filesRegex: the regular expression for knowing what files must be taken into account for building the dependency tree.
ex: "filesRegex": "spec\\.js$"
Input: the program needs a list of files to check against. See example below for an explanation.
Output: it outputs the list of affected files between the tags <affected></affected>
Example:
Say we have two spec files in folder specs/ with its own dependencies.
spec/
+
|-- foo.spec.js - require('lib/component'), require('lib/calendar'), require('lib/tools/dropdown')
|
|-- baz.spec.js - require('lib/whatever'), require('lib/calendar')
Run 1: What spec files are affected by a change in files 'lib/tools/dropdown.js' and 'lib/common/utils.js'? (It's only required in foo.spec.js dependency tree)
> affectedFiles lib/tools/drowndown.js lib/common/utils.js
output
<affected>
spec/foo.spec.js
</affected>
Run 2: What spec files are affected by a change in file 'lib/calendar.js'? (It's required in both specs)
> affectedFiles lib/tools/calendar.js
output
<affected>
spec/foo.spec.js
spec/baz.spec.js
</affected>
|
reducer
|
javascript
|
CartoDB/cartodb
|
lib/build/affectedFiles/affectedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/affectedFiles/affectedFiles.js
|
BSD-3-Clause
|
reducer = (ysAcc$, x) =>
ysAcc$.then(ysAcc => f(x).then(y => ysAcc.push(y) && ysAcc))
|
affectedFiles
This program outputs a list of files affected by changes in other files that are in the former ones dependency tree.
The problem that inspired this program is to know what test files can be broken because of modifications on
another files in the code base. This way, we'll know the exact test files that we must run to check that
nothing breaks.
It needs a config file called `tree.config.json` with the next properties:
- testsFolder: the folder to build the dependency tree from. In our case, the specs folder.
ex: "testsFolder": "lib/assets/test/spec/builder/"
- filesRegex: the regular expression for knowing what files must be taken into account for building the dependency tree.
ex: "filesRegex": "spec\\.js$"
Input: the program needs a list of files to check against. See example below for an explanation.
Output: it outputs the list of affected files between the tags <affected></affected>
Example:
Say we have two spec files in folder specs/ with its own dependencies.
spec/
+
|-- foo.spec.js - require('lib/component'), require('lib/calendar'), require('lib/tools/dropdown')
|
|-- baz.spec.js - require('lib/whatever'), require('lib/calendar')
Run 1: What spec files are affected by a change in files 'lib/tools/dropdown.js' and 'lib/common/utils.js'? (It's only required in foo.spec.js dependency tree)
> affectedFiles lib/tools/drowndown.js lib/common/utils.js
output
<affected>
spec/foo.spec.js
</affected>
Run 2: What spec files are affected by a change in file 'lib/calendar.js'? (It's required in both specs)
> affectedFiles lib/tools/calendar.js
output
<affected>
spec/foo.spec.js
spec/baz.spec.js
</affected>
|
reducer
|
javascript
|
CartoDB/cartodb
|
lib/build/affectedFiles/affectedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/affectedFiles/affectedFiles.js
|
BSD-3-Clause
|
function readFiles (folder) {
return recursive(folder, [onlyTheseFiles]);
}
|
affectedFiles
This program outputs a list of files affected by changes in other files that are in the former ones dependency tree.
The problem that inspired this program is to know what test files can be broken because of modifications on
another files in the code base. This way, we'll know the exact test files that we must run to check that
nothing breaks.
It needs a config file called `tree.config.json` with the next properties:
- testsFolder: the folder to build the dependency tree from. In our case, the specs folder.
ex: "testsFolder": "lib/assets/test/spec/builder/"
- filesRegex: the regular expression for knowing what files must be taken into account for building the dependency tree.
ex: "filesRegex": "spec\\.js$"
Input: the program needs a list of files to check against. See example below for an explanation.
Output: it outputs the list of affected files between the tags <affected></affected>
Example:
Say we have two spec files in folder specs/ with its own dependencies.
spec/
+
|-- foo.spec.js - require('lib/component'), require('lib/calendar'), require('lib/tools/dropdown')
|
|-- baz.spec.js - require('lib/whatever'), require('lib/calendar')
Run 1: What spec files are affected by a change in files 'lib/tools/dropdown.js' and 'lib/common/utils.js'? (It's only required in foo.spec.js dependency tree)
> affectedFiles lib/tools/drowndown.js lib/common/utils.js
output
<affected>
spec/foo.spec.js
</affected>
Run 2: What spec files are affected by a change in file 'lib/calendar.js'? (It's required in both specs)
> affectedFiles lib/tools/calendar.js
output
<affected>
spec/foo.spec.js
spec/baz.spec.js
</affected>
|
readFiles
|
javascript
|
CartoDB/cartodb
|
lib/build/affectedFiles/affectedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/affectedFiles/affectedFiles.js
|
BSD-3-Clause
|
function getAffectedFilesFrom (files) {
if (!files || files.length === 0) {
console.error('Spec files not found.');
process.exit(1);
}
console.log('Found ' + files.length + ' spec files.');
var allFilePromises = files.reduce(function (acc, file) {
acc.push(trie.addFileRequires(file));
return acc;
}, []);
Promise.all(allFilePromises)
.then(function () {
console.log('Dependency tree created.');
console.log(colors.magenta('Took ' + (Date.now() - start)));
console.log('Getting reverse spec dependencies...');
var markStart = Date.now();
files.forEach(function (file) {
trie.markSubTree(file);
});
console.log(colors.magenta('Took ' + (Date.now() - markStart)));
var specsInfo = _.chain(modifiedFiles)
.reduce(function (acc, modifiedFile) {
console.log(colors.magenta(acc.affectedSpecs.length));
var node = trie.getNode(modifiedFile);
if (node && node.marks && node.marks.length > 0) {
acc.affectedSpecs = acc.affectedSpecs.concat(node.marks);
acc.triggers = addTrigger(acc.triggers, modifiedFile, node.marks);
return acc;
}
return acc;
}, {
affectedSpecs: [],
triggers: {}
})
.value();
var targetSpecs = _.uniq(specsInfo.affectedSpecs);
logTriggers(specsInfo.triggers);
console.log('');
console.log('<affected>');
targetSpecs.forEach(function (spec) {
console.log(spec);
});
console.log('</affected>');
})
.catch(function (reason) {
console.error(colors.red(reason));
process.exit(-1);
});
}
|
affectedFiles
This program outputs a list of files affected by changes in other files that are in the former ones dependency tree.
The problem that inspired this program is to know what test files can be broken because of modifications on
another files in the code base. This way, we'll know the exact test files that we must run to check that
nothing breaks.
It needs a config file called `tree.config.json` with the next properties:
- testsFolder: the folder to build the dependency tree from. In our case, the specs folder.
ex: "testsFolder": "lib/assets/test/spec/builder/"
- filesRegex: the regular expression for knowing what files must be taken into account for building the dependency tree.
ex: "filesRegex": "spec\\.js$"
Input: the program needs a list of files to check against. See example below for an explanation.
Output: it outputs the list of affected files between the tags <affected></affected>
Example:
Say we have two spec files in folder specs/ with its own dependencies.
spec/
+
|-- foo.spec.js - require('lib/component'), require('lib/calendar'), require('lib/tools/dropdown')
|
|-- baz.spec.js - require('lib/whatever'), require('lib/calendar')
Run 1: What spec files are affected by a change in files 'lib/tools/dropdown.js' and 'lib/common/utils.js'? (It's only required in foo.spec.js dependency tree)
> affectedFiles lib/tools/drowndown.js lib/common/utils.js
output
<affected>
spec/foo.spec.js
</affected>
Run 2: What spec files are affected by a change in file 'lib/calendar.js'? (It's required in both specs)
> affectedFiles lib/tools/calendar.js
output
<affected>
spec/foo.spec.js
spec/baz.spec.js
</affected>
|
getAffectedFilesFrom
|
javascript
|
CartoDB/cartodb
|
lib/build/affectedFiles/affectedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/affectedFiles/affectedFiles.js
|
BSD-3-Clause
|
function getCurrentBranchName () {
var promise = new Promise(function (resolve, reject) {
child.exec('git rev-parse --abbrev-ref HEAD', function (error, stdout, stderr) {
if (!error) {
resolve(stdout.replace(/(\r\n|\n|\r)/gm, ''));
}
});
});
return promise;
}
|
getCurrentBranchName
@returns {string} The name of the current git branch
|
getCurrentBranchName
|
javascript
|
CartoDB/cartodb
|
lib/build/branchFiles/modifiedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/branchFiles/modifiedFiles.js
|
BSD-3-Clause
|
function getFilesModifiedInBranch (branchName) {
var promise = new Promise(function (resolve, reject) {
var files;
var command = 'git diff --name-only ' + branchName + ' `git merge-base ' + branchName + ' master`';
child.exec(command, function (error, stdout, stderr) {
if (!error) {
var newLine = /(\r\n|\n|\r)/;
files = stdout.split(newLine).filter(function (file) {
return file.trim().length > 0;
});
files = files.map(function (file) {
return path.resolve('.', file);
});
resolve(files);
}
});
});
return promise;
}
|
getFilesModifiedInBranch
@param {string} branchName The branch name to get the list of modified file list from.
@returns {Promise} result.
@resolves {string[]} The list of modified files in the given branch.
|
getFilesModifiedInBranch
|
javascript
|
CartoDB/cartodb
|
lib/build/branchFiles/modifiedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/branchFiles/modifiedFiles.js
|
BSD-3-Clause
|
notNodeModules = function (file, stats) {
return stats.isDirectory() && file.toLowerCase().indexOf('node_modules') > -1;
}
|
getFilesModifiedInBranch
@param {string} branchName The branch name to get the list of modified file list from.
@returns {Promise} result.
@resolves {string[]} The list of modified files in the given branch.
|
notNodeModules
|
javascript
|
CartoDB/cartodb
|
lib/build/branchFiles/modifiedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/branchFiles/modifiedFiles.js
|
BSD-3-Clause
|
function getFilesInStatus () {
var promise = new Promise(function (resolve, reject) {
child.exec('git status --short', function (error, stdout, stderr) {
if (!error) {
var newLine = /\n/;
var files = stdout.split(newLine);
var promises = files.reduce(function (acc, file) {
if (file.trim().length > 0) {
var name = file.slice(3);
var resolvedPath = path.resolve('.', name);
try {
var stats = fs.statSync(resolvedPath);
if (stats.isFile()) {
acc.push(Promise.resolve(resolvedPath));
return acc;
} else if (stats.isDirectory()) {
acc.push(new Promise(function (resolve, reject) {
recursive(resolvedPath, [notNodeModules], function (err, files) {
if (err) {
reject(err);
}
resolve(files);
});
}));
return acc;
}
} catch (err) {
if (err.code === 'ENOENT') {
acc.push(Promise.resolve(resolvedPath));
return acc;
} else {
throw new Error(err);
}
}
} else {
return acc;
}
}, []);
Promise.all(promises)
.then(function (fileList) {
resolve(_.uniq(_.compact(_.flatten(fileList))));
});
}
});
});
return promise;
}
|
getFilesInStatus
@returns {Promise} result.
@resolves {string[]} The list of working tree files as shown by `git status --short` but without status codes.
|
getFilesInStatus
|
javascript
|
CartoDB/cartodb
|
lib/build/branchFiles/modifiedFiles.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/branchFiles/modifiedFiles.js
|
BSD-3-Clause
|
function duplicatedDependencies (lockFileContent, modulesToValidate) {
var all = alldeps(lockFileContent);
modulesToValidate = modulesToValidate || Object.keys(all);
return modulesToValidate.reduce(function (duplicatedMods, mod) {
if (all[mod] === undefined) {
console.error('!!! ERROR !!!');
console.error('Trying to get all dependencies from ', mod, ' but it does not exist.');
console.error('!!! ERROR !!!');
}
var modVersions = Object.keys(all[mod]);
if (modVersions.length > 1) {
var invalidMod = { name: mod, versions: [] };
modVersions.forEach(function (modVersion) {
invalidMod.versions.push({version: modVersion, from: all[mod][modVersion]});
});
duplicatedMods.push(invalidMod);
}
return duplicatedMods;
}, []);
}
|
Checks all modules dependencies versions within a package-lock to not be
duplicated from different parent dependencies.
For instance if there are a couple of dependencies using a different version
of backbone it will return backbone with its parent dependencies.
|
duplicatedDependencies
|
javascript
|
CartoDB/cartodb
|
lib/build/tasks/locked-dependencies.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/tasks/locked-dependencies.js
|
BSD-3-Clause
|
function dependenciesVersion (lockFileContentOne, lockFileContentTwo, modulesToValidate) {
var allDependenciesOne = alldeps(lockFileContentOne);
var allDependenciesTwo = alldeps(lockFileContentTwo);
return modulesToValidate.reduce(function (depWithDiffVer, mod) {
var verDepFromOne = Object.keys(allDependenciesOne[mod])[0];
var verDepFromTwo = Object.keys(allDependenciesTwo[mod])[0];
if (verDepFromOne !== verDepFromTwo) {
depWithDiffVer.push(mod);
}
return depWithDiffVer;
}, []);
}
|
Checks if the version of a package-lock file matches with the version of another lock file.
It is necessary to pass the modules to validate.
It will return the modules where the version differs.
|
dependenciesVersion
|
javascript
|
CartoDB/cartodb
|
lib/build/tasks/locked-dependencies.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/tasks/locked-dependencies.js
|
BSD-3-Clause
|
function filterSpecs (affectedSpecs, match) {
const re = new RegExp(match);
return affectedSpecs.filter(specFile => {
const fileName = specFile.split(/spec\//)[1];
return re.test(fileName);
});
}
|
/*.spec.js',
dashboard_specs: './lib/assets/test/spec/dashboard/*
|
filterSpecs
|
javascript
|
CartoDB/cartodb
|
lib/build/tasks/webpack/webpack.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/tasks/webpack/webpack.js
|
BSD-3-Clause
|
affected = function (option, grunt) {
var done = this.async();
affectedSpecs = [
'./lib/assets/javascripts/builder/components/form-components/index.js',
'./lib/assets/test/spec/builder/components/modals/add-analysis/analysis-options.spec.js',
'./lib/assets/test/spec/builder/routes/router.spec.js'
];
let allSpecs = glob.sync(paths.builder_specs).concat(glob.sync(paths.deep_insights_specs));
const match = grunt.option('match');
if (match) {
allSpecs = filterSpecs(allSpecs, match);
}
console.log(colors.yellow('All specs. ' + allSpecs.length + ' specs found.'));
affectedSpecs = affectedSpecs.concat(allSpecs);
affectedSpecs = _.uniq(affectedSpecs);
done();
}
|
/*.spec.js'
};
// Filter a list of files with a string
// the string will be converted to a RegExp
function filterSpecs (affectedSpecs, match) {
const re = new RegExp(match);
return affectedSpecs.filter(specFile => {
const fileName = specFile.split(/spec\//)[1];
return re.test(fileName);
});
}
/**
affected - To be used as part of a 'registerTask' Grunt definition
|
affected
|
javascript
|
CartoDB/cartodb
|
lib/build/tasks/webpack/webpack.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/tasks/webpack/webpack.js
|
BSD-3-Clause
|
dashboard = function (option, grunt) {
affectedSpecs = glob.sync(paths.dashboard_specs);
const match = grunt.option('match');
if (match) {
affectedSpecs = filterSpecs(affectedSpecs, match);
}
affectedSpecs = _.uniq(affectedSpecs);
console.log(colors.yellow('All specs. ' + affectedSpecs.length + ' specs found.'));
}
|
dashboard - To be used as part of a 'registerTask' Grunt definition
|
dashboard
|
javascript
|
CartoDB/cartodb
|
lib/build/tasks/webpack/webpack.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/tasks/webpack/webpack.js
|
BSD-3-Clause
|
bootstrap = function (config, grunt) {
if (!config) {
throw new Error('Please provide subconfiguration key for webpack.');
}
const cfg = configGenerator(config);
cfg.entry.main = affectedSpecs;
compiler[config] = webpack(cfg);
cache[config] = {};
compiler[config].apply(new webpack.CachePlugin(cache[config]));
// Flag stats === true -> write stats.json
if (grunt.option('stats')) {
compiler[config].apply(new StatsWriterPlugin({
transform: function (data, opts) {
var stats = opts.compiler.getStats().toJson({chunkModules: true});
return JSON.stringify(stats, null, 2);
}
}));
}
}
|
dashboard - To be used as part of a 'registerTask' Grunt definition
|
bootstrap
|
javascript
|
CartoDB/cartodb
|
lib/build/tasks/webpack/webpack.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/tasks/webpack/webpack.js
|
BSD-3-Clause
|
function logAssets (assets) {
_.each(assets, function (asset) {
var trace = asset.name;
trace += ' ' + pretty(asset.size);
console.log(colors.yellow(trace));
});
}
|
dashboard - To be used as part of a 'registerTask' Grunt definition
|
logAssets
|
javascript
|
CartoDB/cartodb
|
lib/build/tasks/webpack/webpack.js
|
https://github.com/CartoDB/cartodb/blob/master/lib/build/tasks/webpack/webpack.js
|
BSD-3-Clause
|
function Animator(callback, options) {
if(!options.steps) {
throw new Error("steps option missing")
}
this.options = options;
this.running = false;
this._tick = this._tick.bind(this);
this._t0 = +new Date();
this.callback = callback;
this._time = 0.0;
this.itemsReady = false;
this.options = torque.extend({
animationDelay: 0,
maxDelta: 0.2,
loop: options.loop === undefined ? true : options.loop
}, this.options);
this.rescale();
}
|
options:
animationDuration in seconds
animationDelay in seconds
|
Animator
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function extend() {
var objs = arguments;
var a = objs[0];
for (var i = 1; i < objs.length; ++i) {
var b = objs[i];
for (var k in b) {
a[k] = b[k];
}
}
return a;
}
|
options:
animationDuration in seconds
animationDelay in seconds
|
extend
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function clone(a) {
return extend({}, a);
}
|
options:
animationDuration in seconds
animationDelay in seconds
|
clone
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function isFunction(f) {
return typeof f == 'function' || false;
}
|
options:
animationDuration in seconds
animationDelay in seconds
|
isFunction
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function isArray(value) {
return value && typeof value == 'object' && Object.prototype.toString.call(value) == '[object Array]';
}
|
options:
animationDuration in seconds
animationDelay in seconds
|
isArray
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function isBrowserSupported() {
return !!document.createElement('canvas');
}
|
options:
animationDuration in seconds
animationDelay in seconds
|
isBrowserSupported
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function userAgent() {
return typeof navigator !== 'undefined' ? navigator.userAgent : '';
}
|
options:
animationDuration in seconds
animationDelay in seconds
|
userAgent
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function CanvasLayer(opt_options) {
/**
* If true, canvas is in a map pane and the OverlayView is fully functional.
* See google.maps.OverlayView.onAdd for more information.
* @type {boolean}
* @private
*/
this.isAdded_ = false;
/**
* If true, each update will immediately schedule the next.
* @type {boolean}
* @private
*/
this.isAnimated_ = false;
/**
* The name of the MapPane in which this layer will be displayed.
* @type {string}
* @private
*/
this.paneName_ = CanvasLayer.DEFAULT_PANE_NAME_;
/**
* A user-supplied function called whenever an update is required. Null or
* undefined if a callback is not provided.
* @type {?function=}
* @private
*/
this.updateHandler_ = null;
/**
* A user-supplied function called whenever an update is required and the
* map has been resized since the last update. Null or undefined if a
* callback is not provided.
* @type {?function}
* @private
*/
this.resizeHandler_ = null;
/**
* The LatLng coordinate of the top left of the current view of the map. Will
* be null when this.isAdded_ is false.
* @type {google.maps.LatLng}
* @private
*/
this.topLeft_ = null;
/**
* The map-pan event listener. Will be null when this.isAdded_ is false. Will
* be null when this.isAdded_ is false.
* @type {?function}
* @private
*/
this.centerListener_ = null;
/**
* The map-resize event listener. Will be null when this.isAdded_ is false.
* @type {?function}
* @private
*/
this.resizeListener_ = null;
/**
* If true, the map size has changed and this.resizeHandler_ must be called
* on the next update.
* @type {boolean}
* @private
*/
this.needsResize_ = true;
/**
* A browser-defined id for the currently requested callback. Null when no
* callback is queued.
* @type {?number}
* @private
*/
this.requestAnimationFrameId_ = null;
var canvas = document.createElement('canvas');
canvas.style.position = 'absolute';
canvas.style.top = 0;
canvas.style.left = 0;
canvas.style.pointerEvents = 'none';
/**
* The canvas element.
* @type {!HTMLCanvasElement}
*/
this.canvas = canvas;
/**
* Simple bind for functions with no args for bind-less browsers (Safari).
* @param {Object} thisArg The this value used for the target function.
* @param {function} func The function to be bound.
*/
function simpleBindShim(thisArg, func) {
return function() { func.apply(thisArg); };
}
/**
* A reference to this.repositionCanvas_ with this bound as its this value.
* @type {function}
* @private
*/
this.repositionFunction_ = simpleBindShim(this, this.repositionCanvas_);
/**
* A reference to this.resize_ with this bound as its this value.
* @type {function}
* @private
*/
this.resizeFunction_ = simpleBindShim(this, this.resize_);
/**
* A reference to this.update_ with this bound as its this value.
* @type {function}
* @private
*/
this.requestUpdateFunction_ = simpleBindShim(this, this.update_);
// set provided options, if any
if (opt_options) {
this.setOptions(opt_options);
}
}
|
A map layer that provides a canvas over the slippy map and a callback
system for efficient animation. Requires canvas and CSS 2D transform
support.
@constructor
@extends google.maps.OverlayView
@param {CanvasLayerOptions=} opt_options Options to set in this CanvasLayer.
|
CanvasLayer
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function simpleBindShim(thisArg, func) {
return function() { func.apply(thisArg); };
}
|
Simple bind for functions with no args for bind-less browsers (Safari).
@param {Object} thisArg The this value used for the target function.
@param {function} func The function to be bound.
|
simpleBindShim
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function CanvasTileLayer(canvas_setup, render) {
this.tileSize = new google.maps.Size(256, 256);
this.maxZoom = 19;
this.name = "Tile #s";
this.alt = "Canvas tile layer";
this.tiles = {};
this.canvas_setup = canvas_setup;
this.render = render;
if (!render) {
this.render = canvas_setup;
}
}
|
Schedule a requestAnimationFrame callback to updateHandler. If one is
already scheduled, there is no effect.
|
CanvasTileLayer
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function distanceToCenterSq(point) {
var dx = point.x - center.x;
var dy = point.y - center.y;
return dx * dx + dy * dy;
}
|
Schedule a requestAnimationFrame callback to updateHandler. If one is
already scheduled, there is no effect.
|
distanceToCenterSq
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function GMapsTorqueLayer(options) {
var self = this;
if (!torque.isBrowserSupported()) {
throw new Error("browser is not supported by torque");
}
this.key = 0;
this.shader = null;
this.ready = false;
this.options = torque.extend({}, options);
this.options = torque.extend({
provider: 'windshaft',
renderer: 'point',
resolution: 2,
steps: 100,
visible: true
}, this.options);
if (options.cartocss) {
torque.extend(this.options,
torque.common.TorqueLayer.optionsFromCartoCSS(options.cartocss));
}
this.hidden = !this.options.visible;
this.animator = new torque.Animator(function(time) {
var k = time | 0;
if(self.key !== k) {
self.setKey(k);
}
}, torque.clone(this.options));
this.play = this.animator.start.bind(this.animator);
this.stop = this.animator.stop.bind(this.animator);
this.pause = this.animator.pause.bind(this.animator);
this.toggle = this.animator.toggle.bind(this.animator);
this.setDuration = this.animator.duration.bind(this.animator);
this.isRunning = this.animator.isRunning.bind(this.animator);
CanvasLayer.call(this, {
map: this.options.map,
//resizeHandler: this.redraw,
animate: false,
updateHandler: this.render,
readyHandler: this.initialize
});
}
|
Schedule a requestAnimationFrame callback to updateHandler. If one is
already scheduled, there is no effect.
|
GMapsTorqueLayer
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function GMapsTiledTorqueLayer(options) {
this.options = torque.extend({}, options);
CanvasTileLayer.call(this, this._loadTile.bind(this), this.drawTile.bind(this));
this.initialize(options);
}
|
set the cartocss for the current renderer
|
GMapsTiledTorqueLayer
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function clamp(a, b) {
return function(t) {
return Math.max(Math.min(t, b), a);
};
}
|
return the value for position relative to map coordinates. null for no value
|
clamp
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function invLinear(a, b) {
var c = clamp(0, 1.0);
return function(t) {
return c((t - a)/(b - a));
};
}
|
return the value for position relative to map coordinates. null for no value
|
invLinear
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function linear(a, b) {
var c = clamp(a, b);
function _linear(t) {
return c(a*(1.0 - t) + t*b);
}
_linear.invert = function() {
return invLinear(a, b);
};
return _linear;
}
|
return the value for position relative to map coordinates. null for no value
|
linear
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function _linear(t) {
return c(a*(1.0 - t) + t*b);
}
|
return the value for position relative to map coordinates. null for no value
|
_linear
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
Point = function(x, y) {
this.x = x || 0;
this.y = y || 0;
}
|
return the value for position relative to map coordinates. null for no value
|
Point
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function clamp(value, optMin, optMax) {
if (optMin !== null) value = Math.max(value, optMin);
if (optMax !== null) value = Math.min(value, optMax);
return value;
}
|
return the value for position relative to map coordinates. null for no value
|
clamp
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function degreesToRadians(deg) {
return deg * (Math.PI / 180);
}
|
return the value for position relative to map coordinates. null for no value
|
degreesToRadians
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function radiansToDegrees(rad) {
return rad / (Math.PI / 180);
}
|
return the value for position relative to map coordinates. null for no value
|
radiansToDegrees
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
MercatorProjection = function() {
// this._tileSize = L.Browser.retina ? 512 : 256;
this._tileSize = 256;
this._pixelOrigin = new Point(this._tileSize / 2, this._tileSize / 2);
this._pixelsPerLonDegree = this._tileSize / 360;
this._pixelsPerLonRadian = this._tileSize / (2 * Math.PI);
}
|
return the value for position relative to map coordinates. null for no value
|
MercatorProjection
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function Metric(name) {
this.t0 = null;
this.name = name;
this.count = 0;
}
|
return the value for position relative to map coordinates. null for no value
|
Metric
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function format(str) {
for(var i = 1; i < arguments.length; ++i) {
var attrs = arguments[i];
for(var attr in attrs) {
str = str.replace(RegExp('\\{' + attr + '\\}', 'g'), attrs[attr]);
}
}
return str;
}
|
return the value for position relative to map coordinates. null for no value
|
format
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
json = function (options) {
this._ready = false;
this._tileQueue = [];
this.options = options;
this.options.is_time = this.options.is_time === undefined ? true: this.options.is_time;
this.options.tiler_protocol = options.tiler_protocol || 'http';
this.options.tiler_domain = options.tiler_domain || 'carto.com';
this.options.tiler_port = options.tiler_port || 80;
if (this.options.data_aggregation) {
this.options.cumulative = this.options.data_aggregation === 'cumulative';
}
// check options
if (options.resolution === undefined ) throw new Error("resolution should be provided");
if (options.steps === undefined ) throw new Error("steps should be provided");
if(options.start === undefined) {
this._fetchKeySpan();
} else {
this._setReady(true);
}
}
|
return the value for position relative to map coordinates. null for no value
|
json
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function format(str, attrs) {
for(var i = 1; i < arguments.length; ++i) {
var attrs = arguments[i];
for(var attr in attrs) {
str = str.replace(RegExp('\\{' + attr + '\\}', 'g'), attrs[attr]);
}
}
return str;
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
format
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
json = function (options) {
// check options
this.options = options;
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
json
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function getKeys(row) {
var HEADER_SIZE = 3;
var valuesCount = row.data[2];
var keys = {};
for (var s = 0; s < valuesCount; ++s) {
keys[row.data[HEADER_SIZE + s]] = row.data[HEADER_SIZE + valuesCount + s];
}
return keys;
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
getKeys
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function format(str) {
for(var i = 1; i < arguments.length; ++i) {
var attrs = arguments[i];
for(var attr in attrs) {
str = str.replace(RegExp('\\{' + attr + '\\}', 'g'), attrs[attr]);
}
}
return str;
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
format
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
windshaft = function (options) {
this._ready = false;
this._tileQueue = [];
this.options = options;
this.options.is_time = this.options.is_time === undefined ? true: this.options.is_time;
this.options.tiler_protocol = options.tiler_protocol || 'http';
this.options.tiler_domain = options.tiler_domain || 'carto.com';
this.options.tiler_port = options.tiler_port || 80;
// backwards compatible
if (!options.maps_api_template) {
this._buildMapsApiTemplate(this.options);
} else {
this.options.maps_api_template = options.maps_api_template;
}
this.options.coordinates_data_type = this.options.coordinates_data_type || Uint8Array;
if (this.options.data_aggregation) {
this.options.cumulative = this.options.data_aggregation === 'cumulative';
}
if (this.options.auth_token) {
var e = this.options.extra_params || (this.options.extra_params = {});
e.auth_token = this.options.auth_token;
}
if (!this.options.no_fetch_map) {
this._fetchMap();
}
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
windshaft
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function renderPoint(ctx, st) {
ctx.fillStyle = st['marker-fill'];
var pixel_size = st['marker-width'];
// render a circle
// TODO: fill and stroke order should depend on the order of the properties
// in the cartocss.
// fill
ctx.beginPath();
ctx.arc(0, 0, pixel_size, 0, TAU, true, true);
ctx.closePath();
if (st['marker-opacity'] !== undefined ) st['marker-fill-opacity'] = st['marker-line-opacity'] = st['marker-opacity'];
if (st['marker-fill']) {
ctx.globalAlpha = st['marker-fill-opacity'] >= 0? st['marker-fill-opacity']: 1;
if (ctx.globalAlpha > 0) {
ctx.fill();
}
}
// stroke
if (st['marker-line-color'] && st['marker-line-width'] && st['marker-line-width'] > LINEWIDTH_MIN_VALUE) {
ctx.globalAlpha = st['marker-line-opacity'] >= 0? st['marker-line-opacity']: 1;
if (st['marker-line-width'] !== undefined) {
ctx.lineWidth = st['marker-line-width'];
}
ctx.strokeStyle = st['marker-line-color'];
// do not render for alpha = 0
if (ctx.globalAlpha > 0) {
ctx.stroke();
}
}
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
renderPoint
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function renderRectangle(ctx, st) {
ctx.fillStyle = st['marker-fill'];
var pixel_size = st['marker-width'];
var w = pixel_size * 2;
// fill
if (st['marker-fill']) {
if (st['marker-fill-opacity'] !== undefined || st['marker-opacity'] !== undefined) {
ctx.globalAlpha = st['marker-fill-opacity'] || st['marker-opacity'];
}
ctx.fillRect(-pixel_size, -pixel_size, w, w)
}
// stroke
ctx.globalAlpha = 1.0;
if (st['marker-line-color'] && st['marker-line-width']) {
if (st['marker-line-opacity']) {
ctx.globalAlpha = st['marker-line-opacity'];
}
if (st['marker-line-width']) {
ctx.lineWidth = st['marker-line-width'];
}
ctx.strokeStyle = st['marker-line-color'];
// do not render for alpha = 0
if (ctx.globalAlpha > 0) {
ctx.strokeRect(-pixel_size, -pixel_size, w, w)
}
}
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
renderRectangle
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function renderSprite(ctx, img, st) {
if(img.complete){
if (st['marker-fill-opacity'] !== undefined || st['marker-opacity'] !== undefined) {
ctx.globalAlpha = st['marker-fill-opacity'] || st['marker-opacity'];
}
ctx.drawImage(img, 0, 0, Math.min(img.width, MAX_SPRITE_RADIUS), Math.min(img.height, MAX_SPRITE_RADIUS));
}
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
renderSprite
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function compop2canvas(compop) {
return COMP_OP_TO_CANVAS[compop] || compop;
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
compop2canvas
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function PointRenderer(canvas, options) {
if (!canvas) {
throw new Error("canvas can't be undefined");
}
this.options = options;
this._canvas = canvas;
this._ctx = canvas.getContext('2d');
this._sprites = []; // sprites per layer
this._shader = null;
this._icons = {};
this._iconsToLoad = 0;
this._filters = new Filters(this._canvas, {canvasClass: options.canvasClass});
this.setCartoCSS(this.options.cartocss || DEFAULT_CARTOCSS);
this.TILE_SIZE = 256;
this._style = null;
this._gradients = {};
this._forcePoints = false;
}
|
`coord` object like {x : tilex, y: tiley }
`zoom` quadtree zoom level
|
PointRenderer
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function gradientKey(imf){
var hash = ""
for(var i = 0; i < imf.args.length; i++){
var rgb = imf.args[i].rgb;
hash += rgb[0] + ":" + rgb[1] + ":" + rgb[2];
}
return hash;
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
gradientKey
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
componentToHex
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
rgbToHex
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function RectanbleRenderer(canvas, options) {
this.options = options;
carto.tree.Reference.set(torque['torque-reference']);
this.setCanvas(canvas);
this.setCartoCSS(this.options.cartocss || DEFAULT_CARTOCSS);
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
RectanbleRenderer
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function torque_filters(canvas, options) {
// jshint newcap: false, validthis: true
if (!(this instanceof torque_filters)) { return new torque_filters(canvas, options); }
options = options || {};
this._canvas = canvas = typeof canvas === 'string' ? document.getElementById(canvas) : canvas;
this._ctx = canvas.getContext('2d');
this._width = canvas.width;
this._height = canvas.height;
this._max = 1;
this._data = [];
this.canvasClass = options.canvasClass;
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
torque_filters
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function jsonp(url, callback, options) {
options = options || {};
options.timeout = options.timeout === undefined ? 10000: options.timeout;
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
// function name
var fnName = options.callbackName || 'torque_' + Date.now();
if (torque.isFunction(fnName)) {
fnName = fnName();
}
function clean() {
head.removeChild(script);
clearTimeout(timeoutTimer);
delete window[fnName];
}
window[fnName] = function() {
clean();
callback.apply(window, arguments);
};
// timeout for errors
var timeoutTimer = setTimeout(function() {
clean();
callback.call(window, null);
}, options.timeout);
// setup url
url = url.replace('callback=\?', 'callback=' + fnName);
script.type = 'text/javascript';
script.src = url;
script.async = true;
// defer the loading because IE9 loads in the same frame the script
// so Loader._script is null
setTimeout(function() { head.appendChild(script); }, 0);
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
jsonp
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function clean() {
head.removeChild(script);
clearTimeout(timeoutTimer);
delete window[fnName];
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
clean
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function get(url, callback, options) {
options = options || {
method: 'GET',
data: null,
responseType: 'text'
};
lastCall = { url: url, callback: callback };
var request = XMLHttpRequest;
// from d3.js
if (global.XDomainRequest
&& !("withCredentials" in request)
&& /^(http(s)?:)?\/\//.test(url)) request = XDomainRequest;
var req = new request();
req.open(options.method, url, true);
function respond() {
var status = req.status, result;
var r = options.responseType === 'arraybuffer' ? req.response: req.responseText;
if (!status && r || status >= 200 && status < 300 || status === 304) {
callback(req);
} else {
callback(null);
}
}
"onload" in req
? req.onload = req.onerror = respond
: req.onreadystatechange = function() { req.readyState > 3 && respond(); };
req.onprogress = function() {};
req.responseType = options.responseType; //'arraybuffer';
if (options.data) {
req.setRequestHeader("Content-type", "application/json");
//req.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
req.setRequestHeader("Accept", "*");
}
req.send(options.data);
return req;
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
get
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function respond() {
var status = req.status, result;
var r = options.responseType === 'arraybuffer' ? req.response: req.responseText;
if (!status && r || status >= 200 && status < 300 || status === 304) {
callback(req);
} else {
callback(null);
}
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
respond
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function post(url, data, callback) {
return get(url, callback, {
data: data,
method: "POST"
});
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
post
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
GMapsTorqueLayerView = function(layerModel, gmapsMap) {
var extra = layerModel.get('extra_params');
cdb.geo.GMapsLayerView.call(this, layerModel, this, gmapsMap);
var query = this._getQuery(layerModel);
torque.GMapsTorqueLayer.call(this, {
table: layerModel.get('table_name'),
user: layerModel.get('user_name'),
column: layerModel.get('property'),
blendmode: layerModel.get('torque-blend-mode'),
resolution: 1,
//TODO: manage time columns
countby: 'count(cartodb_id)',
sql_api_domain: layerModel.get('sql_api_domain'),
sql_api_protocol: layerModel.get('sql_api_protocol'),
sql_api_port: layerModel.get('sql_api_port'),
tiler_protocol: layerModel.get('tiler_protocol'),
tiler_domain: layerModel.get('tiler_domain'),
tiler_port: layerModel.get('tiler_port'),
maps_api_template: layerModel.get('maps_api_template'),
stat_tag: layerModel.get('stat_tag'),
animationDuration: layerModel.get('torque-duration'),
steps: layerModel.get('torque-steps'),
sql: query,
visible: layerModel.get('visible'),
extra_params: {
api_key: extra ? extra.map_key: ''
},
map: gmapsMap,
cartodb_logo: layerModel.get('cartodb_logo'),
attribution: layerModel.get('attribution'),
cartocss: layerModel.get('cartocss') || layerModel.get('tile_style'),
named_map: layerModel.get('named_map'),
auth_token: layerModel.get('auth_token'),
no_cdn: layerModel.get('no_cdn'),
loop: layerModel.get('loop') === false? false: true,
});
//this.setCartoCSS(this.model.get('tile_style'));
if (layerModel.get('visible')) {
this.play();
}
}
|
get active points for a step in active zoom
returns a list of bounding boxes [[sw, ne] , [], []] where ne is a {lat: .., lon: ...} obj
empty list if there is no active pixels
|
GMapsTorqueLayerView
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.mod.torque.uncompressed.js
|
BSD-3-Clause
|
function parseTemplate(template, tags) {
if (!template)
return [];
var sections = []; // Stack to hold section tokens
var tokens = []; // Buffer to hold the tokens
var spaces = []; // Indices of whitespace tokens on the current line
var hasTag = false; // Is there a {{tag}} on the current line?
var nonSpace = false; // Is there a non-space char on the current line?
// Strips all whitespace tokens array for the current line
// if there was a {{#tag}} on it and otherwise only space.
function stripSpace() {
if (hasTag && !nonSpace) {
while (spaces.length)
delete tokens[spaces.pop()];
} else {
spaces = [];
}
hasTag = false;
nonSpace = false;
}
var openingTagRe, closingTagRe, closingCurlyRe;
function compileTags(tags) {
if (typeof tags === 'string')
tags = tags.split(spaceRe, 2);
if (!isArray(tags) || tags.length !== 2)
throw new Error('Invalid tags: ' + tags);
openingTagRe = new RegExp(escapeRegExp(tags[0]) + '\\s*');
closingTagRe = new RegExp('\\s*' + escapeRegExp(tags[1]));
closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tags[1]));
}
compileTags(tags || mustache.tags);
var scanner = new Scanner(template);
var start, type, value, chr, token, openSection;
while (!scanner.eos()) {
start = scanner.pos;
// Match any text between tags.
value = scanner.scanUntil(openingTagRe);
if (value) {
for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
chr = value.charAt(i);
if (isWhitespace(chr)) {
spaces.push(tokens.length);
} else {
nonSpace = true;
}
tokens.push([ 'text', chr, start, start + 1 ]);
start += 1;
// Check for whitespace on the current line.
if (chr === '\n')
stripSpace();
}
}
// Match the opening tag.
if (!scanner.scan(openingTagRe))
break;
hasTag = true;
// Get the tag type.
type = scanner.scan(tagRe) || 'name';
scanner.scan(whiteRe);
// Get the tag value.
if (type === '=') {
value = scanner.scanUntil(equalsRe);
scanner.scan(equalsRe);
scanner.scanUntil(closingTagRe);
} else if (type === '{') {
value = scanner.scanUntil(closingCurlyRe);
scanner.scan(curlyRe);
scanner.scanUntil(closingTagRe);
type = '&';
} else {
value = scanner.scanUntil(closingTagRe);
}
// Match the closing tag.
if (!scanner.scan(closingTagRe))
throw new Error('Unclosed tag at ' + scanner.pos);
token = [ type, value, start, scanner.pos ];
tokens.push(token);
if (type === '#' || type === '^') {
sections.push(token);
} else if (type === '/') {
// Check section nesting.
openSection = sections.pop();
if (!openSection)
throw new Error('Unopened section "' + value + '" at ' + start);
if (openSection[1] !== value)
throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
} else if (type === 'name' || type === '{' || type === '&') {
nonSpace = true;
} else if (type === '=') {
// Set the tags for the next time around.
compileTags(value);
}
}
// Make sure there are no open sections when we're done.
openSection = sections.pop();
if (openSection)
throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
return nestTokens(squashTokens(tokens));
}
|
Breaks up the given `template` string into a tree of tokens. If the `tags`
argument is given here it must be an array with two string values: the
opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
course, the default is to use mustaches (i.e. mustache.tags).
A token is an array with at least 4 elements. The first element is the
mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
did not contain a symbol (i.e. {{myValue}}) this element is "name". For
all text that appears outside a symbol this element is "text".
The second element of a token is its "value". For mustache tags this is
whatever else was inside the tag besides the opening symbol. For text tokens
this is the text itself.
The third and fourth elements of the token are the start and end indices,
respectively, of the token in the original template.
Tokens that are the root node of a subtree contain two more elements: 1) an
array of tokens in the subtree and 2) the index in the original template at
which the closing tag for that section begins.
|
parseTemplate
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function stripSpace() {
if (hasTag && !nonSpace) {
while (spaces.length)
delete tokens[spaces.pop()];
} else {
spaces = [];
}
hasTag = false;
nonSpace = false;
}
|
Breaks up the given `template` string into a tree of tokens. If the `tags`
argument is given here it must be an array with two string values: the
opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
course, the default is to use mustaches (i.e. mustache.tags).
A token is an array with at least 4 elements. The first element is the
mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
did not contain a symbol (i.e. {{myValue}}) this element is "name". For
all text that appears outside a symbol this element is "text".
The second element of a token is its "value". For mustache tags this is
whatever else was inside the tag besides the opening symbol. For text tokens
this is the text itself.
The third and fourth elements of the token are the start and end indices,
respectively, of the token in the original template.
Tokens that are the root node of a subtree contain two more elements: 1) an
array of tokens in the subtree and 2) the index in the original template at
which the closing tag for that section begins.
|
stripSpace
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function compileTags(tags) {
if (typeof tags === 'string')
tags = tags.split(spaceRe, 2);
if (!isArray(tags) || tags.length !== 2)
throw new Error('Invalid tags: ' + tags);
openingTagRe = new RegExp(escapeRegExp(tags[0]) + '\\s*');
closingTagRe = new RegExp('\\s*' + escapeRegExp(tags[1]));
closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tags[1]));
}
|
Breaks up the given `template` string into a tree of tokens. If the `tags`
argument is given here it must be an array with two string values: the
opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
course, the default is to use mustaches (i.e. mustache.tags).
A token is an array with at least 4 elements. The first element is the
mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
did not contain a symbol (i.e. {{myValue}}) this element is "name". For
all text that appears outside a symbol this element is "text".
The second element of a token is its "value". For mustache tags this is
whatever else was inside the tag besides the opening symbol. For text tokens
this is the text itself.
The third and fourth elements of the token are the start and end indices,
respectively, of the token in the original template.
Tokens that are the root node of a subtree contain two more elements: 1) an
array of tokens in the subtree and 2) the index in the original template at
which the closing tag for that section begins.
|
compileTags
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function squashTokens(tokens) {
var squashedTokens = [];
var token, lastToken;
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
token = tokens[i];
if (token) {
if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
lastToken[1] += token[1];
lastToken[3] = token[3];
} else {
squashedTokens.push(token);
lastToken = token;
}
}
}
return squashedTokens;
}
|
Combines the values of consecutive text tokens in the given `tokens` array
to a single token.
|
squashTokens
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function nestTokens(tokens) {
var nestedTokens = [];
var collector = nestedTokens;
var sections = [];
var token, section;
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
token = tokens[i];
switch (token[0]) {
case '#':
case '^':
collector.push(token);
sections.push(token);
collector = token[4] = [];
break;
case '/':
section = sections.pop();
section[5] = token[2];
collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
break;
default:
collector.push(token);
}
}
return nestedTokens;
}
|
Forms the given array of `tokens` into a nested tree structure where
tokens that represent a section have two additional items: 1) an array of
all tokens that appear in that section and 2) the index in the original
template that represents the end of that section.
|
nestTokens
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function Scanner(string) {
this.string = string;
this.tail = string;
this.pos = 0;
}
|
A simple string scanner that is used by the template parser to find
tokens in template strings.
|
Scanner
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function Context(view, parentContext) {
this.view = view == null ? {} : view;
this.cache = { '.': this.view };
this.parent = parentContext;
}
|
Represents a rendering context by wrapping a view object and
maintaining a reference to the parent context.
|
Context
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function Writer() {
this.cache = {};
}
|
A Writer knows how to take a stream of tokens and render them to a
string, given a context. It also maintains a cache of templates to
avoid the need to parse the same template twice.
|
Writer
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function getPrefixed(name) {
var i, fn,
prefixes = ['webkit', 'moz', 'o', 'ms'];
for (i = 0; i < prefixes.length && !fn; i++) {
fn = window[prefixes[i] + name];
}
return fn;
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
getPrefixed
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function timeoutDefer(fn) {
var time = +new Date(),
timeToCall = Math.max(0, 16 - (time - lastTime));
lastTime = time + timeToCall;
return window.setTimeout(fn, timeToCall);
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
timeoutDefer
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
NewClass = function () {
// call the constructor
if (this.initialize) {
this.initialize.apply(this, arguments);
}
// call all constructor hooks
if (this._initHooks) {
this.callInitHooks();
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
NewClass
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function createMulti(Klass) {
return L.FeatureGroup.extend({
initialize: function (latlngs, options) {
this._layers = {};
this._options = options;
this.setLatLngs(latlngs);
},
setLatLngs: function (latlngs) {
var i = 0,
len = latlngs.length;
this.eachLayer(function (layer) {
if (i < len) {
layer.setLatLngs(latlngs[i++]);
} else {
this.removeLayer(layer);
}
}, this);
while (i < len) {
this.addLayer(new Klass(latlngs[i++], this._options));
}
return this;
},
getLatLngs: function () {
var latlngs = [];
this.eachLayer(function (layer) {
latlngs.push(layer.getLatLngs());
});
return latlngs;
}
});
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
createMulti
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function multiToGeoJSON(type) {
return function () {
var coords = [];
this.eachLayer(function (layer) {
coords.push(layer.toGeoJSON().geometry.coordinates);
});
return L.GeoJSON.getFeature(this, {
type: type,
coordinates: coords
});
};
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
multiToGeoJSON
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function onTouchStart(e) {
var count;
if (L.Browser.pointer) {
trackedTouches.push(e.pointerId);
count = trackedTouches.length;
} else {
count = e.touches.length;
}
if (count > 1) {
return;
}
var now = Date.now(),
delta = now - (last || now);
touch = e.touches ? e.touches[0] : e;
doubleTap = (delta > 0 && delta <= delay);
last = now;
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
onTouchStart
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function onTouchEnd(e) {
if (L.Browser.pointer) {
var idx = trackedTouches.indexOf(e.pointerId);
if (idx === -1) {
return;
}
trackedTouches.splice(idx, 1);
}
if (doubleTap) {
if (L.Browser.pointer) {
// work around .type being readonly with MSPointer* events
var newTouch = { },
prop;
// jshint forin:false
for (var i in touch) {
prop = touch[i];
if (typeof prop === 'function') {
newTouch[i] = prop.bind(touch);
} else {
newTouch[i] = prop;
}
}
touch = newTouch;
}
touch.type = 'dblclick';
handler(touch);
last = null;
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
onTouchEnd
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
cb = function (e) {
L.DomEvent.preventDefault(e);
var alreadyInArray = false;
for (var i = 0; i < pointers.length; i++) {
if (pointers[i].pointerId === e.pointerId) {
alreadyInArray = true;
break;
}
}
if (!alreadyInArray) {
pointers.push(e);
}
e.touches = pointers.slice();
e.changedTouches = [e];
handler(e);
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
cb
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
internalCb = function (e) {
for (var i = 0; i < pointers.length; i++) {
if (pointers[i].pointerId === e.pointerId) {
pointers.splice(i, 1);
break;
}
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
internalCb
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function cb(e) {
// don't fire touch moves when mouse isn't down
if ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { return; }
for (var i = 0; i < touches.length; i++) {
if (touches[i].pointerId === e.pointerId) {
touches[i] = e;
break;
}
}
e.touches = touches.slice();
e.changedTouches = [e];
handler(e);
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
cb
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
cb = function (e) {
for (var i = 0; i < touches.length; i++) {
if (touches[i].pointerId === e.pointerId) {
touches.splice(i, 1);
break;
}
}
e.touches = touches.slice();
e.changedTouches = [e];
handler(e);
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
cb
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function createCorner(vSide, hSide) {
var className = l + vSide + ' ' + l + hSide;
corners[vSide + hSide] = L.DomUtil.create('div', className, container);
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
createCorner
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function isDescendant(parent, node) {
while ((node = node.parentNode) !== null) {
if (node === parent) return true
}
return false
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
isDescendant
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function check(event) {
var related = event.relatedTarget
if (!related) return related === null
return (related !== this && related.prefix !== 'xul' && !/document/.test(this.toString()) && !isDescendant(this, related))
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
check
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
createPreventDefault = function (event) {
return function () {
if (event[preventDefault])
event[preventDefault]()
else
event.returnValue = false
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
createPreventDefault
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
createStopPropagation = function (event) {
return function () {
if (event[stopPropagation])
event[stopPropagation]()
else
event.cancelBubble = true
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
createStopPropagation
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
createStop = function (synEvent) {
return function () {
synEvent[preventDefault]()
synEvent[stopPropagation]()
synEvent.stopped = true
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
createStop
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
copyProps = function (event, result, props) {
var i, p
for (i = props.length; i--;) {
p = props[i]
if (!(p in result) && p in event) result[p] = event[p]
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
copyProps
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
targetElement = function (element, isNative) {
return !W3C_MODEL && !isNative && (element === doc || element === win) ? root : element
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
targetElement
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
function entry(element, type, handler, original, namespaces) {
this.element = element
this.type = type
this.handler = handler
this.original = original
this.namespaces = namespaces
this.custom = customEvents[type]
this.isNative = nativeEvents[type] && element[eventSupport]
this.eventType = W3C_MODEL || this.isNative ? type : 'propertychange'
this.customType = !W3C_MODEL && !this.isNative && type
this.target = targetElement(element, this.isNative)
this.eventSupport = this.target[eventSupport]
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
entry
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
forAll = function (element, type, original, handler, fn) {
if (!type || type === '*') {
// search the whole registry
for (var t in map) {
if (t.charAt(0) === '$')
forAll(element, t.substr(1), original, handler, fn)
}
} else {
var i = 0, l, list = map['$' + type], all = element === '*'
if (!list)
return
for (l = list.length; i < l; i++) {
if (all || list[i].matches(element, original, handler))
if (!fn(list[i], list, i, type))
return
}
}
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
forAll
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
has = function (element, type, original) {
// we're not using forAll here simply because it's a bit slower and this
// needs to be fast
var i, list = map['$' + type]
if (list) {
for (i = list.length; i--;) {
if (list[i].matches(element, original, null))
return true
}
}
return false
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
has
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
get = function (element, type, original) {
var entries = []
forAll(element, type, original, null, function (entry) { return entries.push(entry) })
return entries
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
get
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
put = function (entry) {
(map['$' + entry.type] || (map['$' + entry.type] = [])).push(entry)
return entry
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
put
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
del = function (entry) {
forAll(entry.element, entry.type, null, entry.handler, function (entry, list, i) {
list.splice(i, 1)
if (list.length === 0)
delete map['$' + entry.type]
return false
})
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
del
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
entries = function () {
var t, entries = []
for (t in map) {
if (t.charAt(0) === '$')
entries = entries.concat(map[t])
}
return entries
}
|
Renders the `template` with the given `view` and `partials` using the
default writer.
|
entries
|
javascript
|
CartoDB/cartodb
|
vendor/assets/javascripts/cartodb.uncompressed.js
|
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
|
BSD-3-Clause
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.