本文整理汇总了TypeScript中deep-equal类的典型用法代码示例。如果您正苦于以下问题:TypeScript deep-equal类的具体用法?TypeScript deep-equal怎么用?TypeScript deep-equal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了deep-equal类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: deepEqual
import * as deepEqual from "deep-equal";
let isDeepEqual1: boolean = deepEqual({}, {});
let isDeepEqual2: boolean = deepEqual({}, {}, { strict: true });
let isDeepEqual3: boolean = deepEqual({}, {}, { strict: false });
console.log(isDeepEqual1, isDeepEqual2, isDeepEqual3);
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:7,代码来源:deep-equal-tests.ts
示例2: concatSegment
/**
* Concat Segment
*
* @private
* @param {Feature<LineString>} line LineString
* @param {Feature<LineString>} segment 2-vertex LineString
* @returns {Feature<LineString>} concat linestring
*/
function concatSegment(line, segment) {
var coords = getCoords(segment);
var lineCoords = getCoords(line);
var start = lineCoords[0];
var end = lineCoords[lineCoords.length - 1];
var geom = line.geometry.coordinates;
if (equal(coords[0], start)) geom.unshift(coords[1]);
else if (equal(coords[0], end)) geom.push(coords[1]);
else if (equal(coords[1], start)) geom.unshift(coords[0]);
else if (equal(coords[1], end)) geom.push(coords[0]);
return line;
}
开发者ID:Turbo87,项目名称:turf,代码行数:21,代码来源:index.ts
示例3:
({method, pathRegex, queryParamsObject, bodyRestriction = {}}: MockedCall) => {
if (method !== this.req.method) {
return false;
}
if (!new RegExp(pathRegex).test(this.url)) {
return false;
}
const contentTypeIsApplicationJson = this.request.header['content-type'] === 'application/json';
if (queryParamsObject) {
const splitUrl = this.url.split('?');
if (splitUrl.length < 2) {
return false;
}
const queryParamsOnUrl = queryString.parse(splitUrl[1]);
if (!deepEquals(queryParamsOnUrl, queryParamsObject)) {
return false;
}
}
if (bodyRestriction.regex) {
const requestBodyAsString = contentTypeIsApplicationJson
? JSON.stringify(this.request.body)
: this.request.body;
if (!new RegExp(bodyRestriction.regex).test(requestBodyAsString)) {
return false;
}
}
if (
bodyRestriction.minimalObject &&
(!contentTypeIsApplicationJson || !isSubset(this.request.body, bodyRestriction.minimalObject))
) {
return false;
}
if (
bodyRestriction.object &&
(!contentTypeIsApplicationJson || !deepEquals(this.request.body, bodyRestriction.object))
) {
return false;
}
return true;
}
开发者ID:Soluto,项目名称:simple-fake-server,代码行数:48,代码来源:FakeServer.ts
示例4: featureEach
featureEach(tree.search(segment), function (match) {
if (doesOverlaps === false) {
var coordsSegment = getCoords(segment).sort();
var coordsMatch: any = getCoords(match).sort();
// Segment overlaps feature
if (equal(coordsSegment, coordsMatch)) {
doesOverlaps = true;
// Overlaps already exists - only append last coordinate of segment
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
else overlapSegment = segment;
// Match segments which don't share nodes (Issue #901)
} else if (
(tolerance === 0) ?
booleanPointOnLine(coordsSegment[0], match) && booleanPointOnLine(coordsSegment[1], match) :
nearestPointOnLine(match, coordsSegment[0]).properties.dist <= tolerance &&
nearestPointOnLine(match, coordsSegment[1]).properties.dist <= tolerance) {
doesOverlaps = true;
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
else overlapSegment = segment;
} else if (
(tolerance === 0) ?
booleanPointOnLine(coordsMatch[0], segment) && booleanPointOnLine(coordsMatch[1], segment) :
nearestPointOnLine(segment, coordsMatch[0]).properties.dist <= tolerance &&
nearestPointOnLine(segment, coordsMatch[1]).properties.dist <= tolerance) {
// Do not define (doesOverlap = true) since more matches can occur within the same segment
// doesOverlaps = true;
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, match);
else overlapSegment = match;
}
}
});
开发者ID:Turbo87,项目名称:turf,代码行数:32,代码来源:index.ts
示例5: function
target.prototype.shouldComponentUpdate = function (nextProps: Object) {
let _nextProps = nextProps, _props = this.props;
if (subprop) {
_nextProps = Object.assign({}, nextProps);
_props = Object.assign({}, this.props);
if (typeof subprop === 'string') {
_nextProps = _nextProps[subprop];
_props = _props[subprop];
} else if (typeof subprop === 'function') {
_nextProps = subprop(_nextProps);
_props = subprop(_props);
}
}
return !deepEqual(_nextProps, _props);
};
开发者ID:GoToLoop,项目名称:react-deep-equal-update,代码行数:18,代码来源:index.ts
示例6: return
return (serverCall: Call) => {
if (serverCall.method !== call.method) {
return false;
}
if (!new RegExp(call.pathRegex).test(serverCall.path)) {
return false;
}
const contentTypeIsApplicationJson = serverCall.headers['content-type'] === 'application/json';
const callBodyAsString = contentTypeIsApplicationJson ? JSON.stringify(serverCall.body) : serverCall.body;
if (call.bodyRestriction) {
if (call.bodyRestriction.exactText) {
if (callBodyAsString !== call.bodyRestriction.exactText) {
return false;
}
} else if (call.bodyRestriction.regex) {
if (!new RegExp(call.bodyRestriction.regex).test(callBodyAsString)) {
return false;
}
}
if (call.bodyRestriction.exactObject) {
if (!deepEquals(serverCall.body, call.bodyRestriction.exactObject)) {
return false;
}
} else if (call.bodyRestriction.minimalObject) {
if (!isSubset(serverCall.body, call.bodyRestriction.minimalObject)) {
return false;
}
}
}
return true;
};
开发者ID:Soluto,项目名称:simple-fake-server,代码行数:36,代码来源:FakeServer.ts
示例7: it
it('normal object case #2', () => {
const schema = json2schema("Test", {
"Result": {
"Age": null,
"ApplyRemark": null,
"CompanyName": null,
"IsChecked": null,
"IsScanCode": true,
"JobTitle": null,
"MRHeadImg": null,
"MRKid": 0,
"MobilePhone": null,
"NewDoctorCount": null,
"QRcode": null,
"Reason": null,
"Sex": null,
"TrueName": null
},
"State": 1
});
expect(deepEqual(schema, {
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"Result": {
"properties": {
"Age": {
"type": "null"
},
"ApplyRemark": {
"type": "null"
},
"CompanyName": {
"type": "null"
},
"IsChecked": {
"type": "null"
},
"IsScanCode": {
"type": "boolean"
},
"JobTitle": {
"type": "null"
},
"MRHeadImg": {
"type": "null"
},
"MRKid": {
"type": "number"
},
"MobilePhone": {
"type": "null"
},
"NewDoctorCount": {
"type": "null"
},
"QRcode": {
"type": "null"
},
"Reason": {
"type": "null"
},
"Sex": {
"type": "null"
},
"TrueName": {
"type": "null"
},
},
"required": [
"Age",
"ApplyRemark",
"CompanyName",
"IsChecked",
"IsScanCode",
"JobTitle",
"MRHeadImg",
"MRKid",
"MobilePhone",
"NewDoctorCount",
"QRcode",
"Reason",
"Sex",
"TrueName",
],
"type": "object",
},
"State": {
"type": "number"
},
},
"required": [
"Result",
"State"
],
"title": "Test",
"type": "object"
})).to.be.true;
});
开发者ID:jf3096,项目名称:json2schema,代码行数:98,代码来源:json2schema.ts
注:本文中的deep-equal类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论