10 examples of 'filter es6' in JavaScript

Every line of 'filter es6' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
149function filter(arr, iterator, scope) {
150 if (arr && arrayFilter && arrayFilter === arr.filter) {
151 return arr.filter(iterator, scope);
152 }
153 if (!isArray(arr) || typeof iterator !== "function") {
154 throw new TypeError();
155 }
156
157 var t = Object(arr);
158 var len = t.length >>> 0;
159 var res = [];
160 for (var i = 0; i < len; i++) {
161 if (i in t) {
162 var val = t[i]; // in case fun mutates this
163 if (iterator.call(scope, val, i, t)) {
164 res.push(val);
165 }
166 }
167 }
168 return res;
169}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

22function Filter(filter) {
23 // valid filters: regexp, string, function
24 var type = typeof filter;
25 if (type === 'function') {
26 this.filter = filter;
27 } else if (type === 'string') {
28 this._filter = filter;
29 this.filter = nameFilter;
30 } else if (util.isRegExp(filter)) {
31 this._filter = filter;
32 this.filter = regexpFilter;
33 }
34}
39export function filter() {
40 return purry(_filter(false), arguments, filter.lazy);
41}
494return $scope.files.filter(function filter(file) {
495 return type & file.type;
496});
41x.filter = function filter() { throw new Error('array.filter is not a function'); };
45function filterArrayObject(array, filter){
46 var i = 0;
47
48 // array.length is changing
49 for(; i < array.length; i ++){
50 if(!filter.call(array, array[i], i)){
51
52 // the member at the iterator has been removed, so we should move the iterator one step to the left
53 array.splice(i --, 1);
54 }
55 }
56
57 return array;
58};
228value: function filter() {
229 var _filterBuilder;
230
231 (_filterBuilder = this._filterBuilder).filter.apply(_filterBuilder, arguments);
232 return this;
233}
102filter() {
103 return this.choices.filter.apply(this.choices, arguments);
104}
32value: function filter(value) {
33 throw new Error(this.constructor.name + " must define a filter.");
34}
33constructor(target: any|any[] =[]) {
34 super();
35 if (!Array.isArray(target)) {
36 target = [target];
37 }
38 this.target = target;
39 this.numToFind = target.length;
40}

Related snippets