
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
OfilterJs is a data object filter processor for Javascript, which provides simpler, more convenient and more efficient data operations for development.
English | 中文
🖖 OfilterJs is a data object filter processor for Javascript, which provides simpler, more convenient and more efficient data operations for development.
⭐️ If it helps you, please give a star.
filterValuegetValueresetValue$ npm i ofilterjs
Or pnpm, Or cnpm, Or yarn ...
$ pnpm i ofilterjs
<script src="https://unpkg.com/ofilterjs@1.0.6/dist/ofilterjs.global.min.js"></script>
<script>
console.log(ofilterjs)
</script>
const ofjs = require('ofilterjs')
// import ofjs from 'ofilterjs'
filterValue([Object{}], [Config], ...[extraData])
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version_number: 10001
}
}
}
const newData = ofjs.filterValue(data, {
name: 'lib.pkg.name',
versionNumber: 'lib.pkg.version_number',
})
console.log(newData)
/** result
newData = {
name: 'ofilterjs',
versionNumber: 10001
}
*/
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version_number: 10001
}
}
}
const newData = ofjs.filterValue(data, {
name: 'lib.pkg.name',
type: {
value: 'type value'
}
})
console.log(newData)
/** result
newData = {
name: 'ofilterjs',
type: 'type value'
}
*/
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version_number: 10001
}
}
}
const newData = ofjs.filterValue(data, {
name: 'lib.pkg.name',
alias: {
key: 'lib.pkg.alias',
default: 'Default alias'
},
type: {
key: 'lib.pkg.type',
default: 'Npm pkg'
}
})
console.log(newData)
/** result
newData = {
name: 'ofilterjs',
alias: 'Default alias',
type: 'Npm pkg'
}
*/
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version_number: 10001
}
}
}
const newData = ofjs.filterValue(data, {
name: 'lib.pkg.name',
alias: {
key: 'lib.pkg.alias',
filter: (value, source) => {
if (value !== '') return value
return 'This is ' + (source?.lib?.pkg?.name || 'unknown')
}
},
type: {
key: 'lib.pkg.type',
filter: (value, source) => {
return 'Filter npm'
}
}
})
console.log(newData)
/** result
newData = {
name: 'ofilterjs',
alias: 'This is ofilterjs',
type: 'Filter npm'
}
*/
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version_number: 10001
}
}
}
const newData = ofjs.filterValue(data, {
name: 'lib.pkg.name',
_: {
merge: true,
filter: (_, source) => {
if (source?.lib?.pkg?.name === 'ofilterjs') {
return {
support: ['js', 'ts', 'es']
}
}
return {}
}
},
_1: {
merge: true,
filter: (_, source) => {
return { more: 'more data ...' }
}
},
}
})
console.log(newData)
/** result
newData = {
name: 'ofilterjs',
support: ['js', 'ts', 'es'],
more: 'more data ...'
}
*/
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version_number: 10001
}
}
}
const newData = ofjs.filterValue(data, {
name: 'lib.pkg.name'
}
}, {
name1: 'ofilter'
}, {
name2: 'object filter'
})
console.log(newData)
/** result
newData = {
name: 'ofilterjs',
name1: 'ofilter',
name2: 'object filter'
}
*/
getValue([nameStr], [defaultValue])
const data = {
lib: {
pkg: {
name: 'ofilterjs',
version: 10001
},
support: ['js', 'ts', 'es']
}
}
const name = ofjs.getValue(data, 'lib.pkg.name', 'unknown')
console.log(name) // ofilterjs
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version: 10001
},
support: ['js', 'ts', 'es']
}
}
const alias = ofjs.getValue(data, 'lib.pkg.alias|lib.pkg.name', 'unknown')
console.log(name) // ofilterjs
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version: 10001
},
support: ['js', 'ts', 'es']
}
}
const su = ofjs.getValue(data, 'lib.support.0', 'unknown')
console.log(su) // js
resetValue([Object{}], [Config,?Optional])
Tip: Prefixes with '_' attribute names will not be reset automatically.
Shallow Reset
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version: 10001
},
support: ['js', 'ts', 'es'],
_private: 'private attr'
},
lib2: {
pkg: {
name: 'ofilter'
}
}
}
ofjs.resetValue(data, false)
/** result
const data = {
lib: {},
lib2: {}
}
*/
Depth Reset
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version: 10001
},
support: ['js', 'ts', 'es'],
_private: 'private attr'
},
lib2: {
pkg: {
name: 'ofilter'
}
}
}
ofjs.resetValue(data, true)
/** result
const data = {
lib: {
pkg: {
name: '',
alias: '',
version: 0
},
support: [],
_private: 'private attr'
},
lib2: {
pkg: {
name: ''
}
}
}
*/
Depth Reset, Set depth layer parameter
const data = {
// level 0
name: 'lib_list',
lib: {
// level 1
type: 'npm',
pkg: {
// level 2
name: 'ofilterjs',
alias: '',
version: 10001
},
support: {
'js' : 'javascript',
'ts' : 'typescript'
},
_private: 'private attr'
},
lib2 : {
type: 'npm',
pkg: {
name: 'ofilter'
}
}
}
// 0 ~ (0+2)
ofjs.resetValue(data, true, 2)
/** result
const data = {
// level 0
name: '', // Was reset
lib: {
// level 1
type: '', // Was reset
pkg: {
// level 2
name: 'ofilterjs',
alias: '',
version: 10001
},
support: {
'js' : 'javascript',
'ts' : 'typescript'
},
_private: 'private attr'
},
lib2 : {
type: '', // Was reset
pkg: {
name: 'ofilter'
}
}
}
*/
Depth Reset, Set depth layer and start position parameter
const data = {
// level 0
name: 'lib_list',
lib: {
// level 1
type: 'npm',
pkg: {
// level 2
name: 'ofilterjs',
alias: '',
version: 10001,
support: {
// level 3
'js' : 'javascript',
'ts' : 'typescript'
}
},
_private: 'private attr'
},
lib2 : {
type: 'npm',
pkg: {
name: 'ofilter'
}
}
}
// 1 ~ (1+2)
ofjs.resetValue(data, true, 2, 1)
/** result
const data = {
// level 0
name: 'lib_list',
lib: {
// level 1
type: '', // Was reset
pkg: {
// level 2
name: '', // Was reset
alias: '', // Was reset
version: 0, // Was reset
support: {
// level 3
'js' : 'javascript',
'ts' : 'typescript'
}
},
_private: 'private attr'
},
lib2 : {
type: '', // Was reset
pkg: {
name: '' // Was reset
}
}
}
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version: 10001
},
support: ['js', 'ts', 'es']
}
}
ofjs.resetValue(data, [
'lib.pkg.name',
'lib.pkg.version'
])
/** result
const data = {
lib: {
pkg: {
name: '',
alias: '',
version: 0
},
support: ['js', 'ts', 'es']
}
}
*/
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version: 10001
},
support: ['js', 'ts', 'es']
}
}
// us ofilterjs
ofjs.resetValue(data, {
'lib.pkg.name': 'newname',
'lib.pkg.version': 10002
})
/** result
const data = {
lib: {
pkg: {
name: 'newname',
alias: '',
version: 10002
},
support: ['js', 'ts', 'es']
}
}
*/
Buy the author coffee: http://witkeycode.com/sponsor
MIT
FAQs
OfilterJs is a data object filter processor for Javascript, which provides simpler, more convenient and more efficient data operations for development.
The npm package ofilterjs receives a total of 17 weekly downloads. As such, ofilterjs popularity was classified as not popular.
We found that ofilterjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.