How to use the mout.object function in mout

To help you get started, we’ve selected a few mout 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 hw2-archive / upt / test / core / packageRepository.js View on Github external
beforeEach(function (next) {
        var PackageRepository;
        var config;
        var logger = new Logger();

        // Config
        config = mout.object.deepMixIn({}, defaultConfig, {
            storage: {
                packages: packagesCacheDir,
                registry: registryCacheDir
            }
        });

        // Mock the resolver factory to always return a resolver for the test package
        function resolverFactory(decEndpoint, _config, _logger, _registryClient) {
            expect(_config).to.eql(config);
            expect(_logger).to.be.an(Logger);
            expect(_registryClient).to.be.an(RegistryClient);

            decEndpoint = mout.object.deepMixIn({}, decEndpoint);
            decEndpoint.source = mockSource;

            resolver = new resolvers.GitRemote(decEndpoint, _config, _logger);
github ippontech / tatami / web / node_modules / bower / lib / commands / uninstall.js View on Github external
.spread(function (tree, flattened) {
        var nodes = [];
        var dependantsCounter = {};

        // Grab the nodes of each specified name
        mout.object.forOwn(flattened, function (node) {
            if (names.indexOf(node.endpoint.name) !== -1) {
                nodes.push(node);
            }
        });

        // Walk the down the tree, gathering dependants of the packages
        project.walkTree(tree, function (node, nodeName) {
            if (names.indexOf(nodeName) !== -1) {
                dependantsCounter[nodeName] = dependantsCounter[nodeName] || 0;
                dependantsCounter[nodeName] += node.nrDependants;
            }
        }, true);


        // Filter out those that have no dependants
        nodes = nodes.filter(function (node) {
github ippontech / tatami / web / node_modules / bower / lib / core / Project.js View on Github external
Project.prototype._bootstrap = function (targets, resolved, incompatibles) {
    var installed = mout.object.map(this._installed, function (decEndpoint) {
        return decEndpoint.pkgMeta;
    });

    this._json.resolutions = this._json.resolutions || {};

    // Configure the manager and kick in the resolve process
    return this._manager
    .configure({
        targets: targets,
        resolved: resolved,
        incompatibles: incompatibles,
        resolutions: this._json.resolutions,
        installed: installed,
        forceLatest: this._options.forceLatest
    })
    .resolve()
github hw2-archive / upt / src / lib / core / resolvers / FsResolver.js View on Github external
this._source = path.resolve(this._config.cwd, this._source);

    // If target was specified, simply reject the promise
    if (this._target !== '*') {
        throw createError('File system sources can\'t resolve targets', 'ENORESTARGET');
    }

    // If the name was guessed
    if (this._guessedName) {
        // Remove extension
        this._name = this._name.substr(0, this._name.length - path.extname(this._name).length);
    }
}

util.inherits(FsResolver, Resolver);
mout.object.mixIn(FsResolver, Resolver);

// -----------------

FsResolver.isTargetable = function () {
    return false;
};

// TODO: Should we store latest mtimes in the resolution and compare?
//       This would be beneficial when copying big files/folders

// TODO: There's room for improvement by using streams if the source
//       is an archive file, by piping read stream to the zip extractor
//       This will likely increase the complexity of code but might worth it
FsResolver.prototype._resolve = function () {
    return this._createTempDir()
            .then(this._copy.bind(this))
github OrgCurrent / Android / node / bower / lib / commands / list.js View on Github external
function paths(flattened) {
    var ret = {};

    mout.object.forOwn(flattened, function (pkg, name) {
        var main;

        if (pkg.missing) {
            return;
        }

        main = pkg.pkgMeta.main;

        // If no main was specified, fallback to canonical dir
        if (!main) {
            ret[name] = pkg.canonicalDir;
            return;
        }

        // Normalize main
        if (typeof main === 'string') {
github irods-contrib / irods-cloud-browser / irods-cloud-frontend / node_modules / bower / lib / core / Manager.js View on Github external
Manager.prototype._onFetchError = function (decEndpoint, err) {
    var name = decEndpoint.name;

    err.data = err.data || {};
    err.data.endpoint = mout.object.pick(decEndpoint, ['name', 'source', 'target']);

    // Remove from being fetched list
    mout.array.remove(this._fetching[name], decEndpoint);
    this._nrFetching--;

    // Add to the failed list
    this._failed[name] = this._failed[name] || [];
    this._failed[name].push(err);
    delete decEndpoint.promise;

    // Make the whole process to fail fast
    this._failFast();

    // If there are no more packages being fetched,
    // finish the resolve process (with an error)
    if (this._nrFetching <= 0) {
github OrgCurrent / Android / node / bower / lib / commands / init.js View on Github external
function saveJson(project, logger, json) {
    // Cleanup empty props (null values, empty strings, objects and arrays)
    mout.object.forOwn(json, function (value, key) {
        if (value == null || mout.lang.isEmpty(value)) {
            delete json[key];
        }
    });

    logger.info('json', 'Generated json', { json: json });

    // Confirm the json with the user
    return Q.nfcall(logger.prompt.bind(logger), {
        type: 'confirm',
        message: 'Looks good?',
        default: true
    })
    .then(function (good) {
        if (!good) {
            return null;
github bower / bower / lib / renderers / StandardRenderer.js View on Github external
StandardRenderer.prototype._tree2archy = function(node) {
    var dependencies = mout.object.values(node.dependencies);
    var version = !node.missing
        ? node.pkgMeta._release || node.pkgMeta.version
        : null;
    var label = node.endpoint.name + (version ? '#' + version : '');
    var update;

    if (node.root) {
        label += ' ' + node.canonicalDir;
    }

    // State labels
    if (node.missing) {
        label += chalk.red(' not installed');
        return label;
    }
github joeattardi / tailstreamer / node_modules / grunt-bower-task / node_modules / bower / lib / commands / info.js View on Github external
.spread(function (canonicalDir, pkgMeta) {
        pkgMeta = mout.object.filter(pkgMeta, function (value, key) {
            return key.charAt(0) !== '_';
        });

        // Retrieve specific property
        if (property) {
            pkgMeta = mout.object.get(pkgMeta, property);
        }

        return pkgMeta;
    });
}
github OrgCurrent / Android / node / bower / lib / index.js View on Github external
function expandNames(obj, prefix, stack) {
    prefix = prefix || '';
    stack = stack || [];

    mout.object.forOwn(obj, function (value, name) {
        name = prefix + name;

        stack.push(name);

        if (typeof value === 'object' && !value.line) {
            expandNames(value, name + ' ', stack);
        }
    });

    return stack;
}