Skip to content

Commit 177c7cf

Browse files
committed
mc compare method
1 parent e7a7f2d commit 177c7cf

File tree

10 files changed

+78
-17
lines changed

10 files changed

+78
-17
lines changed

build/multiplex.d.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ declare module mx {
7373
* @param objA The first object to compare.
7474
* @param objB The second object to compare.
7575
*/
76-
function compare(objA: any, objB: any): number;
76+
function compare<T>(objA: T, objB: T): number;
7777

7878

7979
/**
@@ -90,6 +90,13 @@ declare module mx {
9090
function lambda<T1, T2, TResult>(exp: string): (obj1: T1, obj2: T2) => TResult;
9191

9292

93+
/**
94+
* Creates A function expression from the specified string lambda expression
95+
* @param exp String lambda expression.
96+
*/
97+
function lambda<T1, T2, T3, TResult>(exp: string): (obj1: T1, obj2: T2, obj3: T3) => TResult;
98+
99+
93100
/**
94101
* Creates A function expression from the specified string lambda expression
95102
* @param exp String lambda expression.
@@ -137,6 +144,14 @@ declare module mx {
137144
function equals(objA: any, objB: any): boolean;
138145

139146

147+
/**
148+
* Performs a comparison of two objects of the same type and returns a value indicating whether one object is less than, equal to, or greater than the other.
149+
* @param objA The first object to compare.
150+
* @param objB The second object to compare.
151+
*/
152+
function compare<T>(objA: T, objB: T): number;
153+
154+
140155
/**
141156
* Determines whether the specified object instances are considered equal. calls the overridden "equals" method when available.
142157
* @param objA The first object to compare.

build/multiplex.intellisense.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@ intellisense.annotate(mx, {
4242
/// <returns type="Boolean" />
4343
/// </signature>
4444
},
45+
"compare": function () {
46+
/// <signature>
47+
/// <summary>
48+
/// Performs a comparison of two objects of the same type and returns a value indicating whether one object is less than, equal to, or greater than the other.
49+
/// <br />
50+
/// Returns an integer that indicates the relative values of objA and objB, as shown in the following table:
51+
/// <br />
52+
/// Less than zero objA is less than objB.
53+
/// <br />
54+
/// Zero objA equals objB.
55+
/// <br />
56+
/// Greater than zero objA is greater than objB.
57+
/// </summary>
58+
/// <param name="objA" type="Object">The first object to compare.</param>
59+
/// <param name="objB" type="Object">The second object to compare.</param>
60+
/// <returns type="Number" />
61+
/// </signature>
62+
},
4563
"empty": function () {
4664
/// <signature>
4765
/// <summary>

build/multiplex.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5796,6 +5796,7 @@
57965796

57975797
hash: $hash,
57985798
equals: $equals,
5799+
compare: $computeCompare,
57995800
range: __Enumerable.range,
58005801
repeat: __Enumerable.repeat,
58015802
empty: __Enumerable.empty,

build/multiplex.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/multiplex.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/javascript/multiplex.intellisense.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@ intellisense.annotate(mx, {
4242
/// <returns type="Boolean" />
4343
/// </signature>
4444
},
45+
"compare": function () {
46+
/// <signature>
47+
/// <summary>
48+
/// Performs a comparison of two objects of the same type and returns a value indicating whether one object is less than, equal to, or greater than the other.
49+
/// <br />
50+
/// Returns an integer that indicates the relative values of objA and objB, as shown in the following table:
51+
/// <br />
52+
/// Less than zero objA is less than objB.
53+
/// <br />
54+
/// Zero objA equals objB.
55+
/// <br />
56+
/// Greater than zero objA is greater than objB.
57+
/// </summary>
58+
/// <param name="objA" type="Object">The first object to compare.</param>
59+
/// <param name="objB" type="Object">The second object to compare.</param>
60+
/// <returns type="Number" />
61+
/// </signature>
62+
},
4563
"empty": function () {
4664
/// <signature>
4765
/// <summary>

src/javascript/multiplex.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5796,6 +5796,7 @@
57965796

57975797
hash: $hash,
57985798
equals: $equals,
5799+
compare: $computeCompare,
57995800
range: __Enumerable.range,
58005801
repeat: __Enumerable.repeat,
58015802
empty: __Enumerable.empty,

src/typescript/multiplex.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ declare module mx {
7373
* @param objA The first object to compare.
7474
* @param objB The second object to compare.
7575
*/
76-
function compare(objA: any, objB: any): number;
76+
function compare<T>(objA: T, objB: T): number;
7777

7878

7979
/**
@@ -144,6 +144,14 @@ declare module mx {
144144
function equals(objA: any, objB: any): boolean;
145145

146146

147+
/**
148+
* Performs a comparison of two objects of the same type and returns a value indicating whether one object is less than, equal to, or greater than the other.
149+
* @param objA The first object to compare.
150+
* @param objB The second object to compare.
151+
*/
152+
function compare<T>(objA: T, objB: T): number;
153+
154+
147155
/**
148156
* Determines whether the specified object instances are considered equal. calls the overridden "equals" method when available.
149157
* @param objA The first object to compare.

test/typescript/runtime.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@
6868

6969
QUnit.test("compare", function (assert) {
7070

71-
assert.ok(mx.runtime.compare(1, null) === 1 && mx.runtime.compare(null, 1) === -1 && mx.runtime.compare(null, null) === 0, "compare null!");
72-
assert.ok(mx.runtime.compare(1, 0) === 1 && mx.runtime.compare(0, 1) === -1 && mx.runtime.compare(1, 1) === 0, "compare numbers!");
73-
assert.ok(mx.runtime.compare("B", "A") === 1 && mx.runtime.compare("A", "B") === -1 && mx.runtime.compare("A", "A") === 0, "compare string!");
74-
assert.ok(mx.runtime.compare(true, false) === 1 && mx.runtime.compare(false, true) === -1 && mx.runtime.compare(true, true) === 0, "compare bolean!");
75-
assert.ok(mx.runtime.compare(new Date(2015, 0, 2), new Date(2015, 0, 1)) === 1 && mx.runtime.compare(new Date(2015, 0, 1), new Date(2015, 0, 2)) === -1 && mx.runtime.compare(new Date(2015, 0, 1), new Date(2015, 0, 1)) === 0, "compare date!");
76-
assert.ok(mx.runtime.compare({ name: "A" }, { name: "B" }) === 0, "compare objects!");
71+
assert.ok(mx.compare(1, null) === 1 && mx.compare(null, 1) === -1 && mx.compare(null, null) === 0, "compare null!");
72+
assert.ok(mx.compare(1, 0) === 1 && mx.compare(0, 1) === -1 && mx.compare(1, 1) === 0, "compare numbers!");
73+
assert.ok(mx.compare("B", "A") === 1 && mx.compare("A", "B") === -1 && mx.compare("A", "A") === 0, "compare string!");
74+
assert.ok(mx.compare(true, false) === 1 && mx.compare(false, true) === -1 && mx.compare(true, true) === 0, "compare bolean!");
75+
assert.ok(mx.compare(new Date(2015, 0, 2), new Date(2015, 0, 1)) === 1 && mx.compare(new Date(2015, 0, 1), new Date(2015, 0, 2)) === -1 && mx.compare(new Date(2015, 0, 1), new Date(2015, 0, 1)) === 0, "compare date!");
76+
assert.ok(mx.compare({ name: "A" }, { name: "B" }) === 0, "compare objects!");
7777
});
7878

7979

test/unit/runtime.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@
6464

6565
QUnit.test("compare", function (assert) {
6666

67-
assert.ok(mx.runtime.compare(1, null) === 1 && mx.runtime.compare(null, 1) === -1 && mx.runtime.compare(null, null) === 0, "compare null!");
68-
assert.ok(mx.runtime.compare(1, 0) === 1 && mx.runtime.compare(0, 1) === -1 && mx.runtime.compare(1, 1) === 0, "compare numbers!");
69-
assert.ok(mx.runtime.compare("B", "A") === 1 && mx.runtime.compare("A", "B") === -1 && mx.runtime.compare("A", "A") === 0, "compare string!");
70-
assert.ok(mx.runtime.compare(true, false) === 1 && mx.runtime.compare(false, true) === -1 && mx.runtime.compare(true, true) === 0, "compare bolean!");
71-
assert.ok(mx.runtime.compare(new Date(2015, 0, 2), new Date(2015, 0, 1)) === 1 && mx.runtime.compare(new Date(2015, 0, 1), new Date(2015, 0, 2)) === -1 && mx.runtime.compare(new Date(2015, 0, 1), new Date(2015, 0, 1)) === 0, "compare date!");
72-
assert.ok(mx.runtime.compare({ name: "A" }, { name: "B" }) === 0, "compare objects!");
67+
assert.ok(mx.compare(1, null) === 1 && mx.compare(null, 1) === -1 && mx.compare(null, null) === 0, "compare null!");
68+
assert.ok(mx.compare(1, 0) === 1 && mx.compare(0, 1) === -1 && mx.compare(1, 1) === 0, "compare numbers!");
69+
assert.ok(mx.compare("B", "A") === 1 && mx.compare("A", "B") === -1 && mx.compare("A", "A") === 0, "compare string!");
70+
assert.ok(mx.compare(true, false) === 1 && mx.compare(false, true) === -1 && mx.compare(true, true) === 0, "compare bolean!");
71+
assert.ok(mx.compare(new Date(2015, 0, 2), new Date(2015, 0, 1)) === 1 && mx.compare(new Date(2015, 0, 1), new Date(2015, 0, 2)) === -1 && mx.compare(new Date(2015, 0, 1), new Date(2015, 0, 1)) === 0, "compare date!");
72+
assert.ok(mx.compare({ name: "A" }, { name: "B" }) === 0, "compare objects!");
7373
});
7474

7575

0 commit comments

Comments
 (0)