How to use lib - 10 common examples

To help you get started, we’ve selected a few lib 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 node-steam / market-pricing / test / mock / currency / pound / single.ts View on Github external
// First Valid Item Request
.get(path)
.query({
    appid: Application.CSGO,
    currency: Currency.GBP,
    market_hash_name: 'FirstItem',
})
.reply(200, {
    lowest_price: '£1.00',
    median_price: '£1.30',
    success: true,
    volume: '328',
});

const API = new Market({ id: Application.CSGO, currency: Currency.GBP });

test('One Item', async (t) => {
    const item = await API.getPrice('FirstItem');
    const should = {
        id: 'FirstItem',
        price: {
            code: 'GBP',
            lowest: 1,
            median: 1.3,
            sign: '£',
            type: 'pound',
        },
        volume: 328,
    };
    t.deepEqual(item, should);
});
github node-steam / market-pricing / test / mock / item / notfound / single.ts View on Github external
.query({
    appid: Application.CSGO,
    currency: Currency.USD,
    market_hash_name: 'DoesNotExist500',
})
.reply(500, {success: false})
// Non-Existent Item With Status Code 404
.get(path)
.query({
    appid: Application.CSGO,
    currency: Currency.USD,
    market_hash_name: 'DoesNotExist404',
})
.reply(404, {success: false});

const API = new Market({ id: Application.CSGO, currency: Currency.USD });

test(`One Item That Doesn't Exist | 500`, async (t) => {
    const item = await t.throwsAsync(API.getPrice('DoesNotExist500'));
    t.deepEqual(item.message, 'Item Not Found! Status: 500');
});

test(`One Item That Doesn't Exist | 404`, async (t) => {
    const item = await t.throwsAsync(API.getPrice('DoesNotExist404'));
    t.deepEqual(item.message, 'Item Not Found! Status: 404');
});
github node-steam / market-pricing / test / mock / item / options / single.ts View on Github external
// First Valid Item Request
nock(base)
.get(path)
.query({
    appid: Application.CSGO,
    currency: Currency.USD,
    market_hash_name: 'FirstItem',
})
.reply(200, {
    lowest_price: '$1.00',
    median_price: '$1.30',
    success: true,
    volume: '328',
});

const API = new Market({ id: Application.CSGO, currency: Currency.EUR });

test('One Item', async (t) => {
    const item = await API.getPrice('FirstItem', { currency: Currency.USD });
    const should = {
        id: 'FirstItem',
        price: {
            code: 'USD',
            lowest: 1,
            median: 1.3,
            sign: '$',
            type: 'us-dollar',
        },
        volume: 328,
    };
    t.deepEqual(item, should);
});
github node-steam / market-pricing / test / mock / ratelimit / single.ts View on Github external
import {
    base,
    path,
} from 'test/settings';

// One Item Rate Limited Request
nock(base)
.get(path)
.query({
    appid: Application.CSGO,
    currency: Currency.USD,
    market_hash_name: 'TestRateLimitForOneItem',
})
.reply(429);

const API = new Market({ id: Application.CSGO, currency: Currency.USD });

test('Steam API Rate Limiting For One Item', async (t) => {
    const error = await t.throwsAsync(API.getPrice('TestRateLimitForOneItem'));
    t.is(error.message, 'Steam API Rate Limit Exceeded!');
});
github node-steam / market-pricing / test / mock / empty / single.ts View on Github external
path,
} from 'test/settings';

// First Valid Item Request
nock(base)
.get(path)
.query({
    appid: Application.CSGO,
    currency: Currency.USD,
    market_hash_name: 'FirstEmptyItem',
})
.reply(200, {
    success: true,
});

const API = new Market({ id: Application.CSGO, currency: Currency.USD });

