
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
解决前后分离项目的接口数据不适用的问题,可以方便的对元数据进行增、删、改操作。 该项目使用typescript开发,因此推荐使用ts开发
import paptor from 'paptor'
or
<script src='https://unpkg.com/paptor@<version>/dist/paptor.js'></script>
// 包含了两个函数,分别是对对象和数组操作
import { objectAdaptor, arrayAdaptor } from ".."
// define interface
interface IData {
name: string,
age: number,
number: string,
}
// define test date
const data: IData = {
name: 'Jack',
age: 20,
number: '18812345678'
}
// 提取需要的属性 pick prop
console.log(objectAdaptor(data, [['age'], ['number']]));
// { age: 20, number: '18812345678' }
// 提取需求的属性并重命名属性名 pick prop and rename prop
console.log(objectAdaptor(data, [['age', 'Age'], ['number', 'Number']]));
// { Age: 20, Number: '18812345678' }
// 提取需求的属性并修改属性名 pick prop and update value
console.log(objectAdaptor(data, [['age'], ['name', (name) => `name is ${name}`]]));
// { age: 20, name: 'name is Jack' }
// 提取需求的属性、重命名属性名并修改属性名 pick prop, rename prop and update value
console.log(objectAdaptor(data, [['age'], ['name', 'Name', (name) => `name is ${name}`]]));
// { age: 20, Name: 'name is Jack' }
// 过滤属性 filter prop by array
console.log(objectAdaptor(data, [], ['number']));
// { name: 'Jack', age: 20 }
// 使用函数过滤 filter prop by function
console.log(objectAdaptor(data, [], (prop) => prop.startsWith('n')));
// { age: 20 }
// 提取和过滤 pick and filter
console.log(objectAdaptor(data, [['age', 'Age']], ['number']));
// { name: 'Jack', Age: 20 }
// mock list data
const dataList = [
{ name: 'foo', id: '10000001' },
{ name: 'baz', id: '10000002' },
{ name: 'bar', id: '10000003' },
]
// mock tree data
const dataTree = [
{ name: 'foo', id: '10000001' },
{ name: 'baz', id: '10000002', child: [ { name: 'bar', id: '10000003' } ] },
]
// 提取并重命名 pick and rename
console.log(arrayAdaptor(dataList, [['name', 'title'], ['id', 'value']]));
// [ { title: 'foo', value: '10000001' }, { title: 'baz', value: '10000002' }, { title: 'bar', value: '10000003' } ]
console.log(JSON.stringify(arrayAdaptor(dataTree, [['name', 'title'], ['id', 'value']], ['child', 'children'])));
// [{"title":"foo","value":"10000001","children":[]},{"title":"baz","value":"10000002","children":[{"title":"bar","value":"10000003","children":[]}]}]
FAQs
The npm package paptor receives a total of 15 weekly downloads. As such, paptor popularity was classified as not popular.
We found that paptor 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.