How to use the hoek.nextTick function in hoek

To help you get started, we’ve selected a few hoek 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 DefinitelyTyped / DefinitelyTyped / hoek / hoek-tests.ts View on Github external
let stack = Hoek.displayStack();
console.log(stack);

// callStack(slice)

let stack2 = Hoek.callStack();
console.log(stack2);

// nextTick(fn)

let myFn = () => {
    console.log('Do this later');
};

let nextFn = Hoek.nextTick(myFn);

nextFn();
console.log('Do this first');

// Results in:
//
// Do this first
// Do this later

// once(fn)

myFn = () => {
    console.log('Ran myFn');
};

let onceFn = Hoek.once(myFn);
github graalvm / graaljs / deps / npm / node_modules / request / node_modules / hawk / lib / server.js View on Github external
exports.authenticateMessage = function (host, port, message, authorization, credentialsFunc, options, callback) {

    callback = Hoek.nextTick(callback);

    // Default options

    options.nonceFunc = options.nonceFunc || internals.nonceFunc;
    options.timestampSkewSec = options.timestampSkewSec || 60;                                                  // 60 seconds

    // Application time

    const now = Utils.now(options.localtimeOffsetMsec);                       // Measure now before any other processing

    // Validate authorization

    if (!authorization.id ||
        !authorization.ts ||
        !authorization.nonce ||
        !authorization.hash ||
github blockstack / blockstack-browser / native / windows / BlockstackBrowser / Resources / corsproxy-https / node_modules / hapi / lib / server.js View on Github external
internals.Server.prototype.initialize = function (callback) {

    var self = this;

    Hoek.assert(callback, 'Missing start callback function');

    var errorCallback = Hoek.nextTick(callback);
    if (!this.connections.length) {
        return errorCallback(new Error('No connections to start'));
    }

    if (this._registring) {
        return errorCallback(new Error('Cannot start server before plugins finished registration'));
    }

    if (this._state !== 'stopped') {
        return errorCallback(new Error('Cannot initialize server while it is in ' + this._state + ' state'));
    }

    // Assert dependencies

    for (var i = 0, il = this._dependencies.length; i < il; ++i) {
        var dependency = this._dependencies[i];
github hapijs / hapi / lib / state.js View on Github external
internals.encode = function (value, options, callback) {

    callback = Hoek.nextTick(callback);

    // Encodings: 'base64json', 'base64', 'form', 'iron', 'none'

    if (value === undefined) {
        return callback(null, value);
    }

    if (!options.encoding ||
        options.encoding === 'none') {

        return callback(null, value);
    }

    if (options.encoding === 'iron') {
        Iron.seal(value, options.password, options.iron || Iron.defaults, function (err, sealed) {
github neuroanatomy / BrainBox / public / js / node_modules / request / node_modules / hawk / lib / server.js View on Github external
exports.authenticate = function (req, credentialsFunc, options, callback) {

    callback = Hoek.nextTick(callback);
    
    // Default options

    options.nonceFunc = options.nonceFunc || function (nonce, ts, nonceCallback) { return nonceCallback(); };   // No validation
    options.timestampSkewSec = options.timestampSkewSec || 60;                                                  // 60 seconds

    // Application time

    var now = Utils.now(options.localtimeOffsetMsec);                           // Measure now before any other processing

    // Convert node Http request object to a request configuration object

    var request = Utils.parseRequest(req, options);
    if (request instanceof Error) {
        return callback(Boom.badRequest(request.message));
    }
github wsmigielski / DiscordSpotifyBot / node_modules / hawk / lib / server.js View on Github external
exports.authenticateMessage = function (host, port, message, authorization, credentialsFunc, options, callback) {

    callback = Hoek.nextTick(callback);

    // Default options

    options.nonceFunc = options.nonceFunc || internals.nonceFunc;
    options.timestampSkewSec = options.timestampSkewSec || 60;                                                  // 60 seconds

    // Application time

    var now = Utils.now(options.localtimeOffsetMsec);                       // Measure now before any other processing

    // Validate authorization

    if (!authorization.id ||
        !authorization.ts ||
        !authorization.nonce ||
        !authorization.hash ||
github bigcommerce / stencil-cli / server / index.js View on Github external
module.exports = (options, callback) => {
    const config = manifest.get('/');
    const parsedSecureUrl = Url.parse(options.dotStencilFile.storeUrl); //The url to a secure page (prompted as login page)
    const parsedNormalUrl = Url.parse(options.dotStencilFile.normalStoreUrl); //The host url of the homepage;

    callback = Hoek.nextTick(callback);

    config.connections[0].port = options.dotStencilFile.port;
    config.plugins['./plugins/router/router.module'].storeUrl = parsedSecureUrl.protocol + '//' + parsedSecureUrl.host;
    config.plugins['./plugins/router/router.module'].normalStoreUrl = parsedNormalUrl.protocol + '//' + parsedNormalUrl.host;
    config.plugins['./plugins/router/router.module'].apiKey = options.dotStencilFile.apiKey;
    config.plugins['./plugins/router/router.module'].port = options.dotStencilFile.port;
    config.plugins['./plugins/router/router.module'].staplerUrl = options.dotStencilFile.staplerUrl;
    config.plugins['./plugins/renderer/renderer.module'].useCache = options.useCache;
    config.plugins['./plugins/renderer/renderer.module'].username = options.dotStencilFile.username;
    config.plugins['./plugins/renderer/renderer.module'].token = options.dotStencilFile.token;
    config.plugins['./plugins/renderer/renderer.module'].accessToken = options.dotStencilFile.accessToken;
    config.plugins['./plugins/renderer/renderer.module'].customLayouts = options.dotStencilFile.customLayouts;
    config.plugins['./plugins/renderer/renderer.module'].stencilEditorPort = options.stencilEditorPort;
    config.plugins['./plugins/renderer/renderer.module'].themePath = options.themePath;
    config.plugins['./plugins/theme-assets/theme-assets.module'].themePath = options.themePath;
github bigcommerce / stencil-cli / server / lib / assembler.js View on Github external
'components/common/forms/select',
            'components/common/forms/checkbox',
            'components/common/forms/selectortext',
            'components/common/forms/date',
            'components/common/forms/number',
            'components/common/forms/radio',
            'components/common/forms/multiline',

            'components/faceted-search/facets/hierarchy',
            'components/faceted-search/facets/multi',
            'components/faceted-search/facets/range',
            'components/faceted-search/facets/rating'
        ],
        configSetByHeader = false;

    callback = Hoek.nextTick(callback);

    if (request.headers['stencil-config']) {
        configSetByHeader = true;
        try {
            ret.config = JSON.parse(request.headers['stencil-config']);
        } catch (e) {
            return callback(e);
        }
    }

    Async.parallel([
        function(callback) {
            Async.each(_.union(options.templates, commonTemplates), resolvePartials, function (err) {
                var frontmatter,
                    frontmatterRegex = /---\n(?:.|\s)*?\n---\n/g,
                    frontmatterMatch,
github nlf / hapi-session / index.js View on Github external
Scheme.prototype.authenticate = function (request, callback) {
    var self = this;

    callback = Hoek.nextTick(callback);

    var validate = function () {
        var sessionId;

        if (!request.state.hasOwnProperty(self.settings.cookie)) {
            return unauthenticated(self.hapi.error.unauthorized());
        }

        sessionId = request.state[self.settings.cookie];
        if (typeof sessionId !== 'string') {
            return unauthenticated(self.hapi.error.unauthorized());
        }

        self.cache.get(sessionId, function (err, session) {
            if (!session) {
                return unauthenticated(self.hapi.error.unauthorized());
github hapijs / catbox / lib / memory.js View on Github external
internals.Connection.prototype.get = function (key, callback) {

    callback = Hoek.nextTick(callback);

    if (!this.cache) {
        return callback(new Error('Connection not started'));
    }

    var segment = this.cache[key.segment];
    if (!segment) {
        return callback(null, null);
    }

    var envelope = segment[key.id];
    if (!envelope) {
        return callback(null, null);
    }

    var value = null;