Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@glimmer/encoder

Package Overview
Dependencies
Maintainers
11
Versions
243
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glimmer/encoder - npm Package Compare versions

Comparing version 0.30.5 to 0.31.0

46

dist/amd/es5/glimmer-encoder.js

@@ -5,8 +5,2 @@ define('@glimmer/encoder', ['exports'], function (exports) { 'use strict';

var ARG_SHIFT = 8;
var MAX_SIZE = 65535;
var TYPE_SIZE = 255;
var TYPE_MASK = 255;
var OPERAND_LEN_MASK = 768;
var MACHINE_MASK = 1024;
var InstructionEncoder = function () {

@@ -22,27 +16,18 @@ function InstructionEncoder(buffer) {

InstructionEncoder.prototype.encode = function encode(type, machine) {
var _this = this;
if (type > TYPE_SIZE) {
throw new Error('Opcode type over 8-bits. Got ' + type + '.');
if (type > 255 /* TYPE_SIZE */) {
throw new Error('Opcode type over 8-bits. Got ' + type + '.');
}
this.buffer.push(type | machine | arguments.length - 2 << 8 /* ARG_SHIFT */);
this.typePos = this.buffer.length - 1;
for (var i = 2; i < arguments.length; i++) {
var op = arguments[i];
if (typeof op === 'number' && op > 65535 /* MAX_SIZE */) {
throw new Error('Operand over 16-bits. Got ' + op + '.');
}
this.buffer.push(op);
}
for (var _len = arguments.length, operands = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
operands[_key - 2] = arguments[_key];
}
this.buffer.push(type | machine | operands.length << ARG_SHIFT);
this.typePos = this.buffer.length - 1;
operands.forEach(function (op) {
if (typeof op === 'number' && op > MAX_SIZE) {
throw new Error('Operand over 16-bits. Got ' + op + '.');
}
_this.buffer.push(op);
});
this.size = this.buffer.length;
};
InstructionEncoder.prototype.compact = function compact(program) {
return String.fromCharCode.apply(String, program);
};
InstructionEncoder.prototype.patch = function patch(position, operand) {

@@ -59,7 +44,2 @@ if (this.buffer[position + 1] === -1) {

exports.ARG_SHIFT = ARG_SHIFT;
exports.TYPE_SIZE = TYPE_SIZE;
exports.TYPE_MASK = TYPE_MASK;
exports.OPERAND_LEN_MASK = OPERAND_LEN_MASK;
exports.MACHINE_MASK = MACHINE_MASK;
exports.InstructionEncoder = InstructionEncoder;

@@ -70,2 +50,2 @@

});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xpbW1lci1lbmNvZGVyLmpzIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9AZ2xpbW1lci9lbmNvZGVyL2xpYi9lbmNvZGVyLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IE9wIH0gZnJvbSBcIkBnbGltbWVyL3ZtXCI7XG5cbmV4cG9ydCBjb25zdCBBUkdfU0hJRlQgPSA4O1xuY29uc3QgTUFYX1NJWkUgICAgICAgICAgICAgICAgPSAwYjExMTExMTExMTExMTExMTE7XG5leHBvcnQgY29uc3QgVFlQRV9TSVpFICAgICAgICA9IDBiMTExMTExMTE7XG5leHBvcnQgY29uc3QgVFlQRV9NQVNLICAgICAgICA9IDBiMDAwMDAwMDAxMTExMTExMTtcbmV4cG9ydCBjb25zdCBPUEVSQU5EX0xFTl9NQVNLID0gMGIwMDAwMDAxMTAwMDAwMDAwO1xuZXhwb3J0IGNvbnN0IE1BQ0hJTkVfTUFTSyAgICAgPSAwYjAwMDAwMTAwMDAwMDAwMDA7XG5cbmV4cG9ydCB0eXBlIE9wZXJhbmQgPSBudW1iZXIgfCAoKCkgPT4gbnVtYmVyKTtcblxuZXhwb3J0IGNsYXNzIEluc3RydWN0aW9uRW5jb2RlciB7XG4gIGNvbnN0cnVjdG9yKHB1YmxpYyBidWZmZXI6IE9wZXJhbmRbXSkge31cbiAgdHlwZVBvcyA9IDA7XG4gIHNpemUgPSAwO1xuICBlbmNvZGUodHlwZTogT3AsIG1hY2hpbmU6IDAgfCB0eXBlb2YgTUFDSElORV9NQVNLLCAuLi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xJQUFJLFVBQVUsUUFBUSxLQUFLO2dCQUNyQyxLQUFLLFVBQVU7Z0JBQ2YsT0FBTyxPQUFPLFlBQVksMkJBQTBCOzBCQUNoRCxJQUFJLHFDQUFtQzs7aUJBRTFDLE9BQU8sS0FBSzs7O2FBR2QsT0FBTyxLQUFLLE9BQU87Ozt3REFHcEIsVUFBa0IsU0FDdEI7WUFBSSxLQUFLLE9BQU8sV0FBVyxPQUFPLENBQUMsR0FBRztpQkFDL0IsT0FBTyxXQUFXLEtBQUs7ZUFDdkI7a0JBQ0MsSUFBSSxNQUFNOzs7Ozs7Ozs7Ozs7Ozs7OzsifQ==

@@ -6,8 +6,2 @@ 'use strict';

});
const ARG_SHIFT = exports.ARG_SHIFT = 8;
const MAX_SIZE = 0b1111111111111111;
const TYPE_SIZE = exports.TYPE_SIZE = 0b11111111;
const TYPE_MASK = exports.TYPE_MASK = 0b0000000011111111;
const OPERAND_LEN_MASK = exports.OPERAND_LEN_MASK = 0b0000001100000000;
const MACHINE_MASK = exports.MACHINE_MASK = 0b0000010000000000;
class InstructionEncoder {

@@ -19,19 +13,18 @@ constructor(buffer) {

}
encode(type, machine, ...operands) {
if (type > TYPE_SIZE) {
throw new Error(`Opcode type over 8-bits. Got ${type}.`);
}
this.buffer.push(type | machine | operands.length << ARG_SHIFT);
encode(type, machine) {
if (type > 255 /* TYPE_SIZE */) {
throw new Error(`Opcode type over 8-bits. Got ${type}.`);
}
this.buffer.push(type | machine | arguments.length - 2 << 8 /* ARG_SHIFT */);
this.typePos = this.buffer.length - 1;
operands.forEach(op => {
if (typeof op === 'number' && op > MAX_SIZE) {
throw new Error(`Operand over 16-bits. Got ${op}.`);
}
for (let i = 2; i < arguments.length; i++) {
let op = arguments[i];
if (typeof op === 'number' && op > 65535 /* MAX_SIZE */) {
throw new Error(`Operand over 16-bits. Got ${op}.`);
}
this.buffer.push(op);
});
}
;
this.size = this.buffer.length;
}
compact(program) {
return String.fromCharCode(...program);
}
patch(position, operand) {

@@ -46,2 +39,2 @@ if (this.buffer[position + 1] === -1) {

exports.InstructionEncoder = InstructionEncoder;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jb2Rlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL0BnbGltbWVyL2VuY29kZXIvbGliL2VuY29kZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFFTyxNQUFNLEFBQVMsZ0NBQUcsQUFBQyxBQUFDO0FBQzNCLE1BQU0sQUFBUSxXQUFrQixBQUFrQixBQUFDLEFBQ25ELEFBQU07QUFBQyxNQUFNLEFBQVMsZ0NBQVUsQUFBVSxBQUFDLEFBQzNDLEFBQU07QUFBQyxNQUFNLEFBQVMsZ0NBQVUsQUFBa0IsQUFBQyxBQUNuRCxBQUFNO0FBQUMsTUFBTSxBQUFnQiw4Q0FBRyxBQUFrQixBQUFDLEFBQ25ELEFBQU07QUFBQyxNQUFNLEFBQVksc0NBQU8sQUFBa0IsQUFBQyxBQUluRCxBQUFNOztnQkFDZSxBQUFpQixRQUFqQjthQUFNLFNBQU4sQUFBTSxBQUFXLEFBQ3BDO2FBQU8sVUFBRyxBQUFDLEFBQUMsQUFDWjthQUFJLE9BRm1DLEFBQUMsQUFFakMsQUFBQyxBQUFDO0FBQ1QsQUFBTTtXQUFDLEFBQVEsTUFBRSxBQUFnQyxTQUFFLEdBQUcsQUFBbUIsVUFDdkUsQUFBRSxBQUFDO1lBQUMsQUFBSSxPQUFHLEFBQVMsQUFBQyxXQUFDLEFBQUMsQUFDckI7a0JBQU0sSUFBSSxBQUFLLEFBQUMsc0NBQWdDLEFBQUksQUFBRyxBQUFDLEFBQUMsQUFDM0QsSUFBQztBQUVELEFBQUk7YUFBQyxBQUFNLE9BQUMsQUFBSSxBQUFDLEtBQUMsQUFBSSxPQUFHLEFBQU8sQUFBRyxVQUF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IDFdID0gb3BlcmFuZDtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhyb3cgbmV3IEVycm9yKCdUcnlpbmcgdG8gcGF0Y2ggb3BlcmFuZCBpbiBwb3B1bGF0ZWQgc2xvdCBpbnN0ZWFkIG9mIGEgcmVzZXJ2ZWQgc2xvdC4nKTtcbiAgICB9XG4gIH1cbn1cbiJdfQ==

@@ -12,8 +12,2 @@ 'use strict';

var ARG_SHIFT = exports.ARG_SHIFT = 8;
var MAX_SIZE = 65535;
var TYPE_SIZE = exports.TYPE_SIZE = 255;
var TYPE_MASK = exports.TYPE_MASK = 255;
var OPERAND_LEN_MASK = exports.OPERAND_LEN_MASK = 768;
var MACHINE_MASK = exports.MACHINE_MASK = 1024;
var InstructionEncoder = exports.InstructionEncoder = function () {

@@ -29,27 +23,18 @@ function InstructionEncoder(buffer) {

InstructionEncoder.prototype.encode = function encode(type, machine) {
var _this = this;
if (type > TYPE_SIZE) {
throw new Error('Opcode type over 8-bits. Got ' + type + '.');
if (type > 255 /* TYPE_SIZE */) {
throw new Error('Opcode type over 8-bits. Got ' + type + '.');
}
this.buffer.push(type | machine | arguments.length - 2 << 8 /* ARG_SHIFT */);
this.typePos = this.buffer.length - 1;
for (var i = 2; i < arguments.length; i++) {
var op = arguments[i];
if (typeof op === 'number' && op > 65535 /* MAX_SIZE */) {
throw new Error('Operand over 16-bits. Got ' + op + '.');
}
this.buffer.push(op);
}
for (var _len = arguments.length, operands = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
operands[_key - 2] = arguments[_key];
}
this.buffer.push(type | machine | operands.length << ARG_SHIFT);
this.typePos = this.buffer.length - 1;
operands.forEach(function (op) {
if (typeof op === 'number' && op > MAX_SIZE) {
throw new Error('Operand over 16-bits. Got ' + op + '.');
}
_this.buffer.push(op);
});
;
this.size = this.buffer.length;
};
InstructionEncoder.prototype.compact = function compact(program) {
return String.fromCharCode.apply(String, program);
};
InstructionEncoder.prototype.patch = function patch(position, operand) {

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XMuYnVmZmVyW3Bvc2l0aW9uICsgMV0gPT09IC0xKSB7XG4gICAgICB0aGlzLmJ1ZmZlcltwb3NpdGlvbiArIDFdID0gb3BlcmFuZDtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhyb3cgbmV3IEVycm9yKCdUcnlpbmcgdG8gcGF0Y2ggb3BlcmFuZCBpbiBwb3B1bGF0ZWQgc2xvdCBpbnN0ZWFkIG9mIGEgcmVzZXJ2ZWQgc2xvdC4nKTtcbiAgICB9XG4gIH1cbn1cbiJdfQ==

@@ -1,7 +0,1 @@

export const ARG_SHIFT = 8;
const MAX_SIZE = 0b1111111111111111;
export const TYPE_SIZE = 0b11111111;
export const TYPE_MASK = 0b0000000011111111;
export const OPERAND_LEN_MASK = 0b0000001100000000;
export const MACHINE_MASK = 0b0000010000000000;
export class InstructionEncoder {

@@ -13,19 +7,18 @@ constructor(buffer) {

}
encode(type, machine, ...operands) {
if (type > TYPE_SIZE) {
throw new Error(`Opcode type over 8-bits. Got ${type}.`);
}
this.buffer.push(type | machine | operands.length << ARG_SHIFT);
encode(type, machine) {
if (type > 255 /* TYPE_SIZE */) {
throw new Error(`Opcode type over 8-bits. Got ${type}.`);
}
this.buffer.push(type | machine | arguments.length - 2 << 8 /* ARG_SHIFT */);
this.typePos = this.buffer.length - 1;
operands.forEach(op => {
if (typeof op === 'number' && op > MAX_SIZE) {
throw new Error(`Operand over 16-bits. Got ${op}.`);
}
for (let i = 2; i < arguments.length; i++) {
let op = arguments[i];
if (typeof op === 'number' && op > 65535 /* MAX_SIZE */) {
throw new Error(`Operand over 16-bits. Got ${op}.`);
}
this.buffer.push(op);
});
}
;
this.size = this.buffer.length;
}
compact(program) {
return String.fromCharCode(...program);
}
patch(position, operand) {

@@ -39,2 +32,2 @@ if (this.buffer[position + 1] === -1) {

}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jb2Rlci5qcyIsInNvdXJjZVJvb3QiOiIi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3RlYWQgb2YgYSByZXNlcnZlZCBzbG90LicpO1xuICAgIH1cbiAgfVxufVxuIl19
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
export var ARG_SHIFT = 8;
var MAX_SIZE = 65535;
export var TYPE_SIZE = 255;
export var TYPE_MASK = 255;
export var OPERAND_LEN_MASK = 768;
export var MACHINE_MASK = 1024;
export var InstructionEncoder = function () {

@@ -19,27 +13,18 @@ function InstructionEncoder(buffer) {

InstructionEncoder.prototype.encode = function encode(type, machine) {
var _this = this;
if (type > TYPE_SIZE) {
throw new Error('Opcode type over 8-bits. Got ' + type + '.');
if (type > 255 /* TYPE_SIZE */) {
throw new Error('Opcode type over 8-bits. Got ' + type + '.');
}
this.buffer.push(type | machine | arguments.length - 2 << 8 /* ARG_SHIFT */);
this.typePos = this.buffer.length - 1;
for (var i = 2; i < arguments.length; i++) {
var op = arguments[i];
if (typeof op === 'number' && op > 65535 /* MAX_SIZE */) {
throw new Error('Operand over 16-bits. Got ' + op + '.');
}
this.buffer.push(op);
}
for (var _len = arguments.length, operands = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
operands[_key - 2] = arguments[_key];
}
this.buffer.push(type | machine | operands.length << ARG_SHIFT);
this.typePos = this.buffer.length - 1;
operands.forEach(function (op) {
if (typeof op === 'number' && op > MAX_SIZE) {
throw new Error('Operand over 16-bits. Got ' + op + '.');
}
_this.buffer.push(op);
});
;
this.size = this.buffer.length;
};
InstructionEncoder.prototype.compact = function compact(program) {
return String.fromCharCode.apply(String, program);
};
InstructionEncoder.prototype.patch = function patch(position, operand) {

@@ -55,2 +40,2 @@ if (this.buffer[position + 1] === -1) {

}();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5jb2Rlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL0B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YWQgb2YgYSByZXNlcnZlZCBzbG90LicpO1xuICAgIH1cbiAgfVxufVxuIl19
import { Op } from "@glimmer/vm";
export declare const ARG_SHIFT = 8;
export declare const TYPE_SIZE = 255;
export declare const TYPE_MASK = 255;
export declare const OPERAND_LEN_MASK = 768;
export declare const MACHINE_MASK = 1024;
export declare const enum OpcodeSize {
ARG_SHIFT = 8,
MAX_SIZE = 65535,
TYPE_SIZE = 255,
TYPE_MASK = 255,
OPERAND_LEN_MASK = 768,
MACHINE_MASK = 1024,
}
export declare type Operand = number | (() => number);

@@ -13,5 +16,4 @@ export declare class InstructionEncoder {

size: number;
encode(type: Op, machine: 0 | typeof MACHINE_MASK, ...operands: Operand[]): void;
compact(program: number[]): string;
encode(type: Op, machine: 0 | OpcodeSize.MACHINE_MASK, ...operands: Operand[]): void;
patch(position: number, operand: number): void;
}
{
"name": "@glimmer/encoder",
"version": "0.30.5",
"version": "0.31.0",
"repository": "https://github.com/glimmerjs/glimmer-vm/tree/master/packages/@glimmer/encoder",

@@ -5,0 +5,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc