Codota Logo For Javascript
LoDashStatic.toInteger
Code IndexAdd Codota to your IDE (free)

How to use
toInteger
function
in
LoDashStatic

Best JavaScript code snippets using lodash.LoDashStatic.toInteger(Showing top 15 results out of 315)

origin: lando/lando

// Helper to set caches
const setCaches = (options, lando) => {
 // Get the github user
 github.authenticate({type: 'token', token: options['github-auth']});
 return github.users.get({})
 .then(user => {
  // Reset this apps metacache
  const metaData = lando.cache.get(`${options.name}.meta.cache`) || {};
  lando.cache.set(`${options.name}.meta.cache`, _.merge({}, metaData, {email: user.data.email}), {persist: true});
  // Reset github tokens
  const tokens = lando.cache.get(githubTokenCache) || [];
  const cache = {token: options['github-auth'], user: user.data.login, date: _.toInteger(_.now() / 1000)};
  lando.cache.set(githubTokenCache, sortTokens(tokens, [cache]), {persist: true});
 });
}
origin: lando/lando

api.getAccountInfo().then(me => {
   // Get the project
   const project = _.find(me.projects, {name: options['platformsh-site']});
   // Or error if there is no spoon
   if (_.isEmpty(project)) throw Error(`${options['platformsh-site']} does not appear to be a platform.sh site!`);

   // This is a good token, lets update our cache
   const cache = {token: options['platformsh-auth'], email: me.mail, date: _.toInteger(_.now() / 1000)};
   // Update lando's store of platformsh machine tokens
   const tokens = lando.cache.get(platformshTokenCache) || [];
   lando.cache.set(platformshTokenCache, utils.sortTokens(tokens, [cache]), {persist: true});
   // Update app metdata
   const metaData = lando.cache.get(`${options.name}.meta.cache`);
   lando.cache.set(`${options.name}.meta.cache`, _.merge({}, metaData, cache), {persist: true});

   return {config: {
    id: _.get(project, 'id', 'lando'),
   }};
  })
origin: lando/lando

// Helper to populate defaults
const getDefaults = (task, options) => {
 // Set interactive options
 _.forEach(['code', 'database', 'files'], name => {
  task.options[name].interactive.choices = answers => {
   return utils.getPantheonInquirerEnvs(
   answers.auth,
   options.id,
   [],
   options._app.log);
  };
  task.options[name].interactive.default = options.env;
 });

 // Get the framework flavor
 const flavor = frameworkType(options.framework);
 // Set envvars
 task.env = {
  LANDO_DB_PULL_COMMAND: buildDbPullCommand(options),
  LANDO_DB_USER_TABLE: flavor === 'pressy' ? 'wp_users' : 'users',
  LANDO_LEIA: _.toInteger(options._app._config.leia),
 };

 return task;
}
origin: lando/lando

/*
   * This event is intended to make sure we reset the active token and cache when it is passed in
   * via the lando pull or lando push commands
   */
  _.forEach(['pull', 'push'], command => {
   app.events.on(`post-${command}`, (config, answers) => {
    // Only run if answer.auth is set, this allows these commands to all be
    // overriden without causing a failure here
    if (answers.auth) {
     const api = new PlatformshApiClient({api_token: answers.auth});
     return api.getAccountInfo().then(me => {
      // This is a good token, lets update our cache
      const cache = {token: answers.auth, email: me.mail, date: _.toInteger(_.now() / 1000)};
      // Update lando's store of platformsh machine tokens
      const tokens = lando.cache.get(app.platformsh.tokenCache) || [];
      lando.cache.set(app.platformsh.tokenCache, utils.sortTokens(tokens, [cache]), {persist: true});
      // Update app metdata
      const metaData = lando.cache.get(`${app.name}.meta.cache`);
      lando.cache.set(`${app.name}.meta.cache`, _.merge({}, metaData, cache), {persist: true});
     });
    }
   });
  });
origin: lando/lando

