index.js (2374B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 /** 22 * Split an object's own and inherited property values into two groups according to a predicate function. 23 * 24 * @module @stdlib/utils/bifurcate-in 25 * 26 * @example 27 * var bifurcateIn = require( '@stdlib/utils/bifurcate-in' ); 28 * 29 * function predicate( v ) { 30 * return v[ 0 ] === 'b'; 31 * } 32 * 33 * function Foo() { 34 * this.a = 'beep'; 35 * this.b = 'boop'; 36 * return this; 37 * } 38 * 39 * Foo.prototype = Object.create( null ); 40 * Foo.prototype.c = 'foo'; 41 * Foo.prototype.d = 'bar'; 42 * 43 * var obj = new Foo(); 44 * 45 * var out = bifurcateIn( obj, predicate ); 46 * // e.g., returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] 47 * 48 * @example 49 * var bifurcateIn = require( '@stdlib/utils/bifurcate-in' ); 50 * 51 * function predicate( v ) { 52 * return v[ 0 ] === 'b'; 53 * } 54 * 55 * function Foo() { 56 * this.a = 'beep'; 57 * this.b = 'boop'; 58 * return this; 59 * } 60 * 61 * Foo.prototype = Object.create( null ); 62 * Foo.prototype.c = 'foo'; 63 * Foo.prototype.d = 'bar'; 64 * 65 * var obj = new Foo(); 66 * 67 * var opts = { 68 * 'returns': 'keys' 69 * }; 70 * var out = bifurcateIn( obj, opts, predicate ); 71 * // e.g., returns [ [ 'a', 'b', 'd' ], [ 'c' ] ] 72 * 73 * @example 74 * var bifurcateIn = require( '@stdlib/utils/bifurcate-in' ); 75 * 76 * function predicate( v ) { 77 * return v[ 0 ] === 'b'; 78 * } 79 * 80 * function Foo() { 81 * this.a = 'beep'; 82 * this.b = 'boop'; 83 * return this; 84 * } 85 * 86 * Foo.prototype = Object.create( null ); 87 * Foo.prototype.c = 'foo'; 88 * Foo.prototype.d = 'bar'; 89 * 90 * var obj = new Foo(); 91 * 92 * var opts = { 93 * 'returns': '*' 94 * }; 95 * var out = bifurcateIn( obj, opts, predicate ); 96 * // e.g., returns [ [ [ 'a', 'beep' ], [ 'b', 'boop' ], [ 'd', 'bar' ] ], [ [ 'c', 'foo' ] ] ] 97 */ 98 99 // MODULES // 100 101 var bifurcateIn = require( './main.js' ); 102 103 104 // EXPORTS // 105 106 module.exports = bifurcateIn;