How to use the unset function from lodash

Find comprehensive JavaScript lodash.unset code examples handpicked from public code repositorys.

102
103
104
105
106
107
108
109
110
      this.options.verbose &&
        this.serverless.cli.log(
          `Skipping peers dependency ${key} for dependency ${module.external} because it's optional`
        );

      _.unset(peerDependencies, key);
    }
  });
}
fork icon408
star icon0
watch icon1

11
12
13
14
15
16
17
18
19
20
21
22
    if (_.isArray(parent)) {
      return _.pullAt(parent, leavePath);
    }
  }


  return _.unset(object, path);
};


exports.assignWithSet = (object, ...sources) => {
  while (sources.length) {
fork icon59
star icon212
watch icon8

116
117
118
119
120
121
122
123
124
125
  })

  _.set(config, 'frontend.apiServerUrl', config.apiServerUrl)
  _.set(config, 'frontend.clusterIdentity', config.clusterIdentity)
  if (!config.gitHub && _.has(config, 'frontend.ticket')) {
    _.unset(config, 'frontend.ticket')
  }

  return config
},
fork icon88
star icon199
watch icon22

+ 2 other calls in file

415
416
417
418
419
420
421
422
423
424
module.exports.unionWith           = _.unionWith;
module.exports.uniq                = _.uniq;
module.exports.uniqBy              = _.uniqBy;
module.exports.uniqWith            = _.uniqWith;
module.exports.uniqueId            = _.uniqueId;
module.exports.unset               = _.unset;
module.exports.unsplat             = _.unsplat;
module.exports.unsplatl            = _.unsplatl;
module.exports.unsplatr            = _.unsplatr;
module.exports.unzip               = _.unzip;
fork icon19
star icon122
watch icon0

+ 92 other calls in file

800
801
802
803
804
805
806
807
808
809
  if (!currentUser.isMachine && !_hasAdminRole) {
    result = _.each(result, (val) => _.unset(val, "billing"));
    const ids = await helper.listChallengesByMember(currentUser.userId);
    result = _.each(result, (val) => {
      if (!_.includes(ids, val.id)) {
        _.unset(val, "privateDescription");
      }
    });
  }
} else {
fork icon45
star icon17
watch icon0

+ 16 other calls in file

1520
1521
1522
1523
1524
1525
1526
1527
1528
  _.set(data, "billing.markup", markup || 0);
}

// Make sure the user cannot change the direct project ID
if (data.legacy && data.legacy.directProjectId) {
  _.unset(data, "legacy.directProjectId", directProjectId);
}

/* BEGIN self-service stuffs */
fork icon44
star icon17
watch icon25

+ 17 other calls in file

1520
1521
1522
1523
1524
1525
1526
1527
1528
  _.set(data, "billing.markup", markup || 0);
}

// Make sure the user cannot change the direct project ID
if (data.legacy && data.legacy.directProjectId) {
  _.unset(data, "legacy.directProjectId");
}

/* BEGIN self-service stuffs */
fork icon44
star icon17
watch icon25

+ 89 other calls in file

721
722
723
724
725
726
727
728
729
730
731
732
const transform = _.transform({ 'a': 1, 'b': 2, 'c': 1 }, (result, value, key) => {
    (result[value] || (result[value] = [])).push(key);
    }, {});
console.log(transform); // => { '1': ['a', 'c'], '2': ['b'] }


const unset = _.unset({ 'a': [{ 'b': { 'c': 7 } }] }, 'a[0].b.c');
console.log(unset); // => true


const update = _.update({ 'a': [{ 'b': { 'c': 3 } }] }, 'a[0].b.c', n => n * n);
console.log(update); // => { 'a': [{ 'b': { 'c': 9 } }] }
fork icon0
star icon4
watch icon0

+ 15 other calls in file

78
79
80
81
82
83
84
85
86
87
const servicePath = path.join('my', 'servicePath');
const rspackOutputPath = path.join('rspack', 'output', 'path');

_.set(serverless, 'config.servicePath', servicePath);
_.set(module, 'rspackOutputPath', rspackOutputPath);
_.unset(module, 'keepOutputDirectory');

return expect(prepareRun())
  .resolves.toBeUndefined()
  .then(() =>
fork icon0
star icon1
watch icon0

85
86
87
88
89
90
91
92
93
94
});

describe('with service packaging', () => {
  beforeEach(() => {
    // Setup behavior for service packaging
    _.unset(module, 'entryFunctions');
    _.set(serverless.service, 'package.individually', false);
  });

  it('should package', () => {
fork icon0
star icon1
watch icon0

+ 2 other calls in file

16
17
18
19
20
21
22
23
24
25

_.forIn(newR, (v, k) => {
  if (k === 'label') return
  if (k === 'protected') return
  if (k === 'values') return
  if (k === 'name') return _.unset(newR, k)


  newR.values.push({
    field: k,
fork icon0
star icon0
watch icon1

+ 7 other calls in file

666
667
668
669
670
671
672
673
674
675
  for (const transaction of this.existingData.transactions) {
    if (!this.shouldOnlyRemoveScriptObjects || isCreatedBySeedScript(transaction)) {
      await stelace.transactions.createTransition(transaction.id, { name: 'cancel', data: { cancellationReason: 'forceCancel' } })

      const alias = getObjectAlias(transaction)
      unset(this.referencedData, `transactions.${alias}`)
      log(`cancelled ${transaction.id}`)
    }
  }
}
fork icon0
star icon0
watch icon1

+ 3 other calls in file

110
111
112
113
114
115
116
117
118
119
  return Object.freeze(this._rawData.userEnteredFormat[param]);
}

_setFormatParam(param, newVal) {
  if (_.isEqual(newVal, _.get(this._rawData, `userEnteredFormat.${param}`))) {
    _.unset(this._draftData, `userEnteredFormat.${param}`);
  } else {
    _.set(this._draftData, `userEnteredFormat.${param}`, newVal);
    this._draftData.clearFormat = false;
  }
fork icon0
star icon0
watch icon1

+ 3 other calls in file

Other functions in lodash

Sorted by popularity

function icon

lodash.get is the most popular function in lodash (7670 examples)