README.md (2708B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # omit 22 23 > Return a partial object copy excluding specified keys. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 </section> 30 31 <!-- /.intro --> 32 33 <!-- Package usage documentation. --> 34 35 <section class="usage"> 36 37 ## Usage 38 39 ```javascript 40 var omit = require( '@stdlib/utils/omit' ); 41 ``` 42 43 #### omit( obj, keys ) 44 45 Returns a partial copy of an `object`, which excludes specified `keys`. 46 47 ```javascript 48 var obj1 = { 49 'a': 1, 50 'b': 2, 51 'c': 3 52 }; 53 54 var obj2 = omit( obj1, 'b' ); 55 // returns { 'a': 1, 'c': 3 } 56 57 var obj3 = omit( obj1, [ 'b', 'c' ] ); 58 // returns { 'a': 1 } 59 ``` 60 61 The function **ignores** non-existent and inherited keys. 62 63 ```javascript 64 var obj1 = { 65 'a': 1, 66 'b': 2, 67 'c': 3 68 }; 69 70 var obj2 = omit( obj1, 'd' ); 71 // returns { 'a': 1, 'b': 2, 'c': 3 } 72 ``` 73 74 </section> 75 76 <!-- /.usage --> 77 78 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 79 80 <section class="notes"> 81 82 ## Notes 83 84 - The function returns a **shallow** copy. 85 - The function **only** copies **own** properties. Hence, the function never copies inherited properties. 86 87 </section> 88 89 <!-- /.notes --> 90 91 <!-- Package usage examples. --> 92 93 <section class="examples"> 94 95 ## Examples 96 97 <!-- eslint no-undef: "error" --> 98 99 ```javascript 100 var omit = require( '@stdlib/utils/omit' ); 101 102 var obj1 = { 103 'a': 1, 104 'b': 2, 105 'c': 3, 106 'd': 4, 107 'e': 5 108 }; 109 110 var obj2 = omit( obj1, [ 'b', 'c', 'e' ] ); 111 // returns { 'a': 1, 'd': 4 } 112 ``` 113 114 </section> 115 116 <!-- /.examples --> 117 118 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 119 120 <section class="references"> 121 122 </section> 123 124 <!-- /.references --> 125 126 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 127 128 <section class="links"> 129 130 </section> 131 132 <!-- /.links -->