How to use dottie - 10 common examples

To help you get started, we’ve selected a few dottie 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 ozum / sequelize-pg-generator / node_modules / sequelize / lib / instance.js View on Github external
if (!options.raw && this._customSetters[key]) {
        this._customSetters[key].call(this, value, key);
      } else {
        // Check if we have included models, and if this key matches the include model names/aliases

        if (this.options && this.options.include && this.options.includeNames.indexOf(key) !== -1 && value) {
          // Pass it on to the include handler
          this._setInclude(key, value, options);
          return;
        } else {
          // Bunch of stuff we won't do when its raw
          if (!options.raw) {
            // If attribute is not in model definition, return
            if (!this._isAttribute(key)) {
              if (key.indexOf('.') > -1 && this.Model._isJsonAttribute(key.split('.')[0])) {
                Dottie.set(this.dataValues, key, value);
                this.changed(key, true);
              }
              return;
            }

            // If attempting to set primary key and primary key is already defined, return
            if (this.Model._hasPrimaryKeys && originalValue && this.Model._isPrimaryKey(key)) {
              return;
            }

            // If attempting to set read only attributes, return
            if (!this.isNewRecord && this.Model._hasReadOnlyAttributes && this.Model._isReadOnlyAttribute(key)) {
              return;
            }

            // Convert date fields to real date objects
github sequelize / sequelize / lib / instance.js View on Github external
} else {
      // Check if we have included models, and if this key matches the include model names/aliases

      if (this.$options && this.$options.include && this.$options.includeNames.indexOf(key) !== -1) {
        // Pass it on to the include handler
        this._setInclude(key, value, options);
        return this;
      } else {
        // Bunch of stuff we won't do when its raw
        if (!options.raw) {
          // If attribute is not in model definition, return
          if (!this._isAttribute(key)) {
            if (key.indexOf('.') > -1 && this.Model._isJsonAttribute(key.split('.')[0])) {
              var previousDottieValue = Dottie.get(this.dataValues, key);
              if (!_.isEqual(previousDottieValue, value)) {
                Dottie.set(this.dataValues, key, value);
                this.changed(key.split('.')[0], true);
              }
            }
            return this;
          }

          // If attempting to set primary key and primary key is already defined, return
          if (this.Model._hasPrimaryKeys && originalValue && this.Model._isPrimaryKey(key)) {
            return this;
          }

          // If attempting to set read only attributes, return
          if (!this.isNewRecord && this.Model._hasReadOnlyAttributes && this.Model._isReadOnlyAttribute(key)) {
            return this;
          }
github iotexproject / iotex-explorer / src / shared / wallet / unlock-by-private-key.tsx View on Github external
public handleInputChange = (e: React.FormEvent) => {
    const name: string = get(e, "target.name");
    const value = get(e, "target.value");
    // @ts-ignore
    this.setState({
      [name]: value
    });
  };
github ozum / sequelize-pg-generator / node_modules / sequelize / lib / dialects / abstract / query.js View on Github external
result = results.map(function(result) {
        var o = {};

        for (var key in result) {
          if (result.hasOwnProperty(key)) {
            o[key] = result[key];
          }
        }

        if (this.options.nest) {
          o = Dot.transform(o);
        }

        return o;
      }, this);
    // Queries with include
github dalinhuang99 / betify / node_modules / sequelize / lib / dialects / abstract / query.js View on Github external
result = results.map(result => {
        let o = {};

        for (const key in result) {
          if (result.hasOwnProperty(key)) {
            o[key] = result[key];
          }
        }

        if (this.options.nest) {
          o = Dot.transform(o);
        }

        return o;
      });
    // Queries with include
github sequelize / sequelize / lib / dialects / abstract / query.js View on Github external
result = results.map(result => {
        let o = {};

        for (const key in result) {
          if (Object.prototype.hasOwnProperty.call(result, key)) {
            o[key] = result[key];
          }
        }

        if (this.options.nest) {
          o = Dot.transform(o);
        }

        return o;
      });
    // Queries with include
github ozum / sequelize-pg-generator / node_modules / sequelize / lib / dialects / abstract / query-generator.js View on Github external
, outerBinding
        , comparatorMap
        , aliasMap
        , comparator = '='
        , field = options.field || options.model && options.model.rawAttributes && options.model.rawAttributes[key] || options.model && options.model.fieldRawAttributesMap && options.model.fieldRawAttributesMap[key]
        , fieldType = options.type || (field && field.type)
        , tmp;

      if (key && typeof key === 'string' && key.indexOf('.') !== -1 && options.model) {
        if (options.model.rawAttributes[key.split('.')[0]] && options.model.rawAttributes[key.split('.')[0]].type instanceof DataTypes.JSON) {
          field = options.model.rawAttributes[key.split('.')[0]];
          fieldType = field.type;
          tmp = value;
          value = {};

          Dottie.set(value, key.split('.').slice(1), tmp);
          key = key.split('.')[0];
        }
      }

      comparatorMap = {
        $eq: '=',
        $ne: '!=',
        $gte: '>=',
        $gt: '>',
        $lte: '<=',
        $lt: '<',
        $not: 'IS NOT',
        $is: 'IS',
        $like: 'LIKE',
        $notLike: 'NOT LIKE',
        $iLike: 'ILIKE',
github CleverStack / node-seed / lib / utils / magicModule.js View on Github external
listing.forEach(function(filePath) {
      var actualPath = path.join(folderPath, filePath)
        , stats      = fs.statSync(actualPath)
        , dotted
        , fullPath;

      dotted = folderPath.replace(appRoot, '').replace(modulesPath.replace(appRoot, ''), '').split(path.sep);
      if (dotted[dotted.length-1] === '') {
        dotted.pop();
      }
      dotted = dotted.slice(2, dotted.length).join('.');
      
      if (dottie.get(cache, dotted) === undefined) {
        dottie.set(cache, dotted, {});
      }

      if (stats.isFile()) {
        if ((filePath.match(/.+\.js$/g) !== null || filePath.match(/.+\.es6$/g) !== null) && filePath !== 'index.js' && filePath !== 'module.js') {
          filePath = filePath.replace('.js', '').replace('.es6', '');
          fullPath = [dotted, filePath].join('.');

          if (dottie.get(cache, fullPath) === undefined) {
            Object.defineProperty(dottie.get(cache, dotted), filePath, {
              get: function() {
                if (dottie.get(loaded, fullPath) === undefined) {
                  if (debug.enabled) {
                    debug('Loading %s into magic module from %s...', fullPath, actualPath);
                  }

                  dottie.set(loaded, fullPath, require(actualPath));
github LINKIWI / orion-web / src / app / react / containers / control-panel / data-source.js View on Github external
const DataSourceContainer = ({
  userDevices: { err, data = [] },
  user,
  timestamp,
  handleUserChange,
  handleDeviceChange,
  handleTimestampStartChange,
  handleTimestampEndChange,
}) => {
  const users = data.map((entry) => entry.user);
  const devices = dottie.get(data.find((entry) => entry.user === user), 'devices', []);

  return (
    <div>
      {err &amp;&amp; (
        
          
        
      )}

      
        </div>
github contentful-labs / gitify-dependencies / lib / gitify.js View on Github external
function processDependencies (dir, shrinkwrapFile, shrinkwrapPath) {
  let shrinkwrapContent = require(shrinkwrapFile);
  let dependenciesPath  = _.compact(_.flatten([shrinkwrapPath].concat('dependencies')));
  let dependencies      = dottie.get(shrinkwrapContent, dependenciesPath);
  let depNames          = Object.keys(dependencies || {});

  return Bluebird.mapSeries(depNames, function (depName) {
    let depDir            = dir + '/node_modules/' + depName;
    let depShrinkwrapPath = dependenciesPath.concat(depName);

    return processDependency(depDir, shrinkwrapFile, depShrinkwrapPath, depName);
  });
}

dottie

Fast and safe nested object access and manipulation in JavaScript

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis

Popular dottie functions

Similar packages