How to use the vow.defer function in vow

To help you get started, we’ve selected a few vow 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 bem-site / bem-forum / server / services / orm.js View on Github external
ORM.prototype.getIssues = function (options) {
    options.page = options.page || DEFAULT.page;
    options.limit = options.per_page || DEFAULT.limit;

    var def = vow.defer();
    ORM.models.issue.find().paginate(options).exec(function(err, models) {
        err ? def.reject() : def.resolve(models);
    });
    return def.promise();
};
github bem-archive / bem-site-engine / src / blocks / server.blocks / provider / _type / provider_type_disk.node.js View on Github external
load: function (options) {
            logger.debug('read file %s from yandex disk', options.path);

            var def = vow.defer();
            disk.readFile(options.path, 'utf8', function (err, content) {
                if (err || !content) {
                    def.reject(err);
                }
                def.resolve(options.archive ? util.unzip(content) : content);
            });
            return def.promise();
        },
github bem-archive / bem-site-engine / src / data / providers / provider-ya-disk.js View on Github external
load: function (options) {
        logger.debug(util.format('load file from %s', options.path), module);
        var def = vow.defer();
        this.disk.readFile(options.path, 'utf8', function (err, content) {
            (err || !content) ? def.reject(err) : def.resolve(content);
        });
        return def.promise();
    },
github bem-archive / bem-site-engine / src / modules / data / providers / github-api.js View on Github external
getContent: function(options) {
        var def = vow.defer(),
            repository = options.repository,
            git = repository.type === 'private' ? gitPrivate : gitPublic;

        git.repos.getContent(repository, function(err, res) {
            if (err || !res) {
                def.reject({res: null, repo: repository});
            }else {
                def.resolve({res: res, repo: repository});
            }
        });
        return def.promise();
    }
};
github bem-archive / bem-site-engine / src / scripts / data_compiler / tasks / get_sitemap.js View on Github external
run: function(modelPath) {
        logger.info(MSG.INFO.START);

        var def = vow.defer();

        try {
            def.resolve(require(modelPath).get());
            logger.info(MSG.INFO.SUCCESS);
        }catch(err) {
            def.reject(err.message);
            logger.error(MSG.ERROR);
        }
        return def.promise();
    }
};

vow

DOM Promise and Promises/A+ implementation for Node.js and browsers

MIT
Latest version published 5 years ago

Package Health Score

53 / 100
Full package analysis

Popular vow functions