Skip to content

Commit 9baf0fc

Browse files
committed
Doc improvements
1 parent f93abd9 commit 9baf0fc

File tree

28 files changed

+792
-924
lines changed

28 files changed

+792
-924
lines changed

@types/directive/include/include.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
22
*
33
* @param {*} $templateRequest
4-
* @param {import("../../services/anchor-scroll.js").AnchorScrollFunction} $anchorScroll
4+
* @param {import("../../services/anchor-scroll/anchor-scroll.js").AnchorScrollFunction} $anchorScroll
55
* @param {*} $animate
66
* @param {import('../../services/exception/interface.ts').Interface} $exceptionHandler
77
* @returns {import('../../interface.js').Directive}
88
*/
99
export function ngIncludeDirective(
1010
$templateRequest: any,
11-
$anchorScroll: import("../../services/anchor-scroll.js").AnchorScrollFunction,
11+
$anchorScroll: import("../../services/anchor-scroll/anchor-scroll.js").AnchorScrollFunction,
1212
$animate: any,
1313
$exceptionHandler: import("../../services/exception/interface.ts").Interface,
1414
): import("../../interface.js").Directive;

@types/router/view-scroll.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ export class ViewScrollProvider {
44
$get: (
55
| string
66
| ((
7-
$anchorScroll: import("../services/anchor-scroll.js").AnchorScrollObject,
8-
) => import("../services/anchor-scroll.js").AnchorScrollObject | Function)
7+
$anchorScroll: import("../services/anchor-scroll/anchor-scroll.js").AnchorScrollObject,
8+
) =>
9+
| import("../services/anchor-scroll/anchor-scroll.js").AnchorScrollObject
10+
| Function)
911
)[];
1012
}

