
Research
/Security News
PolinRider Spreads Through Compromised GitHub Accounts and Packagist
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.
Object Mapping with JSONPath qeries.
async? mapq(rules: object, source: object, context?: any): object
Map the source object using the mapping rules.
If any transformation returns a Promise, the function returns a Promise.
The rules object defines the structure of the resulting object and
contains JSONPath expressions that are applied to the
source object to obtain the corresponding value for each leaf.
import mapq from 'mapq'
const rules = { foo: { bar: '$.a.b' } }
const source = { a: { b: 'hello' } }
const result = mapq(rules, source)
console.log(result) // { foo: { bar: 'hello' } }
Rules can include transformation functions that follow the
signature (value: any, source: object, context: any) => any. The value parameter corresponds to
the value of the node being transformed. The source and context are values that were originally
passed to the map function.
Transformations are defined by using an array [string, function], where the first element is an
expression to get the value from the source, and the second is a transformation function.
function increment (value) { return value + 1 }
const rules = { foo: ['$.bar', increment] }
const source = { bar: 1 }
const result = mapq(rules, source)
console.log(result) // { foo: 2 }
If a leaf does not conform to either JSONPath expression or a transformation, then it is considered as a desired value.
const rules = {
a: 1,
b: 'hello',
c: ['foo', 'bar']
}
const source = {}
const result = mapq(rules, source)
console.log(result) // { a: 1, b: 'hello', c: ['foo', 'bar'] }
Rules may form arrays.
const rules = { foo: ['$.bar', '$.baz'] }
const source = { bar: 'hello', baz: 'world' }
const result = mapq(rules, source)
console.log(result) // { foo: ['hello', 'world'] }
Transformations are also supported for arrays.
const transform = (value) => value + 10
const rules = { foo: [['$.bar', transform], ['$.baz', transform]] }
const source = { bar: 1, baz: 2 }
const result = mapq(rules, source)
console.log(result) // { foo: [11, 12] }
FAQs
Object Mapping with JSONPath
The npm package mapq receives a total of 4 weekly downloads. As such, mapq popularity was classified as not popular.
We found that mapq 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.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.

Security News
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.

Company News
Allow myself to introduce... myself.