slice_pipe.js
3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Pipe } from '@angular/core';
import { InvalidPipeArgumentError } from './invalid_pipe_argument_error';
/**
* \@ngModule CommonModule
* \@whatItDoes Creates a new List or String containing a subset (slice) of the elements.
* \@howToUse `array_or_string_expression | slice:start[:end]`
* \@description
*
* Where the input expression is a `List` or `String`, and:
* - `start`: The starting index of the subset to return.
* - **a positive integer**: return the item at `start` index and all items after
* in the list or string expression.
* - **a negative integer**: return the item at `start` index from the end and all items after
* in the list or string expression.
* - **if positive and greater than the size of the expression**: return an empty list or string.
* - **if negative and greater than the size of the expression**: return entire list or string.
* - `end`: The ending index of the subset to return.
* - **omitted**: return all items until the end.
* - **if positive**: return all items before `end` index of the list or string.
* - **if negative**: return all items before `end` index from the end of the list or string.
*
* All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
* and `String.prototype.slice()`.
*
* When operating on a [List], the returned list is always a copy even when all
* the elements are being returned.
*
* When operating on a blank value, the pipe returns the blank value.
*
* ## List Example
*
* This `ngFor` example:
*
* {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
*
* produces the following:
*
* <li>b</li>
* <li>c</li>
*
* ## String Examples
*
* {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
*
* \@stable
*/
export var SlicePipe = (function () {
function SlicePipe() {
}
/**
* @param {?} value
* @param {?} start
* @param {?=} end
* @return {?}
*/
SlicePipe.prototype.transform = function (value, start, end) {
if (value == null)
return value;
if (!this.supports(value)) {
throw new InvalidPipeArgumentError(SlicePipe, value);
}
return value.slice(start, end);
};
/**
* @param {?} obj
* @return {?}
*/
SlicePipe.prototype.supports = function (obj) { return typeof obj === 'string' || Array.isArray(obj); };
SlicePipe.decorators = [
{ type: Pipe, args: [{ name: 'slice', pure: false },] },
];
/** @nocollapse */
SlicePipe.ctorParameters = function () { return []; };
return SlicePipe;
}());
function SlicePipe_tsickle_Closure_declarations() {
/** @type {?} */
SlicePipe.decorators;
/**
* @nocollapse
* @type {?}
*/
SlicePipe.ctorParameters;
}
//# sourceMappingURL=slice_pipe.js.map