@types/router/view/view.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ViewService {
1818
_ngViews: any[];
1919
_viewConfigs: any[];
2020
_listeners: any[];
21-
$get: (() => this)[];
21+
$get: () => this;
2222
/**
2323
* @param {?import('../state/state-object.js').StateObject} context
2424
* @return {?import('../state/state-object.js').StateObject}

@types/services/anchor-scroll.d.ts renamed to @types/services/anchor-scroll/anchor-scroll.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export class AnchorScrollProvider {
1313
$get: (
1414
| string
1515
| ((
16-
$location: import("../services/location/location.js").Location,
17-
$rootScope: import("../core/scope/scope.js").Scope,
16+
$location: import("../../services/location/location.js").Location,
17+
$rootScope: import("../../core/scope/scope.js").Scope,
1818
) => AnchorScrollFunction)
1919
)[];
2020
}

@types/services/cookie-reader.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

@types/services/template-request.d.ts renamed to @types/services/template-request/template-request.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export class TemplateRequestProvider {
4343
$get: (
4444
| string
4545
| ((
46-
$exceptionHandler: import("./exception/exception-handler.js").ErrorHandler,
47-
$templateCache: import("../services/template-cache/interface.ts").TemplateCache,
46+
$exceptionHandler: import("../exception/exception-handler.js").ErrorHandler,
47+
$templateCache: import("../template-cache/interface.ts").TemplateCache,
4848
$http: any,
4949
$sce: any,
5050
) => {
Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,23 @@
99
-
1010
- @param {Array} array The source array.
1111
- <div class="alert alert-info">
12-
- **Note**: If the array contains objects that reference themselves, filtering is not possible.
12+
- **Note**: If the array contains objects that reference themselves, filtering
13+
is not possible.
1314
- </div>
14-
- @param {string|Object|function()} expression The predicate to be used for selecting items from
15+
- @param {string|Object|function()} expression The predicate to be used for
16+
selecting items from
1517
- `array`.
1618
-
1719
- Can be one of:
1820
-
19-
- - `string`: The string is used for matching against the contents of the `array`. All strings or
21+
- - `string`: The string is used for matching against the contents of the
22+
`array`. All strings or
2023
- objects with string properties in `array` that match this string will be returned. This also
2124
- applies to nested object properties.
2225
- The predicate can be negated by prefixing the string with `!`.
2326
-
24-
- - `Object`: A pattern object can be used to filter specific properties on objects contained
27+
- - `Object`: A pattern object can be used to filter specific properties on
28+
objects contained
2529
- by `array`. For example `{name:"M", phone:"1"}` predicate will return an array of items
2630
- which have property `name` containing "M" and property `phone` containing "1". A special
2731
- property name (`$` by default) can be used (e.g. as in `{$: "text"}`) to accept a match
@@ -37,13 +41,15 @@
3741
- `{name: {first: 'John', last: 'Doe'}}` will **not** be matched by `{name: 'John'}`, but
3842
- **will** be matched by `{$: 'John'}`.
3943
-
40-
- - `function(value, index, array)`: A predicate function can be used to write arbitrary filters.
44+
- - `function(value, index, array)`: A predicate function can be used to write
45+
arbitrary filters.
4146
- The function is called for each element of the array, with the element, its index, and
4247
- the entire array itself as arguments.
4348
-
4449
- The final result is an array of those elements that the predicate returned true for.
4550
-
46-
- @param {function(actual, expected)|true|false} [comparator] Comparator which is used in
51+
- @param {function(actual, expected)|true|false} [comparator] Comparator which
52+
is used in
4753
- determining if values retrieved using `expression` (when it is not a function) should be
4854
- considered a match based on the expected value (from the filter expression) and actual
4955
- value (from the object in the array).
@@ -54,16 +60,19 @@
5460
- The function will be given the object value and the predicate value to compare and
5561
- should return true if both values should be considered equal.
5662
-
57-
- - `true`: A shorthand for `function(actual, expected) { return angular.equals(actual, expected)}`.
63+
- - `true`: A shorthand for
64+
`function(actual, expected) { return angular.equals(actual, expected)}`.
5865
- This is essentially strict comparison of expected and actual.
5966
-
60-
- - `false`: A short hand for a function which will look for a substring match in a case
67+
- - `false`: A short hand for a function which will look for a substring match
68+
in a case
6169
- insensitive way. Primitive values are converted to strings. Objects are not compared against
6270
- primitives, unless they have a custom `toString` method (e.g. `Date` objects).
6371
-
6472
-
6573
- Defaults to `false`.
6674
-
67-
- @param {string} [anyPropertyKey] The special property name that matches against any property.
75+
- @param {string} [anyPropertyKey] The special property name that matches
76+
against any property.
6877
- By default `$`.
6978
- \*/
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
Allows you to convert a JavaScript object into a JSON string.
66

7-
This filter is mostly useful for debugging. When using the double curly `{{value}}` notation, the binding is automatically converted to JSON.
7+
This filter is mostly useful for debugging. When using the double curly
8+
`{{value}}` notation, the binding is automatically converted to JSON.
89

910
## Parameters
1011

11-
- **object** `{*}`: Any JavaScript object (including arrays and primitive types) to filter.
12-
- **spacing** `{number=}`: The number of spaces to use per indentation, defaults to 2.
12+
- **object** `{*}`: Any JavaScript object (including arrays and primitive types)
13+
to filter.
14+
- **spacing** `{number=}`: The number of spaces to use per indentation, defaults
15+
to 2.
1316

1417
## Returns
1518

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# limitTo Filter
2+
3+
## Description
4+
5+
Creates a new array or string containing only a specified number of elements.
6+
The elements are taken from either the beginning or the end of the source array,
7+
string, or number, as specified by the value and sign (positive or negative) of
8+
`limit`. Other array-like objects are also supported (e.g., array subclasses,
9+
NodeLists, JQLite/jQuery collections, etc.). If a number is used as input, it is
10+
converted to a string.
11+
12+
## Parameters
13+
14+
- **input** `{Array|ArrayLike|string|number}`: Array/array-like, string, or
15+
number to be limited.
16+
- **limit** `{string|number}`: The length of the returned array or string.
17+
- If the `limit` number is positive, `limit` number of items from the
18+
beginning of the source array/string are copied.
19+
- If the number is negative, `limit` number of items from the end of the
20+
source array/string are copied.
21+
- The `limit` will be trimmed if it exceeds `array.length`.
22+
- If `limit` is undefined, the input will be returned unchanged.
23+
- **begin** `{(string|number)=}`: Index at which to begin limitation. As a
24+
negative index, `begin` indicates an offset from the end of `input`. Defaults
25+
to `0`.
26+
27+
## Returns
28+
29+
- `{Array|string}`: A new sub-array or substring of length `limit` or less if
30+
the input had less than `limit` elements.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# OrderBy Filter
2+
3+
## Description
4+
5+
Returns an array containing the items from the specified `collection`, ordered
6+
by a `comparator` function based on the values computed using the `expression`
7+
predicate.
8+
9+
For example, `[{id: 'foo'}, {id: 'bar'}] | orderBy:'id'` would result in
10+
`[{id: 'bar'}, {id: 'foo'}]`.
11+
12+
The `collection` can be an Array or array-like object (e.g., NodeList, jQuery
13+
object, TypedArray, String, etc).
14+
15+
The `expression` can be a single predicate or a list of predicates, each serving
16+
as a tie-breaker for the preceding one. The `expression` is evaluated against
17+
each item and the output is used for comparing with other items.
18+
19+
You can change the sorting order by setting `reverse` to `true`. By default,
20+
items are sorted in ascending order.
21+
22+
The comparison is done using the `comparator` function. If none is specified, a
23+
default, built-in comparator is used (see below for details - in a nutshell, it
24+
compares numbers numerically and strings alphabetically).
25+
26+
### Under the Hood
27+
28+
Ordering the specified `collection` happens in two phases:
29+
30+
1. All items are passed through the predicate (or predicates), and the returned
31+
values are saved along with their type (`string`, `number`, etc). For
32+
example, an item `{label: 'foo'}`, passed through a predicate that extracts
33+
the value of the `label` property, would be transformed to:
34+
```javascript
35+
{
36+
value: 'foo',
37+
type: 'string',
38+
index: ...
39+
}
40+
```
41+
42+
Note: null values use 'null' as their type. 2. The comparator function is used
43+
to sort the items, based on the derived values, types, and indices.
44+
45+
If you use a custom comparator, it will be called with pairs of objects of the
46+
form {value: ..., type: '...', index: ...} and is expected to return 0 if the
47+
objects are equal (as far as the comparator is concerned), -1 if the 1st one
48+
should be ranked higher than the second, or 1 otherwise.
49+
50+
To ensure that the sorting will be deterministic across platforms, if none of
51+
the specified predicates can distinguish between two items, orderBy will
52+
automatically introduce a dummy predicate that returns the item's index as
53+
value. (If you are using a custom comparator, make sure it can handle this
54+
predicate as well.)
55+
56+
If a custom comparator still can't distinguish between two items, then they will
57+
be sorted based on their index using the built-in comparator.
58+
59+
Finally, in an attempt to simplify things, if a predicate returns an object as
60+
the extracted value for an item, orderBy will try to convert that object to a
61+
primitive value before passing it to the comparator. The following rules govern
62+
the conversion:
63+
64+
If the object has a valueOf() method that returns a primitive, its return value
65+
will be used instead. (If the object has a valueOf() method that returns another
66+
object, then the returned object will be used in subsequent steps.) If the
67+
object has a custom toString() method (i.e., not the one inherited from Object)
68+
that returns a primitive, its return value will be used instead. (If the object
69+
has a toString() method that returns another object, then the returned object
70+
will be used in subsequent steps.) No conversion; the object itself is used. The
71+
Default Comparator The default, built-in comparator should be sufficient for
72+
most use cases. In short, it compares numbers numerically, strings
73+
alphabetically (and case-insensitively), for objects falls back to using their
74+
index in the original collection, sorts values of different types by type, and
75+
puts undefined and null values at the end of the sorted list.
76+
77+
More specifically, it follows these steps to determine the relative order of
78+
items:
79+
80+
If the compared values are of different types: If one of the values is
81+
undefined, consider it "greater than" the other. Else if one of the values is
82+
null, consider it "greater than" the other. Else compare the types themselves
83+
alphabetically. If both values are of type string, compare them alphabetically
84+
in a case- and locale-insensitive way. If both values are objects, compare their
85+
indices instead. Otherwise, return: 0, if the values are equal (by strict
86+
equality comparison, i.e., using ===). -1, if the 1st value is "less than" the
87+
2nd value (compared using the < operator). 1, otherwise. Note: If you notice
88+
numbers not being sorted as expected, make sure they are actually being saved as
89+
numbers and not strings. Note: For the purpose of sorting, null and undefined
90+
are considered "greater than" any other value (with undefined "greater than"
91+
null). This effectively means that null and undefined values end up at the end
92+
of a list sorted in ascending order. Note: null values use 'null' as their type
93+
to be able to distinguish them from objects.
94+
95+
Parameters collection {Array|ArrayLike}: The collection (array or array-like
96+
object) to sort.
97+
98+
expression {(Function|string|Array.<Function|string>)=}: A predicate (or list of
99+
predicates) to be used by the comparator to determine the order of elements.
100+
101+
Can be one of:
102+
103+
Function: A getter function. This function will be called with each item as an
104+
argument and the return value will be used for sorting. string: An AngularTS
105+
expression. This expression will be evaluated against each item and the result
106+
will be used for sorting. For example, use 'label' to sort by a property called
107+
label or 'label.substring(0, 3)' to sort by the first 3 characters of the label
108+
property. (The result of a constant expression is interpreted as a property name
109+
to be used for comparison. For example, use '"special name"' (note the extra
110+
pair of quotes) to sort by a property called special name.) An expression can be
111+
optionally prefixed with + or - to control the sorting direction, ascending or
112+
descending. For example, '+label' or '-label'. If no property is provided,
113+
(e.g., '+' or '-'), the collection element itself is used in comparisons. Array:
114+
An array of function and/or string predicates. If a predicate cannot determine
115+
the relative order of two items, the next predicate is used as a tie-breaker.
116+
Note: If the predicate is missing or empty, then it defaults to '+'.
117+
118+
reverse {boolean=}: If true, reverse the sorting order.
119+
120+
comparator {(Function)=}: The comparator function used to determine the relative
121+
order of value pairs. If omitted, the built-in comparator will be used.
122+
123+
Returns {Array}: The sorted array.

0 commit comments

Comments
 (0)