Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Node.prototype._init = function init(body) {
var state = this._baseState;
assert(state.parent === null);
body.call(this);
// Filter children
state.children = state.children.filter(function(child) {
return child._baseState.parent === this;
}, this);
assert.equal(state.children.length, 1, 'Root node can have only one child');
};
Node.prototype._init = function init(body) {
var state = this._baseState;
assert(state.parent === null);
body.call(this);
// Filter children
state.children = state.children.filter(function(child) {
return child._baseState.parent === this;
}, this);
assert.equal(state.children.length, 1, 'Root node can have only one child');
};
types.forEach(type => {
const notComposite = !(type instanceof Composite);
const notUnion = !(type instanceof Union);
assert(notUnion, `Unions cannot contain other unions.`);
assert(
notComposite,
`Unions cannot contain composite types (given ${type.name}).`
);
// Ensure types can always be inferred by value.
if (type instanceof Derivation) {
assert(
!typeSet.has(type.subtype),
`Union contains ambiguous types (${type.name} & ${
type.subtype.name
}).`
);
}
});
types.forEach(type => {
const notComposite = !(type instanceof Composite);
const notUnion = !(type instanceof Union);
assert(notUnion, `Unions cannot contain other unions.`);
assert(
notComposite,
`Unions cannot contain composite types (given ${type.name}).`
);
// Ensure types can always be inferred by value.
if (type instanceof Derivation) {
assert(
!typeSet.has(type.subtype),
`Union contains ambiguous types (${type.name} & ${
type.subtype.name
}).`
);
}
});
constructor(name, primitive, def) {
assert(nameRegex.test(name), `Invalid derivation name "${name}".`);
this.name = name;
this.subtype = primitive;
Object.defineProperty(this, '_definition', {
value: def,
});
}
constructor(name: string, def: TypeDefinition) {
assert(nameRegex.test(name), invalidNameMsg(name));
this.name = name;
Object.defineProperties(this, {
_isValid: { value: def.isValid },
_coerce: { value: def.coerce },
});
}
function EDEState(type, key) {
assert.equal(key.length, 24, 'Invalid key length');
var k1 = key.slice(0, 8);
var k2 = key.slice(8, 16);
var k3 = key.slice(16, 24);
if (type === 'encrypt') {
this.ciphers = [
DES.create({ type: 'encrypt', key: k1 }),
DES.create({ type: 'decrypt', key: k2 }),
DES.create({ type: 'encrypt', key: k3 })
];
} else {
this.ciphers = [
DES.create({ type: 'decrypt', key: k3 }),
DES.create({ type: 'encrypt', key: k2 }),
DES.create({ type: 'decrypt', key: k1 })
function Game(options) {
EventEmitter.call(this);
this.options = options;
assert.equal(typeof this.options.index, 'number',
'options.index is required (number)');
assert.equal(typeof this.options.playerCount, 'number',
'options.players is required (number)');
assert.equal(typeof this.options.rules, 'object',
'options.rules is required (object)');
this.rules = this.options.rules;
this.index = this.options.index;
this.playerCount = this.options.playerCount;
this.players = new Array(this.playerCount);
for (var i = 0; i < this.players.length; i++)
this.players[i] = new Player();
this.prev = this.index === 0 ? this.playerCount - 1 : this.index - 1;
this.next = (this.index + 1) % this.playerCount;
DES.prototype._unpad = function _unpad(buffer) {
var pad = buffer[buffer.length - 1];
for (var i = buffer.length - pad; i < buffer.length; i++)
assert.equal(buffer[i], pad);
return buffer.slice(0, buffer.length - pad);
};
function Visual(options) {
EventEmitter.call(this);
this.options = options;
assert.equal(typeof this.options.cardCount, 'number',
'options.cardCount is required (number)');
this.cards = new Array(this.options.cardCount);
for (var i = 0; i < this.cards.length; i++)
this.cards[i] = new Card();
}
inherits(Visual, EventEmitter);