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
function drawDetectionResults() { const canvas = multiPersonCanvas(); drawResults(sourceImage, canvas, faceDetection, predictedPoses); if (!predictedPoses || !predictedPoses.length || !illustration) { return; } skeleton.reset(); canvasScope.project.clear(); if (faceDetection && faceDetection.length ...
Draw the results from the multi-pose estimation on to a canvas
drawDetectionResults
javascript
yemount/pose-animator
static_image.js
https://github.com/yemount/pose-animator/blob/master/static_image.js
Apache-2.0
async function testImageAndEstimatePoses() { toggleLoadingUI(true); setStatusText('Loading FaceMesh model...'); document.getElementById('results').style.display = 'none'; // Reload facemesh model to purge states from previous runs. facemesh = await facemesh_module.load(); // Load an example image setSta...
Loads an image, feeds it into posenet the posenet model, and calculates poses based on the model outputs
testImageAndEstimatePoses
javascript
yemount/pose-animator
static_image.js
https://github.com/yemount/pose-animator/blob/master/static_image.js
Apache-2.0
function setupGui() { const gui = new dat.GUI(); const imageControls = gui.addFolder('Image'); imageControls.open(); gui.add(guiState, 'sourceImage', Object.keys(sourceImages)).onChange(() => testImageAndEstimatePoses()); gui.add(guiState, 'avatarSVG', Object.keys(avatarSvgs)).onChange(() => loadSVG(avatar...
Loads an image, feeds it into posenet the posenet model, and calculates poses based on the model outputs
setupGui
javascript
yemount/pose-animator
static_image.js
https://github.com/yemount/pose-animator/blob/master/static_image.js
Apache-2.0
async function bindPage() { toggleLoadingUI(true); canvasScope = paper.default; let canvas = getIllustrationCanvas(); canvas.width = CANVAS_WIDTH; canvas.height = CANVAS_HEIGHT; canvasScope.setup(canvas); await tf.setBackend('webgl'); setStatusText('Loading PoseNet model...'); posenet = await posenet...
Kicks off the demo by loading the posenet model and estimating poses on a default image
bindPage
javascript
yemount/pose-animator
static_image.js
https://github.com/yemount/pose-animator/blob/master/static_image.js
Apache-2.0
async function loadSVG(target) { let svgScope = await SVGUtils.importSVG(target); skeleton = new Skeleton(svgScope); illustration = new PoseIllustration(canvasScope); illustration.bindSkeleton(skeleton, svgScope); testImageAndEstimatePoses(); }
Kicks off the demo by loading the posenet model and estimating poses on a default image
loadSVG
javascript
yemount/pose-animator
static_image.js
https://github.com/yemount/pose-animator/blob/master/static_image.js
Apache-2.0
function toggleLoadingUI( showLoadingUI, loadingDivId = 'loading', mainDivId = 'main') { if (showLoadingUI) { document.getElementById(loadingDivId).style.display = 'block'; document.getElementById(mainDivId).style.display = 'none'; } else { document.getElementById(loadingDivId).style.display = 'none...
Toggles between the loading UI and the main canvas UI.
toggleLoadingUI
javascript
yemount/pose-animator
utils/demoUtils.js
https://github.com/yemount/pose-animator/blob/master/utils/demoUtils.js
Apache-2.0
function toTuple({y, x}) { return [y, x]; }
Toggles between the loading UI and the main canvas UI.
toTuple
javascript
yemount/pose-animator
utils/demoUtils.js
https://github.com/yemount/pose-animator/blob/master/utils/demoUtils.js
Apache-2.0
function drawPoint(ctx, y, x, r, color) { ctx.beginPath(); ctx.arc(x, y, r, 0, 2 * Math.PI); ctx.fillStyle = color; ctx.fill(); }
Toggles between the loading UI and the main canvas UI.
drawPoint
javascript
yemount/pose-animator
utils/demoUtils.js
https://github.com/yemount/pose-animator/blob/master/utils/demoUtils.js
Apache-2.0
function drawSkeleton(keypoints, minConfidence, ctx, scale = 1) { const adjacentKeyPoints = posenet.getAdjacentKeyPoints(keypoints, minConfidence); adjacentKeyPoints.forEach((keypoints) => { drawSegment( toTuple(keypoints[0].position), toTuple(keypoints[1].position), color, scale, ctx); ...
Draws a pose skeleton by looking up all adjacent keypoints/joints
drawSkeleton
javascript
yemount/pose-animator
utils/demoUtils.js
https://github.com/yemount/pose-animator/blob/master/utils/demoUtils.js
Apache-2.0
_subscribe(subscriber) { // const { source } = this; return source && source.subscribe(subscriber); }
@deprecated This is an internal implementation detail, do not use.
_subscribe
javascript
sverweij/dependency-cruiser
test/extract/transpile/__mocks__/dontconfuse_ts_for_tsx/transpiled/Observable.js
https://github.com/sverweij/dependency-cruiser/blob/master/test/extract/transpile/__mocks__/dontconfuse_ts_for_tsx/transpiled/Observable.js
MIT
function getAverage(arr) { var sum = arr.reduce(function (a, b) { return a + b; }); return sum / arr.length; }
Simple results wrapper Will be passed via events and to formatters
getAverage
javascript
macbre/phantomas
core/results.js
https://github.com/macbre/phantomas/blob/master/core/results.js
BSD-2-Clause
nodeRunner = function () { // "Beep, Beep" }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
nodeRunner
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function getStackFromError(e) { var stack = e.stack .trim() .split("\n") .map(function (item) { return item.replace(/^(\s+at\s|@)/, "").trim(); }) .filter(function (item) { return /:\d+\)?$/.test(item); }); //console.log(stack); retu...
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
getStackFromError
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function getBacktrace() { var stack = []; try { throw new Error("backtrace"); } catch (e) { stack = getStackFromError(e).slice(3); } return stack.join(" / "); }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
getBacktrace
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function getCaller(stepBack) { var caller = false; stepBack = stepBack || 0; try { throw new Error("backtrace"); } catch (e) { caller = getStackFromError(e)[3 + stepBack]; } return caller; }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
getCaller
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function sendMsg(type, data) { scope.__phantomas_emit("scopeMessage", type, data); }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
sendMsg
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function log() { sendMsg("log", Array.prototype.slice.apply(arguments)); }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
log
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function setMetric(name, value, isFinal) { sendMsg("setMetric", [ name, typeof value !== "undefined" ? value : 0, isFinal === true, ]); }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
setMetric
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function incrMetric(name, incr /* =1 */) { sendMsg("incrMetric", [name, incr || 1]); }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
incrMetric
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function addToAvgMetric(name, value) { sendMsg("addToAvgMetric", { name: name, value: value, }); }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
addToAvgMetric
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function setMarkerMetric(name) { sendMsg("setMarkerMetric", { name: name, }); }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
setMarkerMetric
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function addOffender(/*metricName, msg, ...*/) { sendMsg("addOffender", Array.prototype.slice.apply(arguments)); }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
addOffender
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function getParam(param, _default) { return scope.__phantomas_options[param] || _default; }
phantomas browser "scope" with helper code Code below is executed in page's "scope" (injected by the scope.injectJs() helper)
getParam
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function spyEnabled(state, reason) { enabled = state === true; phantomas.log( "Spying " + (enabled ? "enabled" : "disabled") + (reason ? " - " + reason : "") ); }
Proxy function to be used to track calls to native DOM functions Callback is provided with arguments original function was called with Example: window.__phantomas.proxy(window.document, 'getElementById', function() { // ... });
spyEnabled
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function spy(obj, fn, callback, reportResults) { var origFn = obj && obj[fn]; if (typeof origFn !== "function") { return false; } phantomas.log( 'spy: attaching to "%s" function%s', fn, reportResults ? " with results reporting" : "" ); obj[fn] = fun...
Proxy function to be used to track calls to native DOM functions Callback is provided with arguments original function was called with Example: window.__phantomas.proxy(window.document, 'getElementById', function() { // ... });
spy
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function spyGlobalVar(varName, callback) { phantomas.log("spy: attaching to %s global variable", varName); window.__defineSetter__(varName, function (val) { phantomas.log("spy: %s global variable has been defined", varName); spiedGlobals[varName] = val; callback(val); }); ...
Proxy function to be used to track calls to native DOM functions Callback is provided with arguments original function was called with Example: window.__phantomas.proxy(window.document, 'getElementById', function() { // ... });
spyGlobalVar
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function getDOMPath(node, dontGoUpTheDom /* = false */) { var path = [], entry = ""; if (node === window) { return "window"; } while (node instanceof Node) { // div entry = node.nodeName.toLowerCase(); // shorten the path a bit if (["body", "head", "html"].indexOf(...
Returns "DOM path" to a given node (starting from <body> down to the node) Example: body.logged_out.vis-public.env-production > div > div
getDOMPath
javascript
macbre/phantomas
core/scope.js
https://github.com/macbre/phantomas/blob/master/core/scope.js
BSD-2-Clause
function lowerCaseHeaders(headers) { var res = {}; Object.keys(headers).forEach((headerName) => { res[headerName.toLowerCase()] = headers[headerName]; }); return res; }
Given key-value set of HTTP headers returns the set with lowercased header names @param {object} headers @returns {object}
lowerCaseHeaders
javascript
macbre/phantomas
core/modules/requestsMonitor/requestsMonitor.js
https://github.com/macbre/phantomas/blob/master/core/modules/requestsMonitor/requestsMonitor.js
BSD-2-Clause
function parseEntryUrl(entry) { var parsed; // asset type entry.type = "other"; if (entry.url.indexOf("data:") === 0) { // base64 encoded data entry.domain = false; entry.protocol = false; entry.isBase64 = true; } else if (entry.url.indexOf("blob:") === 0) { // blob image or video en...
Given key-value set of HTTP headers returns the set with lowercased header names @param {object} headers @returns {object}
parseEntryUrl
javascript
macbre/phantomas
core/modules/requestsMonitor/requestsMonitor.js
https://github.com/macbre/phantomas/blob/master/core/modules/requestsMonitor/requestsMonitor.js
BSD-2-Clause
function addContentType(headerValue, entry) { var value = headerValue.split(";").shift().toLowerCase(); entry.contentType = value; switch (value) { case "text/html": entry.type = "html"; entry.isHTML = true; break; case "text/xml": entry.type = "xml"; entry.isXML = true; ...
Detect response content type using "Content-Type header value" @param {string} headerValue @param {object} entry
addContentType
javascript
macbre/phantomas
core/modules/requestsMonitor/requestsMonitor.js
https://github.com/macbre/phantomas/blob/master/core/modules/requestsMonitor/requestsMonitor.js
BSD-2-Clause
function screenshot(ts /* force timestamp in file name */) { var now = Date.now(), path; // check when was the last screenshot taken (exclude time it took to render the screenshot) if (now - lastScreenshot < SCREENSHOTS_MIN_INTERVAL) { //phantomas.log('Film strip: skipped'); return; }...
Please note that rendering each screenshot takes several hundreds ms. Consider increasing default timeout. Run phantomas with --film-strip option to use this module --film-strip-dir folder path to output film strip (default is ./filmstrip directory) --film-strip-prefix film strip files name prefix (defaults to 'scree...
screenshot
javascript
macbre/phantomas
extensions/filmStrip/filmStrip.js
https://github.com/macbre/phantomas/blob/master/extensions/filmStrip/filmStrip.js
BSD-2-Clause
function createHAR(page, creator) { // @see: https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HAR/Overview.html var address = page.address; var title = page.title; var startTime = page.startTime; var resources = page.resources; var entries = []; resources.forEach(function (resource) { var request =...
Inspired by phantomHAR @author: Christopher Van (@cvan) @homepage: https://github.com/cvan/phantomHAR @original: https://github.com/cvan/phantomHAR/blob/master/phantomhar.js
createHAR
javascript
macbre/phantomas
extensions/har/har.js
https://github.com/macbre/phantomas/blob/master/extensions/har/har.js
BSD-2-Clause
async function injectStorage(page, storage, storageType) { if (!page || !storage || !storageType) { return; } /* istanbul ignore next */ await page.evaluateOnNewDocument( (storage, storageType, SESSION_STORAGE, LOCAL_STORAGE) => { const keys = Object.keys(storage); const val...
Inject the given storage into the specified page storage. Either localStorage or sessionStorage @param {Page} page in which page the storage should be injected @param {Object} storage the JSON object consisting of the storage keys and values @param {string} storageType either localStorage or sessionStorage
injectStorage
javascript
macbre/phantomas
extensions/pageStorage/pageStorage.js
https://github.com/macbre/phantomas/blob/master/extensions/pageStorage/pageStorage.js
BSD-2-Clause
function phantomas(url, opts) { var events = new EventEmitter(), browser, options; debug("OS: %s %s", process.platform, process.arch); debug("Node.js: %s", process.version); debug("phantomas: %s", VERSION); debug( "Puppeteer: preferred revision r%s", puppeteer.default._preferredRevision ); ...
Main CommonJS module entry point @param {string} url @param {Object} opts @returns {browser}
phantomas
javascript
macbre/phantomas
lib/index.js
https://github.com/macbre/phantomas/blob/master/lib/index.js
BSD-2-Clause
function listModulesInDirectory(modulesDir) { const log = debug("phantomas:modules"); log("Getting the list of all modules in " + modulesDir); // https://nodejs.org/api/fs.html#fs_fs_readdirsync_path_options var ls = fs.readdirSync(modulesDir), modules = []; ls.forEach(function (entry) { // First ch...
Lists all modules / extensions in a given directory @param {string} modulesDir @returns {Array<string}
listModulesInDirectory
javascript
macbre/phantomas
lib/loader.js
https://github.com/macbre/phantomas/blob/master/lib/loader.js
BSD-2-Clause
function loadCoreModules(scope) { const modules = ["navigationTiming", "requestsMonitor", "timeToFirstByte"]; modules.forEach((name) => { var log = debug("phantomas:modules:" + name), _scope = Object.assign({}, scope); _scope.log = log; var module = require(__dirname + "/../core/modules/" + nam...
Lists all modules / extensions in a given directory @param {string} modulesDir @returns {Array<string}
loadCoreModules
javascript
macbre/phantomas
lib/loader.js
https://github.com/macbre/phantomas/blob/master/lib/loader.js
BSD-2-Clause
function loadExtensions(scope) { const extensions = listModulesInDirectory(__dirname + "/../extensions/"); extensions.forEach((name) => { var log = debug("phantomas:extensions:" + name), _scope = Object.assign({}, scope); _scope.log = log; var module = require(__dirname + "/../extensions/" + na...
Lists all modules / extensions in a given directory @param {string} modulesDir @returns {Array<string}
loadExtensions
javascript
macbre/phantomas
lib/loader.js
https://github.com/macbre/phantomas/blob/master/lib/loader.js
BSD-2-Clause
function loadModules(scope) { const extensions = listModulesInDirectory(__dirname + "/../modules/"); extensions.forEach((name) => { var log = debug("phantomas:modules:" + name), _scope = Object.assign({}, scope); _scope.log = log; var module = require(__dirname + "/../modules/" + name + "/" + n...
Lists all modules / extensions in a given directory @param {string} modulesDir @returns {Array<string}
loadModules
javascript
macbre/phantomas
lib/loader.js
https://github.com/macbre/phantomas/blob/master/lib/loader.js
BSD-2-Clause
function getMetricsCoveredByTests(spec) { const debug = require("debug")("metricsCovered"); var covered = {}; spec.forEach((testCase) => { debug(testCase.label || testCase.url); Object.keys(testCase.metrics || {}).forEach((metric) => { covered[metric] = true; }); Object.keys(testCase.off...
Generates metadata.json file that stores metadata about: - events - metrics - modules - extensions
getMetricsCoveredByTests
javascript
macbre/phantomas
lib/metadata/generate.js
https://github.com/macbre/phantomas/blob/master/lib/metadata/generate.js
BSD-2-Clause
function getOptionsCoveredByTests(spec) { var covered = {}; spec.forEach((testCase) => { Object.keys(testCase.options || {}).forEach((option) => { covered[option] = true; }); }); return Object.keys(covered).sort(); }
Generates metadata.json file that stores metadata about: - events - metrics - modules - extensions
getOptionsCoveredByTests
javascript
macbre/phantomas
lib/metadata/generate.js
https://github.com/macbre/phantomas/blob/master/lib/metadata/generate.js
BSD-2-Clause
function getModuleMetadata(moduleFile) { var content = fs.readFileSync(moduleFile).toString(), data = { name: "", description: "", metrics: {}, events: {}, }, matches, moduleName, metricRegEx = /(setMetric|setMetricEvaluate|incrMetric)\(['"]([^'"]+)['"](\)|,)(.*@desc....
Generates metadata.json file that stores metadata about: - events - metrics - modules - extensions
getModuleMetadata
javascript
macbre/phantomas
lib/metadata/generate.js
https://github.com/macbre/phantomas/blob/master/lib/metadata/generate.js
BSD-2-Clause
async function buildDocs() { // now add some real life examples from loading an example URL from our tests events += `## Examples`; const promise = phantomas("http://0.0.0.0:8888/_make_docs.html"); var hasEvent = {}; [ "recv", "send", "request", "response", "milestone", "metrics", ...
events.md https://github.com/macbre/phantomas/issues/729
buildDocs
javascript
macbre/phantomas
lib/metadata/make_docs.js
https://github.com/macbre/phantomas/blob/master/lib/metadata/make_docs.js
BSD-2-Clause
function ucfirst(str) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfixed by: Onno Marsman // + improved by: Brett Zamir (http://brett-zamir.me) // * example 1: ucfirst('kevin van zonneveld'); // * returns 1: 'Kevin...
Adds CSS complexity metrics using analyze-css npm module. Run phantomas with --analyze-css option to use this module setMetric('cssBase64Length') @desc total length of base64-encoded data in CSS source (will warn about base64-encoded data bigger than 4 kB) @optional @offenders setMetric('cssRedundantBodySelectors') @...
ucfirst
javascript
macbre/phantomas
modules/analyzeCss/analyzeCss.js
https://github.com/macbre/phantomas/blob/master/modules/analyzeCss/analyzeCss.js
BSD-2-Clause
async function analyzeCss(css, context) { /** // force JSON output format options.push('--json'); // set basic auth if needed if (phantomas.getParam('auth-user') && phantomas.getParam('auth-pass')) { options.push('--auth-user', phantomas.getParam('auth-user')); options.push('--auth-pass', phantomas.g...
Adds CSS complexity metrics using analyze-css npm module. Run phantomas with --analyze-css option to use this module setMetric('cssBase64Length') @desc total length of base64-encoded data in CSS source (will warn about base64-encoded data bigger than 4 kB) @optional @offenders setMetric('cssRedundantBodySelectors') @...
analyzeCss
javascript
macbre/phantomas
modules/analyzeCss/analyzeCss.js
https://github.com/macbre/phantomas/blob/master/modules/analyzeCss/analyzeCss.js
BSD-2-Clause
async function analyzeImage(body, context) { phantomas.log("Starting analyze-image on %j", context); const results = await analyzer(body, context, {}); phantomas.log("Response from analyze-image: %j", results); for (const offenderName in results.offenders) { phantomas.log( "Offender %s fo...
Adds Responsive Images metrics using analyze-images npm module. Run phantomas with --analyze-images option to use this module
analyzeImage
javascript
macbre/phantomas
modules/analyzeImages/analyzeImages.js
https://github.com/macbre/phantomas/blob/master/modules/analyzeImages/analyzeImages.js
BSD-2-Clause
function extractImageFromDataUri(str) { const result = str.match(/^data:image\/[a-z+]*(?:;[a-z0-9]*)?,(.*)$/); if (result) { // Inline SVGs might be urlencoded if (str.startsWith("data:image/svg+xml") && str.includes("%3Csvg")) { return decodeURIComponent(result[1]); } return res...
Adds Responsive Images metrics using analyze-images npm module. Run phantomas with --analyze-images option to use this module
extractImageFromDataUri
javascript
macbre/phantomas
modules/analyzeImages/analyzeImages.js
https://github.com/macbre/phantomas/blob/master/modules/analyzeImages/analyzeImages.js
BSD-2-Clause
function shortenDataUri(str) { if (str.length > 100) { return str.substring(0, 50) + " [...] " + str.substring(str.length - 50); } return str; }
Adds Responsive Images metrics using analyze-images npm module. Run phantomas with --analyze-images option to use this module
shortenDataUri
javascript
macbre/phantomas
modules/analyzeImages/analyzeImages.js
https://github.com/macbre/phantomas/blob/master/modules/analyzeImages/analyzeImages.js
BSD-2-Clause
function ms(value) { return Math.round(value * 1000); }
Retrieves stats about layouts, style recalcs and JS execution Metrics from https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagemetrics
ms
javascript
macbre/phantomas
modules/cpuTasks/cpuTasks.js
https://github.com/macbre/phantomas/blob/master/modules/cpuTasks/cpuTasks.js
BSD-2-Clause
function processHeaders(headers) { var res = { count: 0, size: 0, }; if (headers) { Object.keys(headers).forEach(function (key) { res.count++; res.size += (key + ": " + headers[key] + "\r\n").length; }); } return res; }
Analyzes HTTP headers in both requests and responses
processHeaders
javascript
macbre/phantomas
modules/headers/headers.js
https://github.com/macbre/phantomas/blob/master/modules/headers/headers.js
BSD-2-Clause
function pushToStack(type, entry, check) { // no entry of given type if (typeof stack[type] === "undefined") { stack[type] = entry; } // apply check function else if (check(stack[type], entry) === true) { stack[type] = entry; } }
Analyzes HTTP requests and generates stats metrics setMetric('smallestResponse') @desc the size of the smallest response @offenders setMetric('biggestResponse') @desc the size of the biggest response @offenders setMetric('fastestResponse') @desc the time to the last byte of the fastest response @offenders setMetric('s...
pushToStack
javascript
macbre/phantomas
modules/requestsStats/requestsStats.js
https://github.com/macbre/phantomas/blob/master/modules/requestsStats/requestsStats.js
BSD-2-Clause
function getFromStack(type) { return stack[type]; }
Analyzes HTTP requests and generates stats metrics setMetric('smallestResponse') @desc the size of the smallest response @offenders setMetric('biggestResponse') @desc the size of the biggest response @offenders setMetric('fastestResponse') @desc the time to the last byte of the fastest response @offenders setMetric('s...
getFromStack
javascript
macbre/phantomas
modules/requestsStats/requestsStats.js
https://github.com/macbre/phantomas/blob/master/modules/requestsStats/requestsStats.js
BSD-2-Clause
function setDomainMetric(metricName) { phantomas.setMetric(metricName, domains.getLength()); domains.sort().forEach(function (domain, cnt) { phantomas.addOffender(metricName, { domain, requests: cnt }); }); }
Number of requests it took to make the page enter DomContentLoaded and DomComplete states accordingly
setDomainMetric
javascript
macbre/phantomas
modules/requestsTo/requestsTo.js
https://github.com/macbre/phantomas/blob/master/modules/requestsTo/requestsTo.js
BSD-2-Clause
function capitalize(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }
Provides metrics for time to first image, CSS and JS file setMetric('timeToFirstCss') @desc time it took to receive the last byte of the first CSS @offenders setMetric('timeToFirstJs') @desc time it took to receive the last byte of the first JS @offenders setMetric('timeToFirstImage') @desc time it took to receiv...
capitalize
javascript
macbre/phantomas
modules/timeToFirst/timeToFirst.js
https://github.com/macbre/phantomas/blob/master/modules/timeToFirst/timeToFirst.js
BSD-2-Clause
function formatSingleRunResults(results) { var res = { generator: results.getGenerator(), url: results.getUrl(), metrics: results.getMetrics(), offenders: results.getAllOffenders(), asserts: false, }; // add asserts var asserts = results.getAsserts(), failedAsserts; ...
Results formatter for -R json Options: pretty - pretty print the JSON
formatSingleRunResults
javascript
macbre/phantomas
reporters/json.js
https://github.com/macbre/phantomas/blob/master/reporters/json.js
BSD-2-Clause
function useAnimatedValue({ direction, max, min, value }) { const [data, setData] = useState({ direction, value, }); const animate = useCallback(() => { // perform all the logic inside setData so useEffect's dependency array // can be empty so it will only trigger one on initial render and not ...
Implements `react-pixi-fiber`'s `usePixiTicker` hook, and the `useState` hook. Handles animation of the circle and square background.
useAnimatedValue
javascript
michalochman/react-pixi-fiber
examples/src/HooksExample/index.js
https://github.com/michalochman/react-pixi-fiber/blob/master/examples/src/HooksExample/index.js
MIT
function setValueForProperty(type, instance, propName, value, internalHandle) { const propertyInfo = getPropertyInfo(propName); let strictRoot = null; if (__DEV__) { strictRoot = findStrictRoot(internalHandle); } if (shouldIgnoreAttribute(type, propName, propertyInfo)) { return; } let shouldIgnor...
Sets the value for a property on a PIXI.DisplayObject instance. @param {string} type @param {PIXI.DisplayObject} instance @param {string} propName @param {*} value @param {*} internalHandle
setValueForProperty
javascript
michalochman/react-pixi-fiber
src/PixiPropertyOperations.js
https://github.com/michalochman/react-pixi-fiber/blob/master/src/PixiPropertyOperations.js
MIT
function Buffer (arg, encodingOrOffset, length) { if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { return new Buffer(arg, encodingOrOffset, length) } // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { throw new Error( 'If encoding is ...
The Buffer constructor returns instances of `Uint8Array` that have their prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of `Uint8Array`, so the returned instances will have all the node `Buffer` methods and the `Uint8Array` methods. Square bracket notation works as expected -- it returns a...
Buffer
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function from (that, value, encodingOrOffset, length) { if (typeof value === 'number') { throw new TypeError('"value" argument must not be a number') } if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { return fromArrayBuffer(that, value, encodingOrOffset, length) } if (typeof...
The Buffer constructor returns instances of `Uint8Array` that have their prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of `Uint8Array`, so the returned instances will have all the node `Buffer` methods and the `Uint8Array` methods. Square bracket notation works as expected -- it returns a...
from
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function assertSize (size) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be a number') } }
Functionally equivalent to Buffer(arg, encoding) but throws a TypeError if value is a number. Buffer.from(str[, encoding]) Buffer.from(array) Buffer.from(buffer) Buffer.from(arrayBuffer[, byteOffset[, length]])
assertSize
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function alloc (that, size, fill, encoding) { assertSize(size) if (size <= 0) { return createBuffer(that, size) } if (fill !== undefined) { // Only pay attention to encoding if it's a string. This // prevents accidentally sending in a number that would // be interpretted as a start offset. r...
Functionally equivalent to Buffer(arg, encoding) but throws a TypeError if value is a number. Buffer.from(str[, encoding]) Buffer.from(array) Buffer.from(buffer) Buffer.from(arrayBuffer[, byteOffset[, length]])
alloc
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function allocUnsafe (that, size) { assertSize(size) that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) if (!Buffer.TYPED_ARRAY_SUPPORT) { for (var i = 0; i < size; i++) { that[i] = 0 } } return that }
Creates a new filled Buffer instance. alloc(size[, fill[, encoding]])
allocUnsafe
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function fromString (that, string, encoding) { if (typeof encoding !== 'string' || encoding === '') { encoding = 'utf8' } if (!Buffer.isEncoding(encoding)) { throw new TypeError('"encoding" must be a valid string encoding') } var length = byteLength(string, encoding) | 0 that = createBuffer(that, ...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
fromString
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function fromArrayLike (that, array) { var length = checked(array.length) | 0 that = createBuffer(that, length) for (var i = 0; i < length; i += 1) { that[i] = array[i] & 255 } return that }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
fromArrayLike
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function fromArrayBuffer (that, array, byteOffset, length) { array.byteLength // this throws if `array` is not a valid ArrayBuffer if (byteOffset < 0 || array.byteLength < byteOffset) { throw new RangeError('\'offset\' is out of bounds') } if (array.byteLength < byteOffset + (length || 0)) { throw new...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
fromArrayBuffer
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function fromObject (that, obj) { if (Buffer.isBuffer(obj)) { var len = checked(obj.length) | 0 that = createBuffer(that, len) if (that.length === 0) { return that } obj.copy(that, 0, 0, len) return that } if (obj) { if ((typeof ArrayBuffer !== 'undefined' && obj.buffe...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
fromObject
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function checked (length) { // Note: cannot use `length < kMaxLength` here because that fails when // length is NaN (which is otherwise coerced to zero.) if (length >= kMaxLength()) { throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength().to...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
checked
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function SlowBuffer (length) { if (+length != length) { // eslint-disable-line eqeqeq length = 0 } return Buffer.alloc(+length) }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
SlowBuffer
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function byteLength (string, encoding) { if (Buffer.isBuffer(string)) { return string.length } if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { return string.byteLength } if (typeof string !== '...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
byteLength
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function slowToString (encoding, start, end) { var loweredCase = false // No need to verify that "this.length <= MAX_UINT32" since it's a read-only // property of a typed array. // This behaves neither like String nor Uint8Array in that we set start/end // to their upper/lower bounds if the value passed is ...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
slowToString
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function swap (b, n, m) { var i = b[n] b[n] = b[m] b[m] = i }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
swap
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function arrayIndexOf (arr, val, byteOffset, encoding) { var indexSize = 1 var arrLength = arr.length var valLength = val.length if (encoding !== undefined) { encoding = String(encoding).toLowerCase() if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
arrayIndexOf
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function read (buf, i) { if (indexSize === 1) { return buf[i] } else { return buf.readUInt16BE(i * indexSize) } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
read
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function hexWrite (buf, string, offset, length) { offset = Number(offset) || 0 var remaining = buf.length - offset if (!length) { length = remaining } else { length = Number(length) if (length > remaining) { length = remaining } } // must be an even number of digits var strLen = str...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
hexWrite
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function utf8Write (buf, string, offset, length) { return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
utf8Write
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function asciiWrite (buf, string, offset, length) { return blitBuffer(asciiToBytes(string), buf, offset, length) }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
asciiWrite
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function binaryWrite (buf, string, offset, length) { return asciiWrite(buf, string, offset, length) }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
binaryWrite
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function base64Write (buf, string, offset, length) { return blitBuffer(base64ToBytes(string), buf, offset, length) }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
base64Write
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function ucs2Write (buf, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
ucs2Write
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function base64Slice (buf, start, end) { if (start === 0 && end === buf.length) { return base64.fromByteArray(buf) } else { return base64.fromByteArray(buf.slice(start, end)) } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
base64Slice
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function utf8Slice (buf, start, end) { end = Math.min(buf.length, end) var res = [] var i = start while (i < end) { var firstByte = buf[i] var codePoint = null var bytesPerSequence = (firstByte > 0xEF) ? 4 : (firstByte > 0xDF) ? 3 : (firstByte > 0xBF) ? 2 : 1 if (i + bytesPer...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
utf8Slice
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function decodeCodePointsArray (codePoints) { var len = codePoints.length if (len <= MAX_ARGUMENTS_LENGTH) { return String.fromCharCode.apply(String, codePoints) // avoid extra slice() } // Decode in chunks to avoid "call stack size exceeded". var res = '' var i = 0 while (i < len) { res += Strin...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
decodeCodePointsArray
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function asciiSlice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) for (var i = start; i < end; i++) { ret += String.fromCharCode(buf[i] & 0x7F) } return ret }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
asciiSlice
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function binarySlice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) for (var i = start; i < end; i++) { ret += String.fromCharCode(buf[i]) } return ret }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
binarySlice
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function hexSlice (buf, start, end) { var len = buf.length if (!start || start < 0) start = 0 if (!end || end < 0 || end > len) end = len var out = '' for (var i = start; i < end; i++) { out += toHex(buf[i]) } return out }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
hexSlice
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function utf16leSlice (buf, start, end) { var bytes = buf.slice(start, end) var res = '' for (var i = 0; i < bytes.length; i += 2) { res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) } return res }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
utf16leSlice
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function checkOffset (offset, ext, length) { if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
checkOffset
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function checkInt (buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') if (offset + ext > buf.length) throw new RangeError('Index out of range') ...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
checkInt
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function objectWriteUInt16 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffff + value + 1 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> (littleEndian ? i : 1 - i) * 8 } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
objectWriteUInt16
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function objectWriteUInt32 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffffffff + value + 1 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff } }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
objectWriteUInt32
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function checkIEEE754 (buf, value, offset, ext, max, min) { if (offset + ext > buf.length) throw new RangeError('Index out of range') if (offset < 0) throw new RangeError('Index out of range') }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
checkIEEE754
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function writeFloat (buf, value, offset, littleEndian, noAssert) { if (!noAssert) { checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) } ieee754.write(buf, value, offset, littleEndian, 23, 4) return offset + 4 }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
writeFloat
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function writeDouble (buf, value, offset, littleEndian, noAssert) { if (!noAssert) { checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) } ieee754.write(buf, value, offset, littleEndian, 52, 8) return offset + 8 }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
writeDouble
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not str = stringtrim(str).replace(INVALID_BASE64_RE, '') // Node converts strings with length < 2 to '' if (str.length < 2) return '' // Node allows for non-padded base64 strings (missing trailing...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
base64clean
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function stringtrim (str) { if (str.trim) return str.trim() return str.replace(/^\s+|\s+$/g, '') }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
stringtrim
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function toHex (n) { if (n < 16) return '0' + n.toString(16) return n.toString(16) }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
toHex
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function utf8ToBytes (string, units) { units = units || Infinity var codePoint var length = string.length var leadSurrogate = null var bytes = [] for (var i = 0; i < length; i++) { codePoint = string.charCodeAt(i) // is surrogate component if (codePoint > 0xD7FF && codePoint < 0xE000) { ...
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
utf8ToBytes
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function asciiToBytes (str) { var byteArray = [] for (var i = 0; i < str.length; i++) { // Node's code seems to be doing this and not & 0x7F.. byteArray.push(str.charCodeAt(i) & 0xFF) } return byteArray }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
asciiToBytes
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function utf16leToBytes (str, units) { var c, hi, lo var byteArray = [] for (var i = 0; i < str.length; i++) { if ((units -= 2) < 0) break c = str.charCodeAt(i) hi = c >> 8 lo = c % 256 byteArray.push(lo) byteArray.push(hi) } return byteArray }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
utf16leToBytes
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function base64ToBytes (str) { return base64.toByteArray(base64clean(str)) }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
base64ToBytes
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT
function blitBuffer (src, dst, offset, length) { for (var i = 0; i < length; i++) { if ((i + offset >= dst.length) || (i >= src.length)) break dst[i + offset] = src[i] } return i }
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
blitBuffer
javascript
sparksuite/simplemde-markdown-editor
debug/simplemde.debug.js
https://github.com/sparksuite/simplemde-markdown-editor/blob/master/debug/simplemde.debug.js
MIT