test('One Empty Item', async (t) => {
    const exception: error.Exception = await t.throwsAsync(API.getPrice('FirstEmptyItem')) as any;
    t.is(exception.code, error.codes.ITEM_NO_DATA);
    t.is(exception.message, error.messages.ITEM_NO_DATA);
});
github comindware / core-ui / src / form / editors / impl / dateTime / views / DateView.js View on Github external
import { Handlebars, $ } from 'lib';
import template from '../templates/date.hbs';
import dropdown from 'dropdown';
import PanelView from './DatePanelView';
import InputView from './DateInputView';
import DateTimeService from '../../../services/DateTimeService';

export default Marionette.LayoutView.extend({
    initialize() {
        this.preserveTime = !!this.getOption('preserveTime'); // If false (default), drop time components on date change
        this.allowEmptyValue = this.getOption('allowEmptyValue');
        this.dateDisplayFormat = this.getOption('dateDisplayFormat');
        this.showTitle = this.getOption('showTitle');
    },

    template: Handlebars.compile(template),

    className: 'date-view',

    regions: {
        popoutRegion: '.js-popout-region'
    },

    ui: {
        initialValue: '.js-date-input'
    },

    events: {
        focus: '__showEditor',
        mousedown: '__showEditor'
    },
github comindware / core-ui / src / form / editors / impl / memberSelect / views / DefaultButtonView.js View on Github external
initialize(options) {
        this.enabled = options.enabled;
        this.reqres = options.reqres;
        this.options.template = Handlebars.compile(options.template || template);
    },
github comindware / core-ui / src / dropdown / views / WrapperView.js View on Github external
* Copyright: 2009-2016 Comindware®
 *       All Rights Reserved
 * Published under the MIT license
 */

import { Handlebars } from 'lib';
import { helpers } from 'utils';

export default Marionette.ItemView.extend({
    initialize(options) {
        helpers.ensureOption(options, 'view');

        this.regionManager = new Marionette.RegionManager();
    },

    template: Handlebars.compile(''),

    onShow() {
        this.regionManager.addRegion('viewRegion', { el: this.$el });
        this.regionManager.get('viewRegion').show(this.options.view);
    },

    onDestroy() {
        this.regionManager.destroy();
    }
});
github comindware / core-ui / src / form / editors / impl / reference / views / UserReferenceButtonView.js View on Github external
import { Handlebars } from 'lib';
import ReferenceButtonView from './ReferenceButtonView';
import template from '../templates/userReferenceButton.hbs';

export default ReferenceButtonView.extend({
    template: Handlebars.compile(template),

    className: 'popout-field-user',

    templateContext() {
        const value = this.model.get('value');
        return {
            text: this.options.getDisplayText(value)
        };
    },

    updateView() {
        if (this.model.get('enabled') && !this.model.get('readonly')) {
            this.ui.clearButton.show();
        } else if (this.model.get('readonly')) {
            this.ui.clearButton.hide();
        } else if (!this.model.get('enabled')) {
github comindware / core-ui / src / form / editors / impl / dateTime / views / DateInputView.js View on Github external
* Published under the MIT license
 */

import { Handlebars, moment } from 'lib';
import { helpers, dateHelpers } from 'utils';
import LocalizationService from '../../../../../services/LocalizationService';
import template from '../templates/dateInput.hbs';

export default Marionette.ItemView.extend({
    initialize(options) {
        helpers.ensureOption(options, 'timezoneOffset');
        helpers.ensureOption(options, 'allowEmptyValue');
        this.editDateFormat = dateHelpers.getDateEditFormat();
    },

    template: Handlebars.compile(template),

    className: 'date-view',

    ui: {
        dateInput: '.js-date-input'
    },

    modelEvents: {
        'change:value': 'updateDisplayValue',
        'change:readonly': '__onEnabledChange',
        'change:enabled': '__onEnabledChange'
    },

    events: {
        click: '__onClick',
        'focus @ui.dateInput': '__onFocus'

lib

Autocode standard library Node.js bindings

MIT
Latest version published 7 months ago

Package Health Score

64 / 100
Full package analysis