@jace.dev/exceptjs
v2.0.0
Published
It returns a new object with the keys that were passed to the function removed
Downloads
6
Maintainers
Readme
EXCEPT JS
A simple script that adds a function to objects to help with key filtering.
Installation
# NPM
npm i @jace.dev/exceptjs
# YARN
yarn add @jace.dev/exceptjs
# PNMP
pnpm i @jace.dev/exceptjs
Examples:
<!-- BASIC HTML -->
<script src="https://raw.githubusercontent.com/Jace-Tech/except-js/main/except.js"></script>
<script>
const obj1 = { name: "foo", age: 20, city: "bar" }
console.log(obj1.except('name'))
// output: { age: 20, city: "bar" }
console.log(obj1.except(['name']))
// output: { age: 20, city: "bar" }
console.log(obj1.except('name', 'age'))
// output: { city: 'bar' }
console.log(obj1.except(['name', 'age']))
// output: { city: 'bar' }
const user = { name: "John Smith", age: 45, email: "[email protected]", password: "password"}
console.log(user.except('password'))
// output: { name: "John Smith", age: 45, email: "[email protected]" }
</script>
// NODE JS
require("@jace.dev/exceptjs")
const obj1 = { name: "foo", age: 20, city: "bar" }
console.log(obj1.except('name'))
// output: { age: 20, city: "bar" }
console.log(obj1.except(['name']))
// output: { age: 20, city: "bar" }
console.log(obj1.except('name', 'age'))
// output: { city: 'bar' }
console.log(obj1.except(['name', 'age']))
// output: { city: 'bar' }
const user = { name: "John Smith", age: 45, email: "[email protected]", password: "password"}
console.log(user.except('password'))
// output: { name: "John Smith", age: 45, email: "[email protected]" }