UNPKG

monaco-editor

Version:
50 lines (49 loc) 1.57 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ var Uint8Matrix = /** @class */ (function () { function Uint8Matrix(rows, cols, defaultValue) { var data = new Uint8Array(rows * cols); for (var i = 0, len = rows * cols; i < len; i++) { data[i] = defaultValue; } this._data = data; this.rows = rows; this.cols = cols; } Uint8Matrix.prototype.get = function (row, col) { return this._data[row * this.cols + col]; }; Uint8Matrix.prototype.set = function (row, col, value) { this._data[row * this.cols + col] = value; }; return Uint8Matrix; }()); export { Uint8Matrix }; export function toUint8(v) { if (v < 0) { return 0; } if (v > 255 /* MAX_UINT_8 */) { return 255 /* MAX_UINT_8 */; } return v | 0; } export function toUint32(v) { if (v < 0) { return 0; } if (v > 4294967295 /* MAX_UINT_32 */) { return 4294967295 /* MAX_UINT_32 */; } return v | 0; } export function toUint32Array(arr) { var len = arr.length; var r = new Uint32Array(len); for (var i = 0; i < len; i++) { r[i] = toUint32(arr[i]); } return r; }