本文整理汇总了TypeScript中lodash.unset函数的典型用法代码示例。如果您正苦于以下问题:TypeScript unset函数的具体用法?TypeScript unset怎么用?TypeScript unset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unset函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: sanitizeOutputFields
export function sanitizeOutputFields(document: Object): Object {
const doc = _.clone(document);
_.unset(doc, '_id');
_.unset(doc, '_key');
_.unset(doc, '_rev');
return doc;
}
示例2: function
sails.router.bind(route, function (req: any, res: any, next: Function) {
let protocol: any = _.startsWith(swagger.host, 'http') ? '' : 'http://';
let targetUrlTemplate: any = protocol + swagger.host + ( swagger.basePath || '' ) + path;
let templateFn: any = _.template(targetUrlTemplate, {
interpolate: /{([\s\S]+?)}/g
});
let params: any = req.allParams();
let targetUrl: any = templateFn(params);
let headers: any = req.headers;
_.unset(headers, 'cookie');
_.unset(headers, 'host');
_.unset(headers, 'user-agent');
_.unset(headers, 'referer');
let reqOut: any = {
url: targetUrl,
method: vertex,
body: ( req.body || null ),
qs: req.transport != 'socket.io' ? req.query : req.body,
json: true,
headers: headers
};
let $request: any = sails.$request(req.session) || request;
$request(reqOut, function (err: Error, message: any, body: any): void {
console.log('*************************');
console.log('' + vertex + ' ' + targetUrl);
console.log('-------------------------');
console.dir(headers);
console.log('=========================');
console.dir(body);
if (params && body && !params.id && !_.isArray(body)) {
body.id = body.id || uuid.v4();
body = [body];
}
else if (_.isArray(body)) {
_.each(body, function (item: any) {
item.id = item.id || uuid.v4();
});
}
if (!err) {
res
.status(message.statusCode)
.send(body);
}
else {
res.serverError(err);
}
})
})
示例3: it
it('should ignore ignoreProperties', () => {
// set options (ignore Properties)
eas.options = {
ignoreProperties: ['data.ignored'], ignoreSubProperties: []
};
_.set(storage.testSnapObj, 'data.ignored', 'aVal');
_.set(storage.testSnapObj2, 'data.ignored', 'aDifferentVal');
// actual testing
let result = eas.deepDiff(storage.testSnapObj, storage.testSnapObj2);
expect(result).to.eql(storage.testDiffObj);
// reset options to emtpy object
eas.options = {};
_.unset(storage.testSnapObj, 'data.ignored');
_.unset(storage.testSnapObj2, 'data.ignored');
});
示例4:
let unsetIgnoredSubProperties = (obj: any) => {
if (_.isPlainObject(obj)) {
for (var prop of this.options.ignoreSubProperties) {
_.unset(obj, prop);
}
}
};
示例5:
collections[collection].insert(doc, (err, newdoc) => {
// docs
if (err) {
throw err;
} else {
_.unset(newdoc, '_id');
return newdoc;
}
});
示例6: makeActiveProject
export function makeActiveProject(projectDir: string, newActive: string): void {
const activeProjects = configstore.get("activeProjects") || {};
if (newActive) {
activeProjects[projectDir] = newActive;
} else {
_.unset(activeProjects, projectDir);
}
configstore.set("activeProjects", activeProjects);
}
示例7: resolve
collections[collection].find(q).exec((err, docs) => {
if (docs) {
const l = docs.length;
for (let i = 0; i < l; i += 1) {
_.unset(docs[i], '_id');
}
resolve(docs);
} else if (err) {
reject(err);
}
});
示例8: unsetConfigValue
export function unsetConfigValue(ctx: ConfigContext & { property: string; }): void {
const conf = getConfig(ctx);
if (ctx.global) { // Global config is flattened
conf.unset(ctx.property);
} else {
const { c } = conf;
lodash.unset(c, ctx.property);
conf.c = c;
}
}
示例9: return
return (control: AbstractControl): { [key: string]: any } => {
const ctrl1 = control.get(path1);
const ctrl2 = control.get(path2);
if (ctrl1.value !== ctrl2.value) {
ctrl2.setErrors({ match: true });
} else {
const hasError = ctrl2.hasError('match');
if (hasError) {
// Remove the 'match' error. If no more errors exists, then set
// the error value to 'null', otherwise the field is still marked
// as invalid.
const errors = ctrl2.errors;
_.unset(errors, 'match');
ctrl2.setErrors(_.isEmpty(_.keys(errors)) ? null : errors);
}
}
return null;
};
示例10: setInstanceProps
/**
* 设置实例的 props 属性
*/
@Action
public setInstanceProps(instanceKey: string, key: string, value: any) {
const instance = this.store.instances.get(instanceKey);
const instanceClass = this.applicationStore.componentClasses.get(instance.gaeaKey);
const defaultProps = this.applicationAction.getDefaultPropsByInstance(instance);
// 如果和 defaultProps 相同,就把字段置空
if (value === _.get(defaultProps, key)) {
_.unset(instance.data.props, key);
// 强制刷新组件
this.eventAction.emit(`${this.eventStore.instanceUpdate}.${instanceKey}`);
return;
}
_.set(instance.data, `props.${key}`, value);
// 强制刷新组件
this.eventAction.emit(`${this.eventStore.instanceUpdate}.${instanceKey}`);
}