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
setRepoUnavailable = async function(packageName, value) { await setValue(packageName, propKeys.repoUnavailable, value ? "1" : "0"); }
Get the cached image filename @param {string} packageName
setRepoUnavailable
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
getRepoUnavailable = async function(packageName) { const text = await getValue(packageName, propKeys.repoUnavailable); return text == "1" ? true : false; }
Get the cached image filename @param {string} packageName
getRepoUnavailable
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
getRepoUnavailable = async function(packageName) { const text = await getValue(packageName, propKeys.repoUnavailable); return text == "1" ? true : false; }
Get the cached image filename @param {string} packageName
getRepoUnavailable
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setUpdatedTime = async function(packageName, updatedTime) { await setValue(packageName, propKeys.updatedTime, updatedTime); }
Get the cached image filename @param {string} packageName
setUpdatedTime
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setUpdatedTime = async function(packageName, updatedTime) { await setValue(packageName, propKeys.updatedTime, updatedTime); }
Get the cached image filename @param {string} packageName
setUpdatedTime
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
getUpdatedTime = async function(packageName) { const value = await getValue(packageName, propKeys.updatedTime); return parseInt(value) || 0; }
Get the cached image filename @param {string} packageName
getUpdatedTime
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
getUpdatedTime = async function(packageName) { const value = await getValue(packageName, propKeys.updatedTime); return parseInt(value) || 0; }
Get the cached image filename @param {string} packageName
getUpdatedTime
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
getMonthlyDownloads = async function(packageName) { const value = await getValue(packageName, propKeys.monthlyDownloads); return parseInt(value) || 0; }
Get monthly downloads for a package. @param {string} packageName - The name of the package. @returns {Promise<number>} - A Promise that resolves to the number of downloads.
getMonthlyDownloads
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
getMonthlyDownloads = async function(packageName) { const value = await getValue(packageName, propKeys.monthlyDownloads); return parseInt(value) || 0; }
Get monthly downloads for a package. @param {string} packageName - The name of the package. @returns {Promise<number>} - A Promise that resolves to the number of downloads.
getMonthlyDownloads
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setMonthlyDownloads = async function(packageName, downloads) { await setValue(packageName, propKeys.monthlyDownloads, downloads); }
Set monthly downloads for a package. @param {string} packageName - The name of the package. @param {number} downloads - The number of downloads to set. @returns {Promise<void>} - A Promise that resolves when the downloads have been set.
setMonthlyDownloads
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setMonthlyDownloads = async function(packageName, downloads) { await setValue(packageName, propKeys.monthlyDownloads, downloads); }
Set monthly downloads for a package. @param {string} packageName - The name of the package. @param {number} downloads - The number of downloads to set. @returns {Promise<void>} - A Promise that resolves when the downloads have been set.
setMonthlyDownloads
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setValue = async function(packageName, propKey, propVal) { const key = packageKey + packageName; await redis.client.hset(key, propKey, propVal); }
Set monthly downloads for a package. @param {string} packageName - The name of the package. @param {number} downloads - The number of downloads to set. @returns {Promise<void>} - A Promise that resolves when the downloads have been set.
setValue
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setValue = async function(packageName, propKey, propVal) { const key = packageKey + packageName; await redis.client.hset(key, propKey, propVal); }
Set monthly downloads for a package. @param {string} packageName - The name of the package. @param {number} downloads - The number of downloads to set. @returns {Promise<void>} - A Promise that resolves when the downloads have been set.
setValue
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
getValue = async function(packageName, propKey) { const key = packageKey + packageName; return await redis.client.hget(key, propKey); }
Set monthly downloads for a package. @param {string} packageName - The name of the package. @param {number} downloads - The number of downloads to set. @returns {Promise<void>} - A Promise that resolves when the downloads have been set.
getValue
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
getValue = async function(packageName, propKey) { const key = packageKey + packageName; return await redis.client.hget(key, propKey); }
Set monthly downloads for a package. @param {string} packageName - The name of the package. @param {number} downloads - The number of downloads to set. @returns {Promise<void>} - A Promise that resolves when the downloads have been set.
getValue
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setAggregatedExtraData = async function(obj) { const jsonText = JSON.stringify(obj, null, 0); await redis.client.set(allPackagesExtraKey, jsonText); }
Set aggregated extra data. @param {object} obj
setAggregatedExtraData
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setAggregatedExtraData = async function(obj) { const jsonText = JSON.stringify(obj, null, 0); await redis.client.set(allPackagesExtraKey, jsonText); }
Set aggregated extra data. @param {object} obj
setAggregatedExtraData
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setRecentPackages = async function(arr) { const jsonText = JSON.stringify(arr, null, 0); await redis.client.set(recentPackagesKey, jsonText); }
Set recent packages. @param {object} obj
setRecentPackages
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setRecentPackages = async function(arr) { const jsonText = JSON.stringify(arr, null, 0); await redis.client.set(recentPackagesKey, jsonText); }
Set recent packages. @param {object} obj
setRecentPackages
javascript
openupm/openupm
app/models/packageExtra.js
https://github.com/openupm/openupm/blob/master/app/models/packageExtra.js
BSD-3-Clause
setFeedRecentUpdate = async function(objs) { // Sort by time. objs = orderBy(objs, ["time"], ["desc"]); // Generate the feed. const feed = new Feed({ title: "OpenUPM Recent Updates", description: "Feed of OpenUPM Recently Updated Packages", id: "https://openupm.com/", link: "https://openupm.com/...
Set aggregated extra data. @param {Array} objs [{ packageName: str, displayName: str, time: int, version: str, author: [ { name: str, link: str }, ...] }, ...]
setFeedRecentUpdate
javascript
openupm/openupm
app/models/packageFeed.js
https://github.com/openupm/openupm/blob/master/app/models/packageFeed.js
BSD-3-Clause
setFeedRecentUpdate = async function(objs) { // Sort by time. objs = orderBy(objs, ["time"], ["desc"]); // Generate the feed. const feed = new Feed({ title: "OpenUPM Recent Updates", description: "Feed of OpenUPM Recently Updated Packages", id: "https://openupm.com/", link: "https://openupm.com/...
Set aggregated extra data. @param {Array} objs [{ packageName: str, displayName: str, time: int, version: str, author: [ { name: str, link: str }, ...] }, ...]
setFeedRecentUpdate
javascript
openupm/openupm
app/models/packageFeed.js
https://github.com/openupm/openupm/blob/master/app/models/packageFeed.js
BSD-3-Clause
function getGithubToken() { if (config.github.tokens && config.github.tokens.length > 0) // Return random token from the list. return config.github.tokens[ Math.floor(Math.random() * config.github.tokens.length) ]; // Fall back to the single token. if (config.github.token) return config.github.t...
Return GitHub token from the configuration. @returns The GitHub token.
getGithubToken
javascript
openupm/openupm
app/utils/github.js
https://github.com/openupm/openupm/blob/master/app/utils/github.js
BSD-3-Clause
healthCheck = async function(checkId) { if (process.env.NODE_ENV !== "production") return; try { let resp = null; const source = CancelToken.source(); setTimeout(() => { if (resp === null) source.cancel("ECONNTIMEOUT"); }, 10000); resp = await AxiosService.create().get( urljoin("http...
Ping healthchecks.io @param {string} checkId
healthCheck
javascript
openupm/openupm
app/utils/healthCheck.js
https://github.com/openupm/openupm/blob/master/app/utils/healthCheck.js
BSD-3-Clause
healthCheck = async function(checkId) { if (process.env.NODE_ENV !== "production") return; try { let resp = null; const source = CancelToken.source(); setTimeout(() => { if (resp === null) source.cancel("ECONNTIMEOUT"); }, 10000); resp = await AxiosService.create().get( urljoin("http...
Ping healthchecks.io @param {string} checkId
healthCheck
javascript
openupm/openupm
app/utils/healthCheck.js
https://github.com/openupm/openupm/blob/master/app/utils/healthCheck.js
BSD-3-Clause
httpErrorInfo = function(err, others) { // Show http status if possible or fallback to error if (err.response && err.response.status) return { status: err.response.status, ...others }; else return { err, ...others }; }
Return HTTP error info object @param {Object} error @param {Object} others
httpErrorInfo
javascript
openupm/openupm
app/utils/http.js
https://github.com/openupm/openupm/blob/master/app/utils/http.js
BSD-3-Clause
httpErrorInfo = function(err, others) { // Show http status if possible or fallback to error if (err.response && err.response.status) return { status: err.response.status, ...others }; else return { err, ...others }; }
Return HTTP error info object @param {Object} error @param {Object} others
httpErrorInfo
javascript
openupm/openupm
app/utils/http.js
https://github.com/openupm/openupm/blob/master/app/utils/http.js
BSD-3-Clause
isErrorCode = function(error, code) { return error.response && error.response.status == code; }
Return if error has given status code. @param {Object} error @param {Number} code
isErrorCode
javascript
openupm/openupm
app/utils/http.js
https://github.com/openupm/openupm/blob/master/app/utils/http.js
BSD-3-Clause
isErrorCode = function(error, code) { return error.response && error.response.status == code; }
Return if error has given status code. @param {Object} error @param {Number} code
isErrorCode
javascript
openupm/openupm
app/utils/http.js
https://github.com/openupm/openupm/blob/master/app/utils/http.js
BSD-3-Clause
addImage = async function({ imageUrl, width, height, fit, duration, filename, force }) { const key = getMediaKey({ imageUrl, width, height, fit }); const expire = new Date().getTime() + duration; const oldImageEntry = await getImage({ imageUrl, width, height, fit }); // download image to a tmp fi...
Download, process a image and upload to S3. @param {object} param0
addImage
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
addImage = async function({ imageUrl, width, height, fit, duration, filename, force }) { const key = getMediaKey({ imageUrl, width, height, fit }); const expire = new Date().getTime() + duration; const oldImageEntry = await getImage({ imageUrl, width, height, fit }); // download image to a tmp fi...
Download, process a image and upload to S3. @param {object} param0
addImage
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
_downloadImageUrl = async function(imageUrl, destPath) { let resp = null; const source = CancelToken.source(); setTimeout(() => { if (resp === null) source.cancel("ECONNTIMEOUT"); }, 10000); const headers = {}; resp = await AxiosService.create().get(imageUrl, { headers, cancelToken: source.token...
Download the image url to the dest path @param {string} imageUrl @param {string} destPath
_downloadImageUrl
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
_downloadImageUrl = async function(imageUrl, destPath) { let resp = null; const source = CancelToken.source(); setTimeout(() => { if (resp === null) source.cancel("ECONNTIMEOUT"); }, 10000); const headers = {}; resp = await AxiosService.create().get(imageUrl, { headers, cancelToken: source.token...
Download the image url to the dest path @param {string} imageUrl @param {string} destPath
_downloadImageUrl
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
_processImage = async function({ sourcePath, destLocalPath, destS3Path, width, height, fit }) { const image = sharp(sourcePath); await image .resize(width, height, { fit, background: { r: 255, g: 255, b: 255, alpha: 0 } }) .png() .toFile(destLocalPath); // copy to s3 awai...
Process the image and upload to s3 @param {object} param0
_processImage
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
_processImage = async function({ sourcePath, destLocalPath, destS3Path, width, height, fit }) { const image = sharp(sourcePath); await image .resize(width, height, { fit, background: { r: 255, g: 255, b: 255, alpha: 0 } }) .png() .toFile(destLocalPath); // copy to s3 awai...
Process the image and upload to s3 @param {object} param0
_processImage
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
getMediaS3Path = function(filename) { return `media/${filename}`; }
Get media S3 path @param {string} filename
getMediaS3Path
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
getMediaS3Path = function(filename) { return `media/${filename}`; }
Get media S3 path @param {string} filename
getMediaS3Path
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
getMediaTempFilename = function({ imageUrl, width, height, fit }) { const md5 = crypto .createHash("md5") .update(imageUrl) .digest("hex"); const now = new Date().getTime(); return `${md5}-${width}x${height}-${fit}-${now}.tmp`; }
Get media tmp filename @param {object} param0
getMediaTempFilename
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
getMediaTempFilename = function({ imageUrl, width, height, fit }) { const md5 = crypto .createHash("md5") .update(imageUrl) .digest("hex"); const now = new Date().getTime(); return `${md5}-${width}x${height}-${fit}-${now}.tmp`; }
Get media tmp filename @param {object} param0
getMediaTempFilename
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
getImage = async function({ imageUrl, width, height, fit }) { const key = getMediaKey({ imageUrl, width, height, fit }); const obj = await redis.client.hgetall(key); if (isEmpty(obj)) return null; obj.size = parseInt(obj.size) || 0; if (!obj.filename) obj.filename = getMediaFilename({ imageUrl, ...
Get the image entry { available, filename, filePath, s3Path, expire, size } @param {object} param0
getImage
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
getImage = async function({ imageUrl, width, height, fit }) { const key = getMediaKey({ imageUrl, width, height, fit }); const obj = await redis.client.hgetall(key); if (isEmpty(obj)) return null; obj.size = parseInt(obj.size) || 0; if (!obj.filename) obj.filename = getMediaFilename({ imageUrl, ...
Get the image entry { available, filename, filePath, s3Path, expire, size } @param {object} param0
getImage
javascript
openupm/openupm
app/utils/media.js
https://github.com/openupm/openupm/blob/master/app/utils/media.js
BSD-3-Clause
readJsFile = function(file, onComplete, ...callbackArgs) { fs.readFile(path.relative(process.cwd(), file), 'utf8', function(err, code) { if (err) { return console.error(err); } onComplete(file, code, ...callbackArgs); }); }
@todo Add features from the Non-CLI side of this module such as: 2. Custom abstraction level 3. Presentation mode 4. Defined colour schemes (default, B&W, blurred, light) 5. Custom colour scheme 6. Custom style 7. Flow tree modifications (iterative methods treated as loops, ...) 8. Custom modifier 9. Debugging @todo Co...
readJsFile
javascript
Bogdan-Lyashenko/js-code-to-svg-flowchart
cli/index.cli.js
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart/blob/master/cli/index.cli.js
MIT
readJsFile = function(file, onComplete, ...callbackArgs) { fs.readFile(path.relative(process.cwd(), file), 'utf8', function(err, code) { if (err) { return console.error(err); } onComplete(file, code, ...callbackArgs); }); }
@todo Add features from the Non-CLI side of this module such as: 2. Custom abstraction level 3. Presentation mode 4. Defined colour schemes (default, B&W, blurred, light) 5. Custom colour scheme 6. Custom style 7. Flow tree modifications (iterative methods treated as loops, ...) 8. Custom modifier 9. Debugging @todo Co...
readJsFile
javascript
Bogdan-Lyashenko/js-code-to-svg-flowchart
cli/index.cli.js
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart/blob/master/cli/index.cli.js
MIT
writeToFile = function(filePath, data) { fs.writeFile(filePath, data, function(err) { if (err) { return console.error(err); } console.log(`SVG file was created: ${filePath}`); }); }
@description Write data to the specified file path. @param {string} filePath Path of the destination file @param {*} data Data to write to the destination
writeToFile
javascript
Bogdan-Lyashenko/js-code-to-svg-flowchart
cli/index.cli.js
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart/blob/master/cli/index.cli.js
MIT
writeToFile = function(filePath, data) { fs.writeFile(filePath, data, function(err) { if (err) { return console.error(err); } console.log(`SVG file was created: ${filePath}`); }); }
@description Write data to the specified file path. @param {string} filePath Path of the destination file @param {*} data Data to write to the destination
writeToFile
javascript
Bogdan-Lyashenko/js-code-to-svg-flowchart
cli/index.cli.js
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart/blob/master/cli/index.cli.js
MIT
createSvgFile = function(file, code) { const svg = js2flowchart.convertCodeToSvg(code), filePath = `${file}.svg`; writeToFile(filePath, svg); }
@description Write data to the specified file path. @param {string} filePath Path of the destination file @param {*} data Data to write to the destination
createSvgFile
javascript
Bogdan-Lyashenko/js-code-to-svg-flowchart
cli/index.cli.js
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart/blob/master/cli/index.cli.js
MIT
createSvgFile = function(file, code) { const svg = js2flowchart.convertCodeToSvg(code), filePath = `${file}.svg`; writeToFile(filePath, svg); }
@description Write data to the specified file path. @param {string} filePath Path of the destination file @param {*} data Data to write to the destination
createSvgFile
javascript
Bogdan-Lyashenko/js-code-to-svg-flowchart
cli/index.cli.js
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart/blob/master/cli/index.cli.js
MIT
createAbstractedSvgFile = function(file, code, abstractionLevel) { const errMsg = 'Please use (case insensitive, without the quotes): "function", "function_dependencies", "class", "import" or "export"'; if (!abstractionLevel) return console.error(`No abstraction level specified`); const flowTreeBuil...
@description Create an SVG file with the provided abstraction level @param {string} file Name of the JS script @param {string} code JS code of the JS script @param {...string} abstractionLevel Abstraction levels (function, function dependencies, class, import, export) @return undefined
createAbstractedSvgFile
javascript
Bogdan-Lyashenko/js-code-to-svg-flowchart
cli/index.cli.js
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart/blob/master/cli/index.cli.js
MIT
createAbstractedSvgFile = function(file, code, abstractionLevel) { const errMsg = 'Please use (case insensitive, without the quotes): "function", "function_dependencies", "class", "import" or "export"'; if (!abstractionLevel) return console.error(`No abstraction level specified`); const flowTreeBuil...
@description Create an SVG file with the provided abstraction level @param {string} file Name of the JS script @param {string} code JS code of the JS script @param {...string} abstractionLevel Abstraction levels (function, function dependencies, class, import, export) @return undefined
createAbstractedSvgFile
javascript
Bogdan-Lyashenko/js-code-to-svg-flowchart
cli/index.cli.js
https://github.com/Bogdan-Lyashenko/js-code-to-svg-flowchart/blob/master/cli/index.cli.js
MIT
filterDNAOptions = (_dna) => { const dnaItems = _dna.split(DNA_DELIMITER); const filteredDNA = dnaItems.filter((element) => { const query = /(\?.*$)/; const querystring = query.exec(element); if (!querystring) { return true; } const options = querystring[1].split("&").reduce((r, setting) =...
In some cases a DNA string may contain optional query parameters for options such as bypassing the DNA isUnique check, this function filters out those items without modifying the stored DNA. @param {String} _dna New DNA string @returns new DNA string with any items that should be filtered, removed.
filterDNAOptions
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
filterDNAOptions = (_dna) => { const dnaItems = _dna.split(DNA_DELIMITER); const filteredDNA = dnaItems.filter((element) => { const query = /(\?.*$)/; const querystring = query.exec(element); if (!querystring) { return true; } const options = querystring[1].split("&").reduce((r, setting) =...
In some cases a DNA string may contain optional query parameters for options such as bypassing the DNA isUnique check, this function filters out those items without modifying the stored DNA. @param {String} _dna New DNA string @returns new DNA string with any items that should be filtered, removed.
filterDNAOptions
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
removeQueryStrings = (_dna) => { const query = /(\?.*$)/; return _dna.replace(query, ""); }
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
removeQueryStrings
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
removeQueryStrings = (_dna) => { const query = /(\?.*$)/; return _dna.replace(query, ""); }
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
removeQueryStrings
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
isDnaUnique = (_DnaList = new Set(), _dna = "") => { const _filteredDNA = filterDNAOptions(_dna); return !_DnaList.has(_filteredDNA); }
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
isDnaUnique
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
isDnaUnique = (_DnaList = new Set(), _dna = "") => { const _filteredDNA = filterDNAOptions(_dna); return !_DnaList.has(_filteredDNA); }
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
isDnaUnique
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
createDna = (_layers) => { let randNum = []; _layers.forEach((layer) => { var totalWeight = 0; layer.elements.forEach((element) => { totalWeight += element.weight; }); // number between 0 - totalWeight let random = Math.floor(Math.random() * totalWeight); for (var i = 0; i < layer.elem...
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
createDna
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
createDna = (_layers) => { let randNum = []; _layers.forEach((layer) => { var totalWeight = 0; layer.elements.forEach((element) => { totalWeight += element.weight; }); // number between 0 - totalWeight let random = Math.floor(Math.random() * totalWeight); for (var i = 0; i < layer.elem...
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
createDna
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
writeMetaData = (_data) => { fs.writeFileSync(`${buildDir}/json/_metadata.json`, _data); }
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
writeMetaData
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
writeMetaData = (_data) => { fs.writeFileSync(`${buildDir}/json/_metadata.json`, _data); }
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
writeMetaData
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
saveMetaDataSingleFile = (_editionCount) => { let metadata = metadataList.find((meta) => meta.edition == _editionCount); debugLogs ? console.log( `Writing metadata for ${_editionCount}: ${JSON.stringify(metadata)}` ) : null; fs.writeFileSync( `${buildDir}/json/${_editionCount}.json`, ...
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
saveMetaDataSingleFile
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
saveMetaDataSingleFile = (_editionCount) => { let metadata = metadataList.find((meta) => meta.edition == _editionCount); debugLogs ? console.log( `Writing metadata for ${_editionCount}: ${JSON.stringify(metadata)}` ) : null; fs.writeFileSync( `${buildDir}/json/${_editionCount}.json`, ...
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
saveMetaDataSingleFile
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
function shuffle(array) { let currentIndex = array.length, randomIndex; while (currentIndex != 0) { randomIndex = Math.floor(Math.random() * currentIndex); currentIndex--; [array[currentIndex], array[randomIndex]] = [ array[randomIndex], array[currentIndex], ]; } return array; }
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
shuffle
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
startCreating = async () => { let layerConfigIndex = 0; let editionCount = 1; let failedCount = 0; let abstractedIndexes = []; for ( let i = network == NETWORK.sol ? 0 : 1; i <= layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo; i++ ) { abstractedIndexes.push(i); } if...
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
startCreating
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
startCreating = async () => { let layerConfigIndex = 0; let editionCount = 1; let failedCount = 0; let abstractedIndexes = []; for ( let i = network == NETWORK.sol ? 0 : 1; i <= layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo; i++ ) { abstractedIndexes.push(i); } if...
Cleaning function for DNA strings. When DNA strings include an option, it is added to the filename with a ?setting=value query string. It needs to be removed to properly access the file name before Drawing. @param {String} _dna The entire newDNA string @returns Cleaned DNA string without querystring parameters.
startCreating
javascript
HashLips/hashlips_art_engine
src/main.js
https://github.com/HashLips/hashlips_art_engine/blob/master/src/main.js
MIT
function downloadFromOverpass ( queryName, overpassConfig, filename, overpassDownloadCallback ) { let query = '[out:json][timeout:60];(' if (overpassConfig.way) { query += 'way' } else { query += 'relation' } const queryKeys = Object.keys(overpassConfig) for (let i = queryKeys.length - 1; ...
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
downloadFromOverpass
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
overpassResponseHandler = function (err, data, overpassAttempt) { if (overpassAttempts[overpassAttempt]) { // Skip duplicate callback return } overpassAttempts[overpassAttempt] = true if (err) { console.log(err) console.log('Increas...
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
overpassResponseHandler
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
overpassResponseHandler = function (err, data, overpassAttempt) { if (overpassAttempts[overpassAttempt]) { // Skip duplicate callback return } overpassAttempts[overpassAttempt] = true if (err) { console.log(err) console.log('Increas...
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
overpassResponseHandler
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
makeQuery = function () { console.log('waiting ' + curRequestGap + ' seconds') setTimeout(function () { curOverpassQueryAttempt++ overpass( query, (err, data) => overpassResponseHandler(err, data, curOverpassQueryAttempt), { flatPrope...
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
makeQuery
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
makeQuery = function () { console.log('waiting ' + curRequestGap + ' seconds') setTimeout(function () { curOverpassQueryAttempt++ overpass( query, (err, data) => overpassResponseHandler(err, data, curOverpassQueryAttempt), { flatPrope...
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
makeQuery
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function downloadOsmBoundary (boundaryId, boundaryCallback) { const boundaryFilename = downloadsDir + '/' + boundaryId + '.json' downloadProgress.beginTask(`getting data for ${boundaryId}`, true) downloadFromOverpass( boundaryId, osmBoundarySources[boundaryId], boundaryFilename, boundaryCallback...
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
downloadOsmBoundary
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function downloadOsmTimezoneBoundary (tzId, boundaryCallback) { const tzBoundayName = `${tzId.replace(/\//g, '-')}-tz` const boundaryFilename = path.join(downloadsDir, `${tzBoundayName}.json`) const workingBoundaryFilename = path.join(osmDownloadDir, `${tzBoundayName}.json`) downloadOSMZoneProgress.beginTask(`...
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
downloadOsmTimezoneBoundary
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function copyToOsmDownloadFolder (err) { if (err) return boundaryCallback(err) fs.copyFile(boundaryFilename, workingBoundaryFilename, boundaryCallback) }
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
copyToOsmDownloadFolder
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function safeTzFilename (tzid) { return tzid.replace(/\//g, '__') }
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
safeTzFilename
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function getFinalTzOutputFilename (tzid) { return path.join(workingDir, `${safeTzFilename(tzid)}.json`) }
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
getFinalTzOutputFilename
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function getFinal1970TzOutputFilename (tzid) { return path.join(workingDir, `${safeTzFilename(tzid)}-1970.json`) }
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
getFinal1970TzOutputFilename
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function getFinalNowTzOutputFilename (tzid) { return path.join(workingDir, `${safeTzFilename(tzid)}-now.json`) }
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
getFinalNowTzOutputFilename
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function getSourceDownloadName (id) { return downloadsDir + '/' + id + '.json' }
Download something from overpass and convert it into GeoJSON. @param {string} queryName Name of the query (for debugging purposes) @param {object} overpassConfig Config used to build overpass query @param {string} filename Filename to save result to @param {function} overpassDownloadCallback The callback to cal...
getSourceDownloadName
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function getDataSource (source) { let geoJson if (source.source === 'overpass') { geoJson = require(getSourceDownloadName(source.id)) } else if (source.source === 'manual-polygon') { geoJson = polygon(source.data).geometry } else if (source.source === 'manual-multipolygon') { geoJson = multiPolygon(...
Get the geometry of the requested source data @return {Object} geom The geometry of the source @param {Object} source An object representing the data source must have `source` key and then either: - `id` if from a file - `id` if from a file
getDataSource
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function postProcessZone (geom, returnAsObject) { // reduce precision of geometry const geojson = geomToGeoJson(precisionReducer.reduce(geom)) // iterate through all polygons const filteredPolygons = [] let allPolygons = geojson.coordinates if (geojson.type === 'Polygon') { allPolygons = [geojson.coord...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
postProcessZone
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function makeTimezoneBoundaries (callback) { // load cache if available const tzBoundaryCache = new FileLookupCache({ filename: path.join(cacheDir, 'boundary-creation-cache.json') }) tzBoundaryCache.init(() => { asynclib.each( Object.keys(zoneCfg), (tzid, cb) => { buildingProgress.b...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
makeTimezoneBoundaries
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function makeDerivedTimezoneBoundaries (strategy, callback) { const cfg = ( strategy === '1970' ? { cacheFilename: path.join(cacheDir, 'derived-1970-cache.json'), derivedZoneConfig: zoneCfg1970, getFinalTzFilenameFn: getFinal1970TzOutputFilename, loadZonesInMemoryFn: ...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
makeDerivedTimezoneBoundaries
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function loadFinalZonesIntoMemory () { console.log('load zones into memory') Object.keys(zoneCfg).forEach(tzid => { finalZones[tzid] = getDataSource({ source: 'final', id: tzid }) }) }
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
loadFinalZonesIntoMemory
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function loadFinal1970ZonesIntoMemory () { console.log('load 1970 zones into memory') Object.keys(zoneCfg1970).forEach(tzid => { final1970Zones[tzid] = getDataSource({ source: 'final1970', id: tzid }) }) }
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
loadFinal1970ZonesIntoMemory
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function loadFinalNowZonesIntoMemory () { console.log('load Now zones into memory') Object.keys(zoneCfgNow).forEach(tzid => { finalNowZones[tzid] = getDataSource({ source: 'finalNow', id: tzid }) }) }
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
loadFinalNowZonesIntoMemory
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function roundDownToTenth (n) { return Math.floor(n * 10) / 10 }
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
roundDownToTenth
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function roundUpToTenth (n) { return Math.ceil(n * 10) / 10 }
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
roundUpToTenth
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function formatBounds (bounds) { let boundsStr = '[' boundsStr += roundDownToTenth(bounds[0]) + ', ' boundsStr += roundDownToTenth(bounds[1]) + ', ' boundsStr += roundUpToTenth(bounds[2]) + ', ' boundsStr += roundUpToTenth(bounds[3]) + ']' return boundsStr }
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
formatBounds
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function validateTimezoneBoundaries (callback) { console.log('do validation... this may take a few minutes with fresh data') // load cache if available const validationCache = new FileCache({ filename: path.join(cacheDir, 'validation-cache.json') }) validationCache.init(() => { let allZonesOk = true...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
validateTimezoneBoundaries
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function addOceans (callback) { console.log('adding ocean boundaries') const zones = Object.keys(zoneCfg) const oceanProgress = new ProgressStats( 'Oceans', oceanZones.length ) const oceanBoundaryCache = new FileCache({ filename: path.join(cacheDir, 'ocean-creation-cache.json') }) oceanBoun...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
addOceans
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function combineAndWriteZones (callback) { const regularWriter = new FeatureWriterStream(workingDir + '/combined.json') const oceanWriter = new FeatureWriterStream(workingDir + '/combined-with-oceans.json') let regular1970Writer let ocean1970Writer let regularNowWriter let oceanNowWriter if (!argv.skip_1...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
combineAndWriteZones
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function combineAndWriteOSMZones (callback) { const osmZoneWriter = new FeatureWriterStream(workingDir + '/combined-osm-zones.json') Object.keys(zoneCfg).forEach(tzId => { const tzBoundayName = `${tzId.replaceAll('/', '-')}-tz` const boundaryFilename = downloadsDir + '/' + tzBoundayName + '.json' const ...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
combineAndWriteOSMZones
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function downloadLastRelease (cb) { // download latest release info got( 'https://api.github.com/repos/evansiroky/timezone-boundary-builder/releases/latest' ).json() .then(data => { // determine last release version name and download link lastReleaseName = data.name lastReleaseJSONfile =...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
downloadLastRelease
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function zipGeoJsonFiles (cb) { const zipCommands = [ ['timezones.geojson.zip', 'combined.json'], ['timezones-with-oceans.geojson.zip', 'combined-with-oceans.json'] ] if (!argv.skip_1970_zones) { zipCommands.push(['timezones-1970.geojson.zip', 'combined-1970.json']) zipCommands.push(['timezones-wi...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
zipGeoJsonFiles
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function makeShapefile (config, cb) { rimraf(config.shapeFileGlob, rimrafErr => { if (rimrafErr) { return cb(rimrafErr) } exec( `ogr2ogr -f "ESRI Shapefile" ${config.shapeFile} ${config.jsonFile}`, ogrErr => { if (ogrErr) { return cb(ogrErr) } if (!config.shapeFileZip) { return cb(...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
makeShapefile
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function makeShapefiles (cb) { const shapefileConfigs = [ { // combined without oceans jsonFile: path.join(workingDir, 'combined.json'), shapeFile: path.join(workingDir, 'combined-shapefile.shp'), shapeFileGlob: path.join(workingDir, 'combined-shapefile.*'), shapeFileZip: path.join(distDir...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
makeShapefiles
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function analyzeChangesFromLastRelease (cb) { // load last release data into memory console.log('loading previous release into memory') const lastReleaseData = require(lastReleaseJSONfile) // load each feature's geojson into JSTS format and then organized by tzid const lastReleaseZones = {} lastReleaseData...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
analyzeChangesFromLastRelease
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
function assembleAndZipInputData (callback) { // since lots of files are at absolute paths, assemble a temporary folder with needed files const tempInputFilesDir = path.join(workingDir, 'input-data') asynclib.series( [ // remove previous folder cb => fs.rm(tempInputFilesDir, { recursive: true }, c...
Post process created timezone boundary. - remove small holes and exclaves - reduce geometry precision @param {Geometry} geom The jsts geometry of the timezone @param {boolean} returnAsObject if true, return as object, otherwise return stringified @return {Object|String} geojson as object or stringified
assembleAndZipInputData
javascript
evansiroky/timezone-boundary-builder
index.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/index.js
MIT
beginTask (message, logTimeLeft) { this.printStats(message, logTimeLeft) this.logNext() }
Begin a new task. Print the current progress and then increment the number of tasks. @param {string} A short message about the current task progress @param {[boolean]} logTimeLeft whether or not to log the time left.
beginTask
javascript
evansiroky/timezone-boundary-builder
util/progressStats.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/util/progressStats.js
MIT
printStats (message, logTimeLeft) { message = `${message}; ${this.trackerName} progress: ${this.getPercentage()}% done` if (logTimeLeft) { message = `${message} - ${this.getTimeLeft()} left` } console.log(message) }
Print the current progress. @param {string} A short message about the current task progress @param {[boolean]} logTimeLeft whether or not to log the time left.
printStats
javascript
evansiroky/timezone-boundary-builder
util/progressStats.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/util/progressStats.js
MIT
getPercentage () { const current = (this.taskCounter / this.totalTasks) return Math.round(current * 1000.0) / 10.0 }
calculates the percentage of finished downloads @returns {string}
getPercentage
javascript
evansiroky/timezone-boundary-builder
util/progressStats.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/util/progressStats.js
MIT
getTimeLeft () { if (this.taskCounter === 0) return '?' const averageTimePerTask = (Date.now() - this.beginTime.getTime()) / this.taskCounter const tasksLeft = this.totalTasks - this.taskCounter const millisecondsLeft = averageTimePerTask * tasksLeft return this.formatMilliseconds(millisecondsLeft) ...
calculates the time left and outputs it in human readable format calculation is based on the average time per task so far @returns {string}
getTimeLeft
javascript
evansiroky/timezone-boundary-builder
util/progressStats.js
https://github.com/evansiroky/timezone-boundary-builder/blob/master/util/progressStats.js
MIT