Skip to content

Commit 3aa9f67

Browse files
📚 docs(src): Improve function documentation.
1 parent f143bc1 commit 3aa9f67

File tree

7 files changed

+51
-15
lines changed

7 files changed

+51
-15
lines changed

src/native/decreasing.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
1+
/**
2+
* Compare two objects in decreasing order using the native comparison and
3+
* equality operators.
4+
*
5+
* @param {Object} a - The first parameter.
6+
* @param {Object} b - The second parameter.
7+
* @return {Number} -1 if a > b, 0 if a === b, and 1 otherwise.
8+
*/
29
export const decreasing = ( a , b ) => ( a > b ) ? -1 : ( a === b ) ? 0 : 1 ;
3-

src/native/increasing.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
1+
/**
2+
* Compare two objects in increasing order using the native comparison and
3+
* equality operators.
4+
*
5+
* @param {Object} a - The first parameter.
6+
* @param {Object} b - The second parameter.
7+
* @return {Number} -1 if a < b, 0 if a === b, and 1 otherwise.
8+
*/
29
export const increasing = ( a , b ) => ( a < b ) ? -1 : ( a === b ) ? 0 : 1 ;
3-

src/proxy/attr/attr.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
1+
/**
2+
* Generates a binary attribute comparator
3+
* from a binary comparator and an attribute key.
4+
*
5+
* @param {Function} compare - The function used to order attributes.
6+
* @param {Object} key - The key of the attribute used in the comparison.
7+
* @return {Function} The function that orders objects by attribute.
8+
*/
29
export const attr = ( compare , key ) => ( a , b ) => compare( a[key] , b[key] ) ;
3-
4-

src/proxy/attr/len.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
1+
/**
2+
* Generates a binary length comparator
3+
* from a binary comparator.
4+
*
5+
* @param {Function} compare - The function used to order lengths.
6+
* @return {Function} The function that orders objects by length.
7+
*/
28
export const len = compare => ( a , b ) => compare( a.length , b.length ) ;
3-

src/proxy/fn.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
1+
/**
2+
* Generates a binary comparator
3+
* from a binary comparator and a function.
4+
*
5+
* @param {Function} compare - The function used to order values.
6+
* @param {Function} callable - The function that generates values used in the comparison.
7+
* @return {Function} The function that orders objects by value.
8+
*/
29
export const fn = ( compare , callable ) => ( a , b ) => compare( callable( a ) , callable( b ) ) ;
3-

src/tools/reverse.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
1+
/**
2+
* Reverse the order of a comparator.
3+
*
4+
* @param {Function} compare - The comparator to reverse.
5+
* @return {Function} A function f such that compare(a,b) === f(b,a) for all a,b.
6+
*/
27
export const reverse = compare => ( a , b ) => compare( b , a ) ;
3-

src/tools/sign.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
1+
/**
2+
* Computes the sign of the input number.
3+
*
4+
* @param {Number} v - The number to compute the sign of.
5+
* @return {Number} -1 if v < 0, 1 if v > 0, 0 otherwise.
6+
*/
27
export const sign = v => v < 0 ? -1 : v > 0 ? 1 : 0 ;
3-

0 commit comments

Comments
 (0)