api.auth().then(() => Promise.all([api.getSites(), api.getUser()]))
  // Parse the dataz and set the things
  .then(results => {
   // Get our site and email
   const site = _.head(_.filter(results[0], site => site.name === options['pantheon-site']));
   const user = results[1];

   // Error if site doesn't exist
   if (_.isEmpty(site)) throw Error(`${site} does not appear to be a Pantheon site!`);

   // This is a good token, lets update our cache
   const cache = {token: options['pantheon-auth'], email: user.email, date: _.toInteger(_.now() / 1000)};

   // Update lando's store of pantheon machine tokens
   const tokens = lando.cache.get(pantheonTokenCache) || [];
   lando.cache.set(pantheonTokenCache, utils.sortTokens(tokens, [cache]), {persist: true});
   // Update app metdata
   const metaData = lando.cache.get(`${options.name}.meta.cache`);
   lando.cache.set(`${options.name}.meta.cache`, _.merge({}, metaData, cache), {persist: true});

   // Add some stuff to our landofile
   return {config: {
    framework: _.get(site, 'framework', 'drupal'),
    site: _.get(site, 'name', options.name),
    id: _.get(site, 'id', 'lando'),
   }};
  })
origin: lando/lando

};
_.forEach(logLevels, (word, num) => {
 const log = new Log({logLevelConsole: _.toInteger(num)});
 log.transports.console.should.have.property('level', word);
});
origin: lando/lando

// Set the app caches, validate tokens and update token cache
  _.forEach(['pull', 'push', 'switch'], command => {
   app.events.on(`post-${command}`, (config, answers) => {
    // Only run if answer.auth is set, this allows these commands to all be
    // overriden without causing a failure here
    if (answers.auth) {
     const api = new PantheonApiClient(answers.auth, app.log);
     return api.auth().then(() => api.getUser().then(results => {
      const cache = {token: answers.auth, email: results.email, date: _.toInteger(_.now() / 1000)};
      // Reset this apps metacache
      lando.cache.set(app.metaCache, _.merge({}, app.meta, cache), {persist: true});
      // Set lando's store of pantheon machine tokens
      lando.cache.set(app.pantheonTokenCache, utils.sortTokens(app.pantheonTokens, [cache]), {persist: true});
      // Wipe out the apps tooling cache to reset with the new MT
      lando.cache.remove(`${app.name}.tooling.cache`);
     }))
     // Throw some sort of error
     // NOTE: this provides some error handling when we are completely non-interactive
     .catch(err => {
      throw (_.has(err, 'response.data')) ? new Error(err.response.data) : err;
     });
    }
   });
  });
origin: lando/lando

const uid = _.toInteger(_.get(_config, 'uid', 1000));
const gid = _.toInteger(_.get(_config, 'gid', 1000));
origin: lando/lando

  let code = 200;
  if (_.includes(last, ':')) {
   if (_.toInteger(last.split(':')[1]) === counter[url]) code = 200;
   else code = last.split(':')[0];
  } else {
   code = isFinite(_.last(url.split('.'))) ? _.last(url.split('.')) : 200;
  return (_.startsWith(code, 2)) ? Promise.resolve() : Promise.reject({response: {status: _.toInteger(code)}});
 },
}));
origin: karan-darji/node-sample

// Faking  processing time
      setTimeout(() => {
        post = _.find(posts, ['id', _.toInteger(postId)]);
        if(_.isNull(post)) {
          throw new Error({'success': false})
        }
        resolve({'success': true, 'data': post})
      }, 2000);
origin: Ribhnux/piranhax

// set quantity of item
  /**
   * Set quantity of CartItem
   * @param {number} qty represents Quantity of an Item
   */
  Quantity(qty) {
    qty = _.toInteger(qty)

    // allow to clear an item for cart
    if (qty < 0) {
      qty = 0
    }

    // set this data to CartItem
    this._quantity = qty
  }
origin: swestmoreland/scormcloud-api-wrapper

