How to use object-path

Comprehensive object-path code examples:

How to use object-path.del:

99
100
101
102
103
104
105
106
107
108

resourcesToDelete.forEach(resource => {
  delete doc.Resources[resource];
});
resourceAttributeToDelete.forEach(path => {
  ObjectPath.del(doc, path);
});

const outputsToDelete = [];
Object.keys(doc.Outputs).forEach(output => {

How to use object-path.has:

128
129
130
131
132
133
134
135
136
137
	if (subscription.variableName === '') {
		return
	}
	if (subscription.subpath === '') {
		this.setVariable(subscription.variableName, typeof msgValue === 'object' ? JSON.stringify(msgValue) : msgValue)
	} else if (typeof msgValue === 'object' && objectPath.has(msgValue, subscription.subpath)) {
		let value = objectPath.get(msgValue, subscription.subpath)
		this.setVariable(subscription.variableName, typeof value === 'object' ? JSON.stringify(value) : value)
	}
})

How to use object-path.set:

129
130
131
132
133
134
135
136
137
138
      answer = (yield reporter.question(question)) || def;
    }
  }

  if (answer) {
    objectPath.set(pkg, manifestKey, answer);
  }
}

// save answers

How to use object-path.get:

228
229
230
231
232
233
234
235
236
237
if (decodedObjectName && objectPath.get(req, `${decodedObjectName}.role`)) {
  return objectPath.get(req, `${decodedObjectName}.role`);
}

if (req.decoded && req.decoded.role) {
  return objectPath.get(req, 'decoded.role');
}

if (req.session && req.session.role) {
  return objectPath.get(req, 'session.role');