本文整理汇总了TypeScript中underscore.isEqual函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isEqual函数的具体用法?TypeScript isEqual怎么用?TypeScript isEqual使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isEqual函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
memCache.find(alternateUserResponse.cachedResponse, function(err3, results) {
if (err3) done(err3);
var alternateUserEntry = results[0];
assert(_.isEqual(alternateUserEntry, alternateUserResponse.cachedResponse), 'The pre-existing alternate user cache entry was ' +
'inappropriately altered.');
done();
});
示例2: later
changed.map(k => {
if (k == null) {
return;
}
const obj = k.toJS();
const obj0 = this.primary_key_part(obj);
const from0 = this.get_one(obj0);
const to0 = other.get_one(obj0);
if (from0 == null || to0 == null) {
// just to make typescript happy
return;
}
const from = from0.toJS();
const to = to0.toJS();
// undefined for each key of from not in to
for (let key in from) {
if (to[key] == null) {
obj[key] = null;
}
}
// Explicitly set each key of `to` that is different
// than corresponding key of `from`:
for (let key in to) {
const v = to[key];
if (!isEqual(from[key], v)) {
if (this.string_cols.has(key) && from[key] != null && v != null) {
if (typeof from[key] == "string" && typeof v == "string") {
// A valid string patch, converting one string to another.
obj[key] = string_make_patch(from[key], v);
} else {
/* This should be impossible, due to the type checking that
I've added to set in this same commit. However, it can't
hurt to put in the above check on types, just in case.
https://github.com/sagemathinc/cocalc/issues/3625
A string col actually contains something that is not
a string. (Maybe it's due to loading something old?)
In any case, it's better to "best effort" this, rather
than to make the entire document be un-savable and
un-usable to the user.
We just give up and record no change in this case, so
when doc is read in later (or by another user), there
will be no weird corruption.
This case will probably go away completely when all
client code is written with proper typing.
*/
}
} else if (is_object(from[key]) && is_object(v)) {
// Changing from one map to another, where they are not
// equal -- can use a merge to make this more efficient.
// This is an important optimization, to avoid making
// patches HUGE.
obj[key] = map_merge_patch(from[key], v);
} else {
obj[key] = v;
}
}
}
add.push(obj);
});
示例3: function
the_lean_server.on("tasks", function(path: string, tasks: object[]) {
logger.debug("lean_server:websocket:tasks -- ", path, tasks);
const lean_file = lean_files[`lean:${path}`];
if (lean_file !== undefined && !isEqual(lean_file.tasks, tasks)) {
lean_file.tasks = tasks;
lean_file.channel.write({ tasks });
}
});
示例4: areEqualInternal
private static areEqualInternal(expected: any, actual: any, partial: boolean) {
if (partial) {
if (_.isMatch(actual, expected)) return true;
}
else {
if (_.isEqual(actual, expected)) return true;
}
return false;
}
示例5: assertEntriesEqual
function assertEntriesEqual(expected: any, received: any, message: string) {
if (!_.isEqual(expected, received)) {
util.findDiffs(expected, received);
console.log('Expected:');
console.log(expected);
console.log('Received');
console.log(received);
assert(false, message);
}
}
示例6: createUser
public createUser(resultUser:BaseUser): User{
if(_.isEqual(resultUser.role,"facebook_user")){
this.log.log("Factory returning facebook user.");
return new FacebookUser(resultUser);//shallow copy
}
else{
this.log.log("Factory returning local user.");
return new LocalUser(resultUser);
}
}
示例7: push
function push(store: IStore, next: typeof actions.commonsUpdated.payload) {
const prev = store.getState().commons;
let hasDifferences = false;
for (const k of Object.keys(next)) {
if (!isEqual(prev[k], next[k])) {
hasDifferences = true;
break;
}
}
if (hasDifferences) {
store.dispatch(actions.commonsUpdated(next));
}
}
示例8: function
util.isMathDeviceCodeResponse = function (expected: any, received: any, print: any) {
if (print) {
console.log('DIFFS');
util.findDiffs(expected, received);
console.log('EXPECTED');
console.log(expected);
console.log('RECEIVED');
console.log(received);
}
var receivedClone = _.clone(received);
var expectedClone = _.clone(expected);
var isEqual = _.isEqual(expectedClone, receivedClone);
return isEqual;
};