this._request(url, function (error, json) {

    if (error) return callback(error, json);

    let data = {
      "id":               json.rsp.course.id,
      "title":            json.rsp.course.title,
      "versions":         _.flatten(_.toArray(json.rsp.course.versions[1])),
      "registrations":    _.toInteger(json.rsp.course.registrations),
      "size":             _.toInteger(json.rsp.course.size),
      "tags":             _.flatten(_.toArray(json.rsp.course.tags)),
      "learningStandard": json.rsp.course.learningStandard,
      "createDate":       json.rsp.course.createDate
    }

    return callback(error, data);

  });
origin: swestmoreland/scormcloud-api-wrapper

var getCourseAttributeValue = function (name, value) {

  switch (_.get(COURSE_ATTRIBUTES, name)) {
    case "boolean":
      return _.lowerCase(value) === 'true' ? true : false;
    case "number":
      return _.toNumber(value);
    case "integer":
      return _.toInteger(value);
    // Value is a string by default.
    default:
      return value;
  }

}
origin: swestmoreland/scormcloud-api-wrapper

this._request(url, function (error, json) {

    if (error) return callback(error, json);

    let data = [];
    let courseList = toArray(json.rsp.courselist.course);

    courseList.forEach(function (course) {
      data.push({
        "id":               course.id,
        "title":            course.title,
        "registrations":    _.toInteger(course.registrations),
        "size":             _.toInteger(course.size),
        "tags":             _.flatten(_.toArray(course.tags)),
        "learningStandard": course.learningStandard,
        "createDate":       course.createDate
      });
    });

    return callback(error, data);

  });
origin: swestmoreland/scormcloud-api-wrapper

// See https://www.npmjs.com/package/request
  request.post(requestOptions, function (error, response, body) {

    if (error) return callback(error);

    // See https://www.npmjs.com/package/xml2js
    parseString(body, { explicitArray: false, mergeAttrs: true }, function (err, json) {
      if (err) throw err;

      if (VERBOSE) {
        console.log(body);
        console.log(util.inspect(json, false, null));
      }

      let error;
      if (json.rsp.stat === 'fail') {
        error = new Error(json.rsp.err.msg);
        json = { "error": { "code": _.toInteger(json.rsp.err.code), "message": json.rsp.err.msg } };
      }

      callback(error, json);
    });

  });
lodash(npm)LoDashStatictoInteger

JSDoc

Converts `value` to an integer.
**Note:** This function is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger).

Most used lodash functions

  • LoDashStatic.map
    Creates an array of values by running each element in collection through iteratee. The iteratee is
  • LoDashStatic.isEmpty
    Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string
  • LoDashStatic.forEach
    Iterates over elements of collection invoking iteratee for each element. The iteratee is invoked wit
  • LoDashStatic.find
    Iterates over elements of collection, returning the first element predicate returns truthy for.
  • LoDashStatic.pick
    Creates an object composed of the picked `object` properties.
  • LoDashStatic.get,
  • LoDashStatic.isArray,
  • LoDashStatic.filter,
  • LoDashStatic.merge,
  • LoDashStatic.isString,
  • LoDashStatic.isFunction,
  • LoDashStatic.assign,
  • LoDashStatic.extend,
  • LoDashStatic.includes,
  • LoDashStatic.keys,
  • LoDashStatic.cloneDeep,
  • LoDashStatic.uniq,
  • LoDashStatic.isObject,
  • LoDashStatic.omit

Popular in JavaScript

  • axios
    Promise based HTTP client for the browser and node.js
  • commander
    the complete solution for node.js command-line programs
  • minimist
    parse argument options
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • colors
    get colors in your node.js console
  • mkdirp
    Recursively mkdir, like `mkdir -p`
  • handlebars
    Handlebars provides the power necessary to let you build semantic templates effectively with no frustration
  • yargs
    yargs the modern, pirate-themed, successor to optimist.
  • fs-extra
    fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • Top plugins for WebStorm
    The challenge is finding the best plugins for JavaScript development on Intellij IDEs. Who wants to sit there and go over hundreds of plugins to pick the best?
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJavascript Code Index
Get Codota for your IDE now