
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
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.
$ npm i ofilterjs
Or pnpm, Or cnpm, Or yarn ...
$ pnpm i ofilterjs
import ofjs from 'ofilterjs'
// const ofjs = require('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])
const data = {
lib: {
pkg: {
name: 'ofilterjs',
alias: '',
version: 10001
},
support: ['js', 'ts', 'es']
}
}
ofjs.resetValue(data)
/** result
const data = {
lib: {
pkg: {
name: '',
alias: '',
version: 0
},
support: []
}
}
*/
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.
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.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.