本文整理匯總了TypeScript中underscore.pick函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript pick函數的具體用法?TypeScript pick怎麽用?TypeScript pick使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了pick函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: reset
reset() {
const svgNode = this.scope.svg.node();
const mx = d3.mouse(svgNode)[0];
const my = d3.mouse(svgNode)[1];
const t = d3.zoomIdentity.translate(0, 0).scale(1);
this.scope.svg.call(this.scope.plotZoom.zoomObj.transform, t);
const lMargin = this.scope.layout.leftLayoutMargin;
const bMargin = this.scope.layout.bottomLayoutMargin;
const H = plotUtils.safeHeight(this.scope.jqsvg);
if (mx < lMargin && my < H - bMargin) {
_.extend(this.focus, _.pick(this.defaultFocus, "yl", "yr", "yspan", "yl_r", "yr_r", "yspan_r"));
} else if (my > H - bMargin && mx > lMargin) {
_.extend(this.focus, _.pick(this.defaultFocus, "xl", "xr", "xspan"));
} else {
_.extend(this.focus, this.defaultFocus);
}
this.fix(this.focus);
this.scope.plotRange.calcMapping(true);
this.scope.emitZoomLevelChange();
this.scope.update();
}
示例2: ArrayToTreeToTemplateToData
public static ArrayToTreeToTemplateToData(list: Property[], extra?: any) {
let tree = Tree.ArrayToTree(list)
let template: { [key: string]: any } = Tree.TreeToTemplate(tree)
let data
if (extra) {
// DONE 2.2 支持引用請求參數
let keys = Object.keys(template).map(item => item.replace(RE_KEY, '$1'))
let extraKeys = _.difference(Object.keys(extra), keys)
let scopedData = Tree.TemplateToData(
Object.assign({}, _.pick(extra, extraKeys), template),
)
for (const key in scopedData) {
if (!scopedData.hasOwnProperty(key)) continue
let data = scopedData[key]
for (const eKey in extra) {
if (!extra.hasOwnProperty(eKey)) continue
const pattern = new RegExp(`\\$${eKey}\\$`, 'g')
if (data && pattern.test(data)) {
data = scopedData[key] = data.replace(pattern, extra[eKey])
}
}
}
data = _.pick(scopedData, keys)
} else {
data = Tree.TemplateToData(template)
}
return data
}
示例3: callbacks
get callbacks(): CrawlCallbacks {
return _.pick(this.config, [
'success',
'failure',
'finished'
]);
}
示例4: function
static respondToResourceGET<T>(requestBody, res, dao: DAO<T>, whereArray: string[], likeArray: string[]) {
let whereQuery = _.omit(_.pick(requestBody, whereArray),
function (value, key, object) {
return value === "";
});
let likeQuery_ = _.chain(requestBody)
.pick(requestBody, likeArray)
.omit(function (value, key, object) {
return value === "";
}).value();
let likeQuery = _.mapObject(likeQuery_, function (value, key) {
return "%" + value + "%";
});
dao.find({
where: whereQuery, like: likeQuery, orderBy: requestBody.orderBy
}, function (err, results) {
if (err) {
APIHelper.sendDatabaseErrorResponse(res, err);
} else {
if (results.length === 0) {
APIHelper.sendNotFoundResponse(res, "Not found.");
} else {
APIHelper.sendResponse(res, results);
}
}
});
}
示例5: String
var action = String(function (args) {
var gm = require("@arangodb/general-graph");
var graph = gm._graph('qaGraph');
var _ = require('underscore');
var answerData = _.pick(args[0], 'chosen', 'opinion');
answerData.updatedAt = new Date();
return graph.answer.update(args[0]._key, answerData);
});
示例6: String
var action = String(function (args) {
var gm = require("@arangodb/general-graph");
var graph = gm._graph('qaGraph');
var _ = require('underscore');
var questionData = _.pick(args[0], 'title', 'options');
questionData.updatedAt = new Date();
return graph.question.update(args[0]._key, questionData);
});
示例7: View
export function View(options) {
this.cid = _.uniqueId('view');
options || (options = {});
_.extend(this, _.pick(options, viewOptions));
this._ensureElement();
this.initialize.apply(this, arguments);
this.delegateEvents();
};
示例8: h
node.on((data, key, at, ev) => {
if (signal.stop) {
ev.off();
} else {
// modifying data directly does not seem to work...
h(cleanup ? pick(data, (v, k, o) => v !== null && k !== '_') : data);
}
});
示例9: String
var action = String(function (args) {
var _ = require("underscore");
var gm = require("@arangodb/general-graph");
var graph = gm._graph('partyGraph');
var party = graph.party.document(args[0]);
var user = graph.user.document(args[1].user._key);
var location = graph.location.document(args[1].candidate.location._key);
var memberData = { admin: args[1].admin };
var candidateData = { office: args[1].candidate.office };
var member = graph.member.save(party._id, user._id, memberData);
var candidate = graph.candidate.save(user._id, location._id, candidateData);
return _.extend(
member,
memberData,
{ user: _.pick(user, '_key', 'name', 'nickname') },
{ candidate: _.extend(candidate, candidateData, { location: _.pick(location, '_key', 'name') }) },
);
});
示例10: ArrayToTreeToTemplateToData
public static ArrayToTreeToTemplateToData(list: Property[], extra?: any) {
let tree = Tree.ArrayToTree(list)
let template = Tree.TreeToTemplate(tree)
let data
if (extra) {
// DONE 2.2 支持引用請求參數
let keys = Object.keys(template).map(item => item.replace(RE_KEY, '$1'))
let extraKeys = _.difference(Object.keys(extra), keys)
let scopedData = Tree.TemplateToData(
Object.assign({}, _.pick(extra, extraKeys), template)
)
data = _.pick(scopedData, keys)
} else {
data = Tree.TemplateToData(template)
}
return data
}