How to use the assert-js.string function in assert-js

To help you get started, we’ve selected a few assert-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github norberttech / no-game / nodejs / client / src / NoGame / Client / UserInterface / Chat.js View on Github external
addMessage(time, username, message)
    {
        Assert.instanceOf(time, Date);
        Assert.string(username);
        Assert.string(message);

        let msgElement = this._doc.createElement('div');
        msgElement.classList.add('message');

        msgElement.innerHTML = MESSAGE_TEMPLATE
            .replace(
                '__TIME__',
                this._format(time.getHours(), 2) + ':' + this._format(time.getMinutes(), 2) + ':' + this._format(time.getSeconds(), 2)
            ).replace('__USERNAME__', username)
            .replace('__MESSAGE__', message);

        this._packet.appendChild(msgElement);
        this._chatContainer.scrollTop = this._chatContainer.scrollHeight;

    }
github norberttech / no-game / nodejs / server / src / NoGame / Server / Broadcaster.js View on Github external
getConnection(playerId)
    {
        Assert.string(playerId);

        for (let connection of this._connections.values()) {
            if (connection.hasPlayerId && connection.playerId === playerId) {
                return connection;
            }
        }

        throw `Can't find connection for player with id ${playerId}`;
    }
github norberttech / no-game / nodejs / server / src / NoGame / Engine / Map / Area.js View on Github external
getPlayer(playerId)
    {
        Assert.string(playerId);

        if (!this._characters.has(playerId)) {
            throw new Error(`Player with id ${playerId} does not exists.`);
        }

        return this._characters.get(playerId);
    }
github norberttech / no-game / nodejs / server / src / NoGame / Server / Broadcaster.js View on Github external
removeConnection(id)
    {
        Assert.string(id);

        this._connections.delete(id);
    }
github norberttech / no-game / nodejs / client / src / NoGame / Client / Player.js View on Github external
attack(characterId)
    {
        Assert.string(characterId);

        this._targetId = characterId;
    }
github norberttech / no-game / nodejs / client / src / NoGame / Client / UserInterface / Chat.js View on Github external
addMessage(time, username, message)
    {
        Assert.instanceOf(time, Date);
        Assert.string(username);
        Assert.string(message);

        let msgElement = this._doc.createElement('div');
        msgElement.classList.add('message');

        msgElement.innerHTML = MESSAGE_TEMPLATE
            .replace(
                '__TIME__',
                this._format(time.getHours(), 2) + ':' + this._format(time.getMinutes(), 2) + ':' + this._format(time.getSeconds(), 2)
            ).replace('__USERNAME__', username)
            .replace('__MESSAGE__', message);

        this._packet.appendChild(msgElement);
        this._chatContainer.scrollTop = this._chatContainer.scrollHeight;

    }
github norberttech / no-game / nodejs / server / src / NoGame / Infrastructure / Logger / BunyanLogger.js View on Github external
constructor(name, logLevel)
    {
        super();

        Assert.string(name);
        Assert.string(logLevel);

        this._logger = bunyan.createLogger({
            name: name,
            level: logLevel
        });
    }
github norberttech / no-game / nodejs / client / src / NoGame / Client / Gfx / MessageUI.js View on Github external
constructor(text)
    {
        Assert.string(text);

        this._text = text;
        this._endTime = new Date().getTime() + 5000;
    }
github norberttech / no-game / nodejs / server / src / NoGame / Server / Network / CharacterSayMessage.js View on Github external
constructor(characterId, message)
    {
        super();

        Assert.string(characterId);
        Assert.string(message);

        this._name = ServerMessages.CHARACTER_SAY;
        this._data = {
            id: characterId,
            message: message
        };
    }
}
github norberttech / no-game / nodejs / client / src / NoGame / Client / Network / SayMessage.js View on Github external
constructor(message)
    {
        super();

        Assert.string(message);

        this._name = ClientMessages.MESSAGE;
        this._data = {message: message};
    }
}

assert-js

Javascript simple assertion library with no dependencies.

MIT
Latest version published 5 years ago

Package Health Score

45 / 100
Full package analysis