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 _decodeFill(line, index, count) { /** @type {string | {value: number}} */ const fill = parseFillOption(line); if (isObject(fill)) { return isNaN(fill.value) ? false : fill; } let target = parseFloat(fill); if (isFinite(target) && Math.floor(target) === target) { return decodeTargetIndex(...
@param {LineElement} line @param {number} index @param {number} count
_decodeFill
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.options.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.options.js
MIT
function _getTargetPixel(fill, scale) { let pixel = null; if (fill === 'start') { pixel = scale.bottom; } else if (fill === 'end') { pixel = scale.top; } else if (isObject(fill)) { // @ts-ignore pixel = scale.getPixelForValue(fill.value); } else if (scale.getBasePixel) { pixel = scale.getB...
@param {FillTarget | ComplexFillTarget} fill @param {Scale} scale @returns {number | null}
_getTargetPixel
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.options.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.options.js
MIT
function _getTargetValue(fill, scale, startValue) { let value; if (fill === 'start') { value = startValue; } else if (fill === 'end') { value = scale.options.reverse ? scale.min : scale.max; } else if (isObject(fill)) { // @ts-ignore value = fill.value; } else { value = scale.getBaseValue...
@param {FillTarget | ComplexFillTarget} fill @param {Scale} scale @param {number} startValue @returns {number | undefined}
_getTargetValue
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.options.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.options.js
MIT
function _getTarget(source) { const {chart, fill, line} = source; if (isFinite(fill)) { return getLineByIndex(chart, fill); } if (fill === 'stack') { return _buildStackLine(source); } if (fill === 'shape') { return true; } const boundary = computeBoundary(source); if (boundary instanc...
@typedef { import('../../core/core.controller.js').default } Chart @typedef { import('../../core/core.scale.js').default } Scale @typedef { import('../../elements/element.point.js').default } PointElement
_getTarget
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.target.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.js
MIT
function getLineByIndex(chart, index) { const meta = chart.getDatasetMeta(index); const visible = meta && chart.isDatasetVisible(index); return visible ? meta.dataset : null; }
@param {Chart} chart @param {number} index
getLineByIndex
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.target.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.js
MIT
function computeBoundary(source) { const scale = source.scale || {}; if (scale.getPointPositionForValue) { return computeCircularBoundary(source); } return computeLinearBoundary(source); }
@param {Chart} chart @param {number} index
computeBoundary
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.target.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.js
MIT
function computeLinearBoundary(source) { const {scale = {}, fill} = source; const pixel = _getTargetPixel(fill, scale); if (isFinite(pixel)) { const horizontal = scale.isHorizontal(); return { x: horizontal ? pixel : null, y: horizontal ? null : pixel }; } return null; }
@param {Chart} chart @param {number} index
computeLinearBoundary
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.target.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.js
MIT
function computeCircularBoundary(source) { const {scale, fill} = source; const options = scale.options; const length = scale.getLabels().length; const start = options.reverse ? scale.max : scale.min; const value = _getTargetValue(fill, scale, start); const target = []; if (options.grid.circular) { co...
@param {Chart} chart @param {number} index
computeCircularBoundary
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.target.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.js
MIT
function _buildStackLine(source) { const {scale, index, line} = source; const points = []; const segments = line.segments; const sourcePoints = line.points; const linesBelow = getLinesBelow(scale, index); linesBelow.push(_createBoundaryLine({x: null, y: scale.bottom}, line)); for (let i = 0; i < segments...
@param {{ chart: Chart; scale: Scale; index: number; line: LineElement; }} source @return {LineElement}
_buildStackLine
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.target.stack.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.stack.js
MIT
function getLinesBelow(scale, index) { const below = []; const metas = scale.getMatchingVisibleMetas('line'); for (let i = 0; i < metas.length; i++) { const meta = metas[i]; if (meta.index === index) { break; } if (!meta.hidden) { below.unshift(meta.dataset); } } return below;...
@param {Scale} scale @param {number} index @return {LineElement[]}
getLinesBelow
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.target.stack.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.stack.js
MIT
function addPointsBelow(points, sourcePoint, linesBelow) { const postponed = []; for (let j = 0; j < linesBelow.length; j++) { const line = linesBelow[j]; const {first, last, point} = findPoint(line, sourcePoint, 'x'); if (!point || (first && last)) { continue; } if (first) { // Fir...
@param {PointElement[]} points @param {PointElement} sourcePoint @param {LineElement[]} linesBelow
addPointsBelow
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.target.stack.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.stack.js
MIT
function findPoint(line, sourcePoint, property) { const point = line.interpolate(sourcePoint, property); if (!point) { return {}; } const pointValue = point[property]; const segments = line.segments; const linePoints = line.points; let first = false; let last = false; for (let i = 0; i < segments...
@param {LineElement} line @param {PointElement} sourcePoint @param {string} property @returns {{point?: PointElement, first?: boolean, last?: boolean}}
findPoint
javascript
chartjs/Chart.js
src/plugins/plugin.filler/filler.target.stack.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/filler.target.stack.js
MIT
afterDatasetsUpdate(chart, _args, options) { const count = (chart.data.datasets || []).length; const sources = []; let meta, i, line, source; for (i = 0; i < count; ++i) { meta = chart.getDatasetMeta(i); line = meta.dataset; source = null; if (line && line.options && line insta...
Plugin based on discussion from the following Chart.js issues: @see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569 @see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897
afterDatasetsUpdate
javascript
chartjs/Chart.js
src/plugins/plugin.filler/index.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/index.js
MIT
beforeDraw(chart, _args, options) { const draw = options.drawTime === 'beforeDraw'; const metasets = chart.getSortedVisibleDatasetMetas(); const area = chart.chartArea; for (let i = metasets.length - 1; i >= 0; --i) { const source = metasets[i].$filler; if (!source) { continue; ...
Plugin based on discussion from the following Chart.js issues: @see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569 @see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897
beforeDraw
javascript
chartjs/Chart.js
src/plugins/plugin.filler/index.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/index.js
MIT
beforeDatasetsDraw(chart, _args, options) { if (options.drawTime !== 'beforeDatasetsDraw') { return; } const metasets = chart.getSortedVisibleDatasetMetas(); for (let i = metasets.length - 1; i >= 0; --i) { const source = metasets[i].$filler; if (_shouldApplyFill(source)) { _...
Plugin based on discussion from the following Chart.js issues: @see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569 @see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897
beforeDatasetsDraw
javascript
chartjs/Chart.js
src/plugins/plugin.filler/index.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/index.js
MIT
beforeDatasetDraw(chart, args, options) { const source = args.meta.$filler; if (!_shouldApplyFill(source) || options.drawTime !== 'beforeDatasetDraw') { return; } _drawfill(chart.ctx, source, chart.chartArea); }
Plugin based on discussion from the following Chart.js issues: @see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569 @see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897
beforeDatasetDraw
javascript
chartjs/Chart.js
src/plugins/plugin.filler/index.js
https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/index.js
MIT
computeTickLimit() { const horizontal = this.isHorizontal(); const length = horizontal ? this.width : this.height; const minRotation = toRadians(this.options.ticks.minRotation); const ratio = (horizontal ? Math.sin(minRotation) : Math.cos(minRotation)) || 0.001; const tickFont = this._resolveTickFon...
Returns the maximum number of ticks based on the scale dimension @protected
computeTickLimit
javascript
chartjs/Chart.js
src/scales/scale.linear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.linear.js
MIT
getPixelForValue(value) { return value === null ? NaN : this.getPixelForDecimal((value - this._startValue) / this._valueRange); }
Returns the maximum number of ticks based on the scale dimension @protected
getPixelForValue
javascript
chartjs/Chart.js
src/scales/scale.linear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.linear.js
MIT
getValueForPixel(pixel) { return this._startValue + this.getDecimalForPixel(pixel) * this._valueRange; }
Returns the maximum number of ticks based on the scale dimension @protected
getValueForPixel
javascript
chartjs/Chart.js
src/scales/scale.linear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.linear.js
MIT
function generateTicks(generationOptions, dataRange) { const ticks = []; // To get a "nice" value for the tick spacing, we will use the appropriately named // "nice number" algorithm. See https://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks // for details. const MIN_...
Generate a set of linear ticks for an axis 1. If generationOptions.min, generationOptions.max, and generationOptions.step are defined: if (max - min) / step is an integer, ticks are generated as [min, min + step, ..., max] Note that the generationOptions.maxCount setting is respected in this scenario 2. If gener...
generateTicks
javascript
chartjs/Chart.js
src/scales/scale.linearbase.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.linearbase.js
MIT
function relativeLabelSize(value, minSpacing, {horizontal, minRotation}) { const rad = toRadians(minRotation); const ratio = (horizontal ? Math.sin(rad) : Math.cos(rad)) || 0.001; const length = 0.75 * minSpacing * ('' + value).length; return Math.min(minSpacing / ratio, length); }
Generate a set of linear ticks for an axis 1. If generationOptions.min, generationOptions.max, and generationOptions.step are defined: if (max - min) / step is an integer, ticks are generated as [min, min + step, ..., max] Note that the generationOptions.maxCount setting is respected in this scenario 2. If gener...
relativeLabelSize
javascript
chartjs/Chart.js
src/scales/scale.linearbase.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.linearbase.js
MIT
constructor(cfg) { super(cfg); /** @type {number} */ this.start = undefined; /** @type {number} */ this.end = undefined; /** @type {number} */ this._startValue = undefined; /** @type {number} */ this._endValue = undefined; this._valueRange = 0; }
Generate a set of linear ticks for an axis 1. If generationOptions.min, generationOptions.max, and generationOptions.step are defined: if (max - min) / step is an integer, ticks are generated as [min, min + step, ..., max] Note that the generationOptions.maxCount setting is respected in this scenario 2. If gener...
constructor
javascript
chartjs/Chart.js
src/scales/scale.linearbase.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.linearbase.js
MIT
function generateTicks(generationOptions, {min, max}) { min = finiteOrDefault(generationOptions.min, min); const ticks = []; const minExp = log10Floor(min); let exp = startExp(min, max); let precision = exp < 0 ? Math.pow(10, Math.abs(exp)) : 1; const stepSize = Math.pow(10, exp); const base = minExp > ex...
Generate a set of logarithmic ticks @param generationOptions the options used to generate the ticks @param dataRange the range of the data @returns {object[]} array of tick objects
generateTicks
javascript
chartjs/Chart.js
src/scales/scale.logarithmic.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.logarithmic.js
MIT
function fitWithPointLabels(scale) { // Right, this is really confusing and there is a lot of maths going on here // The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9 // // Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif // // Solution: // //...
Helper function to fit a radial linear scale with point labels
fitWithPointLabels
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function updateLimits(limits, orig, angle, hLimits, vLimits) { const sin = Math.abs(Math.sin(angle)); const cos = Math.abs(Math.cos(angle)); let x = 0; let y = 0; if (hLimits.start < orig.l) { x = (orig.l - hLimits.start) / sin; limits.l = Math.min(limits.l, orig.l - x); } else if (hLimits.end > ori...
Helper function to fit a radial linear scale with point labels
updateLimits
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function createPointLabelItem(scale, index, itemOpts) { const outerDistance = scale.drawingArea; const {extra, additionalAngle, padding, size} = itemOpts; const pointLabelPosition = scale.getPointPosition(index, outerDistance + extra + padding, additionalAngle); const angle = Math.round(toDegrees(_normalizeAngl...
Helper function to fit a radial linear scale with point labels
createPointLabelItem
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function isNotOverlapped(item, area) { if (!area) { return true; } const {left, top, right, bottom} = item; const apexesInArea = _isPointInArea({x: left, y: top}, area) || _isPointInArea({x: left, y: bottom}, area) || _isPointInArea({x: right, y: top}, area) || _isPointInArea({x: right, y: bottom}, area...
Helper function to fit a radial linear scale with point labels
isNotOverlapped
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function buildPointLabelItems(scale, labelSizes, padding) { const items = []; const valueCount = scale._pointLabels.length; const opts = scale.options; const {centerPointLabels, display} = opts.pointLabels; const itemOpts = { extra: getTickBackdropHeight(opts) / 2, additionalAngle: centerPointLabels ?...
Helper function to fit a radial linear scale with point labels
buildPointLabelItems
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function getTextAlignForAngle(angle) { if (angle === 0 || angle === 180) { return 'center'; } else if (angle < 180) { return 'left'; } return 'right'; }
Helper function to fit a radial linear scale with point labels
getTextAlignForAngle
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function leftForTextAlign(x, w, align) { if (align === 'right') { x -= w; } else if (align === 'center') { x -= (w / 2); } return x; }
Helper function to fit a radial linear scale with point labels
leftForTextAlign
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function yForAngle(y, h, angle) { if (angle === 90 || angle === 270) { y -= (h / 2); } else if (angle > 270 || angle < 90) { y -= h; } return y; }
Helper function to fit a radial linear scale with point labels
yForAngle
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function drawPointLabelBox(ctx, opts, item) { const {left, top, right, bottom} = item; const {backdropColor} = opts; if (!isNullOrUndef(backdropColor)) { const borderRadius = toTRBLCorners(opts.borderRadius); const padding = toPadding(opts.backdropPadding); ctx.fillStyle = backdropColor; const b...
Helper function to fit a radial linear scale with point labels
drawPointLabelBox
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function drawPointLabels(scale, labelCount) { const {ctx, options: {pointLabels}} = scale; for (let i = labelCount - 1; i >= 0; i--) { const item = scale._pointLabelItems[i]; if (!item.visible) { // overlapping continue; } const optsAtIndex = pointLabels.setContext(scale.getPointLabelCo...
Helper function to fit a radial linear scale with point labels
drawPointLabels
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function pathRadiusLine(scale, radius, circular, labelCount) { const {ctx} = scale; if (circular) { // Draw circular arcs between the points ctx.arc(scale.xCenter, scale.yCenter, radius, 0, TAU); } else { // Draw straight lines connecting each index let pointPosition = scale.getPointPosition(0, ra...
Helper function to fit a radial linear scale with point labels
pathRadiusLine
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function drawRadiusLine(scale, gridLineOpts, radius, labelCount, borderOpts) { const ctx = scale.ctx; const circular = gridLineOpts.circular; const {color, lineWidth} = gridLineOpts; if ((!circular && !labelCount) || !color || !lineWidth || radius < 0) { return; } ctx.save(); ctx.strokeStyle = colo...
Helper function to fit a radial linear scale with point labels
drawRadiusLine
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function createPointLabelContext(parent, index, label) { return createContext(parent, { label, index, type: 'pointLabel' }); }
Helper function to fit a radial linear scale with point labels
createPointLabelContext
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
computeTickLimit() { return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options)); }
Returns the maximum number of ticks based on the scale dimension @protected
computeTickLimit
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
generateTickLabels(ticks) { LinearScaleBase.prototype.generateTickLabels.call(this, ticks); // Point labels this._pointLabels = this.getLabels() .map((value, index) => { const label = callCallback(this.options.pointLabels.callback, [value, index], this); return label || label === 0 ? ...
Returns the maximum number of ticks based on the scale dimension @protected
generateTickLabels
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
fit() { const opts = this.options; if (opts.display && opts.pointLabels.display) { fitWithPointLabels(this); } else { this.setCenterPoint(0, 0, 0, 0); } }
Returns the maximum number of ticks based on the scale dimension @protected
fit
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
setCenterPoint(leftMovement, rightMovement, topMovement, bottomMovement) { this.xCenter += Math.floor((leftMovement - rightMovement) / 2); this.yCenter += Math.floor((topMovement - bottomMovement) / 2); this.drawingArea -= Math.min(this.drawingArea / 2, Math.max(leftMovement, rightMovement, topMovement, bot...
Returns the maximum number of ticks based on the scale dimension @protected
setCenterPoint
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
getIndexAngle(index) { const angleMultiplier = TAU / (this._pointLabels.length || 1); const startAngle = this.options.startAngle || 0; return _normalizeAngle(index * angleMultiplier + toRadians(startAngle)); }
Returns the maximum number of ticks based on the scale dimension @protected
getIndexAngle
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
getDistanceFromCenterForValue(value) { if (isNullOrUndef(value)) { return NaN; } // Take into account half font size + the yPadding of the top value const scalingFactor = this.drawingArea / (this.max - this.min); if (this.options.reverse) { return (this.max - value) * scalingFactor; ...
Returns the maximum number of ticks based on the scale dimension @protected
getDistanceFromCenterForValue
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
getValueForDistanceFromCenter(distance) { if (isNullOrUndef(distance)) { return NaN; } const scaledDistance = distance / (this.drawingArea / (this.max - this.min)); return this.options.reverse ? this.max - scaledDistance : this.min + scaledDistance; }
Returns the maximum number of ticks based on the scale dimension @protected
getValueForDistanceFromCenter
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
getPointLabelContext(index) { const pointLabels = this._pointLabels || []; if (index >= 0 && index < pointLabels.length) { const pointLabel = pointLabels[index]; return createPointLabelContext(this.getContext(), index, pointLabel); } }
Returns the maximum number of ticks based on the scale dimension @protected
getPointLabelContext
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
getPointPosition(index, distanceFromCenter, additionalAngle = 0) { const angle = this.getIndexAngle(index) - HALF_PI + additionalAngle; return { x: Math.cos(angle) * distanceFromCenter + this.xCenter, y: Math.sin(angle) * distanceFromCenter + this.yCenter, angle }; }
Returns the maximum number of ticks based on the scale dimension @protected
getPointPosition
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
getPointPositionForValue(index, value) { return this.getPointPosition(index, this.getDistanceFromCenterForValue(value)); }
Returns the maximum number of ticks based on the scale dimension @protected
getPointPositionForValue
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
getBasePosition(index) { return this.getPointPositionForValue(index || 0, this.getBaseValue()); }
Returns the maximum number of ticks based on the scale dimension @protected
getBasePosition
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
getPointLabelPosition(index) { const {left, top, right, bottom} = this._pointLabelItems[index]; return { left, top, right, bottom, }; }
Returns the maximum number of ticks based on the scale dimension @protected
getPointLabelPosition
javascript
chartjs/Chart.js
src/scales/scale.radialLinear.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.radialLinear.js
MIT
function parse(scale, input) { if (isNullOrUndef(input)) { return null; } const adapter = scale._adapter; const {parser, round, isoWeekday} = scale._parseOpts; let value = input; if (typeof parser === 'function') { value = parser(value); } // Only parse if it's not a timestamp already if (!...
@param {TimeScale} scale @param {*} input @return {number}
parse
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
function determineUnitForAutoTicks(minUnit, min, max, capacity) { const ilen = UNITS.length; for (let i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) { const interval = INTERVALS[UNITS[i]]; const factor = interval.steps ? interval.steps : Number.MAX_SAFE_INTEGER; if (interval.common && Math.ceil((max -...
Figures out what unit results in an appropriate number of auto-generated ticks @param {Unit} minUnit @param {number} min @param {number} max @param {number} capacity @return {object}
determineUnitForAutoTicks
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
function determineUnitForFormatting(scale, numTicks, minUnit, min, max) { for (let i = UNITS.length - 1; i >= UNITS.indexOf(minUnit); i--) { const unit = UNITS[i]; if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >= numTicks - 1) { return unit; } } return UNITS[minUnit ? UNITS....
Figures out what unit to format a set of ticks with @param {TimeScale} scale @param {number} numTicks @param {Unit} minUnit @param {number} min @param {number} max @return {Unit}
determineUnitForFormatting
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
function addTick(ticks, time, timestamps) { if (!timestamps) { ticks[time] = true; } else if (timestamps.length) { const {lo, hi} = _lookup(timestamps, time); const timestamp = timestamps[lo] >= time ? timestamps[lo] : timestamps[hi]; ticks[timestamp] = true; } }
@param {object} ticks @param {number} time @param {number[]} [timestamps] - if defined, snap to these timestamps
addTick
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
function setMajorTicks(scale, ticks, map, majorUnit) { const adapter = scale._adapter; const first = +adapter.startOf(ticks[0].value, majorUnit); const last = ticks[ticks.length - 1].value; let major, index; for (major = first; major <= last; major = +adapter.add(major, 1, majorUnit)) { index = map[major...
@param {TimeScale} scale @param {object[]} ticks @param {object} map @param {Unit} majorUnit @return {object[]}
setMajorTicks
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
function ticksFromTimestamps(scale, values, majorUnit) { const ticks = []; /** @type {Object<number,object>} */ const map = {}; const ilen = values.length; let i, value; for (i = 0; i < ilen; ++i) { value = values[i]; map[value] = i; ticks.push({ value, major: false }); } ...
@param {TimeScale} scale @param {number[]} values @param {Unit|undefined} [majorUnit] @return {object[]}
ticksFromTimestamps
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
parse(raw, index) { // eslint-disable-line no-unused-vars if (raw === undefined) { return null; } return parse(this, raw); }
@param {*} raw @param {number?} [index] @return {number}
parse
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
beforeLayout() { super.beforeLayout(); this._cache = { data: [], labels: [], all: [] }; }
@param {*} raw @param {number?} [index] @return {number}
beforeLayout
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
determineDataLimits() { const options = this.options; const adapter = this._adapter; const unit = options.time.unit || 'day'; // eslint-disable-next-line prefer-const let {min, max, minDefined, maxDefined} = this.getUserBounds(); /** * @param {object} bounds */ function _applyBounds(b...
@param {*} raw @param {number?} [index] @return {number}
determineDataLimits
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
initOffsets(timestamps = []) { let start = 0; let end = 0; let first, last; if (this.options.offset && timestamps.length) { first = this.getDecimalForValue(timestamps[0]); if (timestamps.length === 1) { start = 1 - first; } else { start = (this.getDecimalForValue(times...
Returns the start and end offsets from edges in the form of {start, end} where each value is a relative width to the scale and ranges between 0 and 1. They add extra margins on the both sides by scaling down the original scale. Offsets are added when the `offset` option is true. @param {number[]} timestamps @protected
initOffsets
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
_generate() { const adapter = this._adapter; const min = this.min; const max = this.max; const options = this.options; const timeOpts = options.time; // @ts-ignore const minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, this._getLabelCapacity(min)); const ste...
Generates a maximum of `capacity` timestamps between min and max, rounded to the `minor` unit using the given scale time `options`. Important: this method can return ticks outside the min and max range, it's the responsibility of the calling code to clamp values if needed. @protected
_generate
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
format(value, format) { const options = this.options; const formats = options.time.displayFormats; const unit = this._unit; const fmt = format || formats[unit]; return this._adapter.format(value, fmt); }
@param {number} value @param {string|undefined} format @return {string}
format
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
_tickFormatFunction(time, index, ticks, format) { const options = this.options; const formatter = options.ticks.callback; if (formatter) { return call(formatter, [time, index, ticks], this); } const formats = options.time.displayFormats; const unit = this._unit; const majorUnit = thi...
Function to format an individual tick mark @param {number} time @param {number} index @param {object[]} ticks @param {string|undefined} [format] @return {string} @private
_tickFormatFunction
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
getDecimalForValue(value) { return value === null ? NaN : (value - this.min) / (this.max - this.min); }
@param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC) @return {number}
getDecimalForValue
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
getPixelForValue(value) { const offsets = this._offsets; const pos = this.getDecimalForValue(value); return this.getPixelForDecimal((offsets.start + pos) * offsets.factor); }
@param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC) @return {number}
getPixelForValue
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
_getLabelSize(label) { const ticksOpts = this.options.ticks; const tickLabelWidth = this.ctx.measureText(label).width; const angle = toRadians(this.isHorizontal() ? ticksOpts.maxRotation : ticksOpts.minRotation); const cosRotation = Math.cos(angle); const sinRotation = Math.sin(angle); const tic...
@param {string} label @return {{w:number, h:number}} @private
_getLabelSize
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
_getLabelCapacity(exampleTime) { const timeOpts = this.options.time; const displayFormats = timeOpts.displayFormats; // pick the longest format (milliseconds) for guesstimation const format = displayFormats[timeOpts.unit] || displayFormats.millisecond; const exampleLabel = this._tickFormatFunction(...
@param {number} exampleTime @return {number} @private
_getLabelCapacity
javascript
chartjs/Chart.js
src/scales/scale.time.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.time.js
MIT
function interpolate(table, val, reverse) { let lo = 0; let hi = table.length - 1; let prevSource, nextSource, prevTarget, nextTarget; if (reverse) { if (val >= table[lo].pos && val <= table[hi].pos) { ({lo, hi} = _lookupByKey(table, 'pos', val)); } ({pos: prevSource, time: prevTarget} = table...
Linearly interpolates the given source `val` using the table. If value is out of bounds, values at edges are used for the interpolation. @param {object} table @param {number} val @param {boolean} [reverse] lookup time based on position instead of vice versa @return {object}
interpolate
javascript
chartjs/Chart.js
src/scales/scale.timeseries.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.timeseries.js
MIT
_generate() { const min = this.min; const max = this.max; let timestamps = super.getDataTimestamps(); if (!timestamps.includes(min) || !timestamps.length) { timestamps.splice(0, 0, min); } if (!timestamps.includes(max) || timestamps.length === 1) { timestamps.push(max); } ret...
Generates all timestamps defined in the data. Important: this method can return ticks outside the min and max range, it's the responsibility of the calling code to clamp values if needed. @protected
_generate
javascript
chartjs/Chart.js
src/scales/scale.timeseries.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.timeseries.js
MIT
_getTimestampsForTable() { let timestamps = this._cache.all || []; if (timestamps.length) { return timestamps; } const data = this.getDataTimestamps(); const label = this.getLabelTimestamps(); if (data.length && label.length) { // If combining labels and data (data might not contai...
Returns all timestamps @return {number[]} @private
_getTimestampsForTable
javascript
chartjs/Chart.js
src/scales/scale.timeseries.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.timeseries.js
MIT
getDecimalForValue(value) { return (interpolate(this._table, value) - this._minPos) / this._tableRange; }
@param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC) @return {number}
getDecimalForValue
javascript
chartjs/Chart.js
src/scales/scale.timeseries.js
https://github.com/chartjs/Chart.js/blob/master/src/scales/scale.timeseries.js
MIT
concat(a1, a2) { if (a1.length === 0 || a2.length === 0) { return a1.concat(a2); } const last = a1[a1.length - 1], shift = bitArray.getPartial(last); if (shift === 32) { return a1.concat(a2); } else { return bitArray._shiftRight(a2, shift, last | 0, a1.slice(0, a1.length - 1)); } }
Concatenate two bit arrays. @param {bitArray} a1 The first array. @param {bitArray} a2 The second array. @return {bitArray} The concatenation of a1 and a2.
concat
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
bitLength(a) { const l = a.length; if (l === 0) { return 0; } const x = a[l - 1]; return (l - 1) * 32 + bitArray.getPartial(x); }
Find the length of an array of bits. @param {bitArray} a The array. @return {Number} The length of a, in bits.
bitLength
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
clamp(a, len) { if (a.length * 32 < len) { return a; } a = a.slice(0, Math.ceil(len / 32)); const l = a.length; len = len & 31; if (l > 0 && len) { a[l - 1] = bitArray.partial(len, a[l - 1] & 0x80000000 >> (len - 1), 1); } return a; }
Truncate an array. @param {bitArray} a The array. @param {Number} len The length to truncate to, in bits. @return {bitArray} A new array, truncated to len bits.
clamp
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
partial(len, x, _end) { if (len === 32) { return x; } return (_end ? x | 0 : x << (32 - len)) + len * 0x10000000000; }
Make a partial word for a bit array. @param {Number} len The number of bits in the word. @param {Number} x The bits. @param {Number} [_end=0] Pass 1 if x has already been shifted to the high side. @return {Number} The partial word.
partial
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
getPartial(x) { return Math.round(x / 0x10000000000) || 32; }
Get the number of bits used by a partial word. @param {Number} x The partial word. @return {Number} The number of bits used by the partial word.
getPartial
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
_shiftRight(a, shift, carry, out) { if (out === undefined) { out = []; } for (; shift >= 32; shift -= 32) { out.push(carry); carry = 0; } if (shift === 0) { return out.concat(a); } for (let i = 0; i < a.length; i++) { out.push(carry | a[i] >>> shift); carry = a[i] << (32 -...
Shift an array right. @param {bitArray} a The array to shift. @param {Number} shift The number of bits to shift. @param {Number} [carry=0] A byte to carry in @param {bitArray} [out=[]] An array to prepend to the output. @private
_shiftRight
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
fromBits(arr) { const bl = bitArray.bitLength(arr); const byteLength = bl / 8; const out = new Uint8Array(byteLength); let tmp; for (let i = 0; i < byteLength; i++) { if ((i & 3) === 0) { tmp = arr[i / 4]; } out[i] = tmp >>> 24; tmp <<= 8; } return out; }
Convert from a bitArray to an array of bytes.
fromBits
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
toBits(bytes) { const out = []; let i; let tmp = 0; for (i = 0; i < bytes.length; i++) { tmp = tmp << 8 | bytes[i]; if ((i & 3) === 3) { out.push(tmp); tmp = 0; } } if (i & 3) { out.push(bitArray.partial(8 * (i & 3), tmp)); } return out; }
Convert from an array of bytes to a bitArray.
toBits
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
constructor(hash) { const sha1 = this; /** * The hash's block size, in bits. * @constant */ sha1.blockSize = 512; /** * The SHA-1 initialization vector. * @private */ sha1._init = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]; /** * The SHA-1 hash key. * ...
Context for a SHA-1 operation in progress. @constructor
constructor
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
reset() { const sha1 = this; sha1._h = sha1._init.slice(0); sha1._buffer = []; sha1._length = 0; return sha1; }
Reset the hash state. @return this
reset
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
update(data) { const sha1 = this; if (typeof data === "string") { data = codec.utf8String.toBits(data); } const b = sha1._buffer = bitArray.concat(sha1._buffer, data); const ol = sha1._length; const nl = sha1._length = ol + bitArray.bitLength(data); if (nl > 9007199254740991) { throw new Er...
Input several words to the hash. @param {bitArray|String} data the data to hash. @return this
update
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
finalize() { const sha1 = this; let b = sha1._buffer; const h = sha1._h; // Round out and push the buffer b = bitArray.concat(b, [bitArray.partial(1, 1)]); // Round out the buffer to a multiple of 16 words, less the 2 length words. for (let i = b.length + 2; i & 15; i++) { b.push(0); } ...
Complete hashing and output the hash value. @return {bitArray} The hash value, an array of 5 big-endian words. TODO
finalize
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
_block(words) { const sha1 = this; const h = sha1._h; // When words is passed to _block, it has 16 elements. SHA1 _block // function extends words with new elements (at the end there are 80 elements). // The problem is that if we use Uint32Array instead of Array, // the length of Uint32Array cannot ...
Perform one cycle of SHA-1. @param {Uint32Array|bitArray} words one block of words. @private
_block
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
constructor(key) { /** * The expanded S-box and inverse S-box tables. These will be computed * on the client so that we don't have to send them down the wire. * * There are two tables, _tables[0] is for encryption and * _tables[1] is for decryption. * * The first 4 sub-tables are the exp...
Schedule out an AES key for both encryption and decryption. This is a low-level class. Use a cipher mode to do bulk encryption. @constructor @param {Array} key The key as an array of 4, 6 or 8 words.
constructor
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
encrypt(data) { return this._crypt(data, 0); }
Encrypt an array of 4 big-endian words. @param {Array} data The plaintext. @return {Array} The ciphertext.
encrypt
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
decrypt(data) { return this._crypt(data, 1); }
Decrypt an array of 4 big-endian words. @param {Array} data The ciphertext. @return {Array} The plaintext.
decrypt
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
_crypt(input, dir) { if (input.length !== 4) { throw new Error("invalid aes block size"); } const key = this._key[dir]; const nInnerRounds = key.length / 4 - 2; const out = [0, 0, 0, 0]; const table = this._tables[dir]; // load up the tables const t0 = table[0]; const t1 = table[1]; ...
Encryption and decryption core. @param {Array} input Four words to be encrypted or decrypted. @param dir The direction, 0 for encrypt and 1 for decrypt. @return {Array} The four encrypted or decrypted words. @private
_crypt
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
getRandomValues(typedArray) { const words = new Uint32Array(typedArray.buffer); const r = (m_w) => { let m_z = 0x3ade68b1; const mask = 0xffffffff; return function () { m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask; m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask; const ...
Generate random words with pure js, cryptographically not as strong & safe as native implementation. @param {TypedArray} typedArray The array to fill. @return {TypedArray} The random values.
getRandomValues
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
r = (m_w) => { let m_z = 0x3ade68b1; const mask = 0xffffffff; return function () { m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask; m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask; const result = ((((m_z << 0x10) + m_w) & mask) / 0x100000000) + .5; return result * (Math.ran...
Generate random words with pure js, cryptographically not as strong & safe as native implementation. @param {TypedArray} typedArray The array to fill. @return {TypedArray} The random values.
r
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
r = (m_w) => { let m_z = 0x3ade68b1; const mask = 0xffffffff; return function () { m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask; m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask; const result = ((((m_z << 0x10) + m_w) & mask) / 0x100000000) + .5; return result * (Math.ran...
Generate random words with pure js, cryptographically not as strong & safe as native implementation. @param {TypedArray} typedArray The array to fill. @return {TypedArray} The random values.
r
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
update(data) { return this.calculate(this._prf, data, this._iv); }
Input some data to calculate. @param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last.
update
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
incWord(word) { if (((word >> 24) & 0xff) === 0xff) { //overflow let b1 = (word >> 16) & 0xff; let b2 = (word >> 8) & 0xff; let b3 = word & 0xff; if (b1 === 0xff) { // overflow b1 b1 = 0; if (b2 === 0xff) { b2 = 0; if (b3 === 0xff) { b3 = 0; } else { ++b3...
Input some data to calculate. @param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last.
incWord
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
incCounter(counter) { if ((counter[0] = this.incWord(counter[0])) === 0) { // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8 counter[1] = this.incWord(counter[1]); } }
Input some data to calculate. @param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last.
incCounter
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
calculate(prf, data, iv) { let l; if (!(l = data.length)) { return []; } const bl = bitArray.bitLength(data); for (let i = 0; i < l; i += 4) { this.incCounter(iv); const e = prf.encrypt(iv); data[i] ^= e[0]; data[i + 1] ^= e[1]; data[i + 2] ^= e[2]; data[i + 3] ^= e[3]; } ...
Input some data to calculate. @param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last.
calculate
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
importKey(password) { return new misc.hmacSha1(codec.bytes.toBits(password)); }
Input some data to calculate. @param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last.
importKey
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
pbkdf2(prf, salt, count, length) { count = count || 10000; if (length < 0 || count < 0) { throw new Error("invalid params to pbkdf2"); } const byteLength = ((length >> 5) + 1) << 2; let u, ui, i, j, k; const arrayBuffer = new ArrayBuffer(byteLength); const out = new DataView(arrayBuffer); le...
Input some data to calculate. @param {bitArray} data the data to process, it must be intergral multiple of 128 bits unless it's the last.
pbkdf2
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
constructor(key) { const hmac = this; const Hash = hmac._hash = hash.sha1; const exKey = [[], []]; hmac._baseHash = [new Hash(), new Hash()]; const bs = hmac._baseHash[0].blockSize / 32; if (key.length > bs) { key = new Hash().update(key).finalize(); } for (let i = 0; i < bs; i++) { ex...
HMAC with the specified hash function. @constructor @param {bitArray} key the key for HMAC. @param {Object} [Hash=hash.sha1] The hash function to use.
constructor
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
reset() { const hmac = this; hmac._resultHash = new hmac._hash(hmac._baseHash[0]); hmac._updated = false; }
HMAC with the specified hash function. @constructor @param {bitArray} key the key for HMAC. @param {Object} [Hash=hash.sha1] The hash function to use.
reset
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
update(data) { const hmac = this; hmac._updated = true; hmac._resultHash.update(data); }
HMAC with the specified hash function. @constructor @param {bitArray} key the key for HMAC. @param {Object} [Hash=hash.sha1] The hash function to use.
update
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
digest() { const hmac = this; const w = hmac._resultHash.finalize(); const result = new (hmac._hash)(hmac._baseHash[1]).update(w).finalize(); hmac.reset(); return result; }
HMAC with the specified hash function. @constructor @param {bitArray} key the key for HMAC. @param {Object} [Hash=hash.sha1] The hash function to use.
digest
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause
encrypt(data) { if (!this._updated) { this.update(data); return this.digest(data); } else { throw new Error("encrypt on already updated hmac called!"); } }
HMAC with the specified hash function. @constructor @param {bitArray} key the key for HMAC. @param {Object} [Hash=hash.sha1] The hash function to use.
encrypt
javascript
gildas-lormeau/zip.js
dist/zip-fs-full.js
https://github.com/gildas-lormeau/zip.js/blob/master/dist/zip-fs-full.js
BSD-3-Clause