Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
An easy way to anonymize your json. This utility can remove all field names from javascript objects.
Let's say you have to put a dataset on your website for your own use, but don't really want to share it to everyone. If you upload the raw, nice dataset with all the field names, people can just take it for their own use easily. You want to make it a bit harder for them to interpret the data without shooting yourself in the foot.
This anonymizer was built for that purpose:
The library is also very lightweight (raw 3KB, minified 1KB) and supports CommonJS, AMD (RequireJS) as well as browser use.
Install with npm:
npm install --save anonymizer
or bower
bower install --save anonymizer
var anonymizer = new Anonymizer();
anonymizer.encode(
{a: 1, b: true, c: 'test'},
{a: 'Number', b: 'Boolean', c: 'String'}
);
=> [1, true, 'test']
anonymizer.encode(
[{a: 1, b: true, c: 'test'}, {a: 2, b: false, c: 'test2'}],
[{a: 'Number', b: 'Boolean', c: 'String'}]
);
=> [ [1, true, 'test'], [2, false, 'test2'] ]
anonymizer.decode(
[1, true, 'test'],
{a: 'Number', b: 'Boolean', c: 'String'}
);
=> {a: 1, b: true, c: 'test'}
anonymizer.decode(
[ [1, true, 'test'], [2, false, 'test2'] ],
[{a: 'Number', b: 'Boolean', c: 'String'}]
);
=> [{a: 1, b: true, c: 'test'}, {a: 2, b: false, c: 'test2'}]
Anonymizer can map categorical values to/from integers.
anonymizer.encode('test', 'Category');
=> 1
anonymizer.encode(['test', 'test2', 'test'], ['Category']);
=> [1, 2, 1]
anonymizer.getCategories();
=> ['test', 'test2']
// Create a new anonymizer and pass known categories
var anonymizer2 = new Anonymizer(anonymizer.getCategories());
anonymizer2.decode(1);
=> 'test'
anonymizer2.decode([1, 2, 1]);
=> ['test', 'test2', 'test']
Primitive values Use string
2
=> schema = 'Number'
'test value'
=> 'String'
true
=> schema = 'Boolean'
Categorical values Use string "Categorical"
'category1'
=> schema = 'Categorical'
Object Use curly braces and contain all the keys that you want to export. The value for each key is the type for that field.
{a: 1, b:'test', c: true}
=> schema = {a: 'Number', b: 'String', c: 'Boolean'}
Array Use square brackets and contains the type of an element. This library assume that all children of an array are of the same type, so you will define the schema for the child only once.
[1, 2, 3]
=> schema = ['Number']
['test1', 'test2']
=> schema = ['String']
['category1', 'category2']
=> schema = ['Category']
Nesting You can combine the syntax above to define any schema for you data.
Array of objects
[
{a: 1, b: true, c: 'test'},
{a: 2, b: false, c: 'test2'}
]
=> schema = [{a: 'Number', b: 'Boolean', c: 'String'}]
Array of arrays
[
[1, 2, 3],
['a', 'b', 'c']
]
=> schema = [['Number'], ['String']]
Object that contains an array
{
a: [1, 2, 3],
b: ['a','b','c'],
c: 'test'
}
=> schema = {a: ['Number'], b: ['String'], c: 'String'}
From the repo root:
npm install
npm test
FAQs
An easy way to anonymize your json. This utility can remove all field names from javascript objects.
The npm package anonymizer receives a total of 1 weekly downloads. As such, anonymizer popularity was classified as not popular.
We found that anonymizer 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.