
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
JSON folk-transforming tool
npm install --save jsonfork
Define the transformer
:
var jsonfork = require('jsonfork');
var transformer = new jsonfork({
source: {
name: 'Billing',
schema: {
"type": "object",
"properties": {
"title": { "type": "string" },
"fromTime": { "type": "string" },
"toTime": { "type": "string" },
"customerId": { "type": "string" },
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"label": { "type": "string" },
"price": { "type": "number" },
"amount": { "type": "number" }
},
"required": ["label", "price", "amount"]
}
}
}
}
},
targets: [{
name: 'Details',
transform: function(data, bill_opts) {
return {
title: data.title + ' [' + data.customerId + ']',
customerId: data.customerId,
items: data.items
}
},
eventName: 'BillingDetails'
},{
name: 'Summary',
transform: function(data, bill_opts) {
var summary = data.items.reduce(function(sum, item) {
sum.count += item.amount;
sum.total += item.amount * item.price;
return sum;
}, { count: 0, total: 0 });
if (bill_opts.tax > 0) {
summary.total *= (1 + bill_opts.tax);
}
return {
title: data.title + ' [' + data.customerId + ']',
customerId: data.customerId,
count: summary.count,
total: summary.total
}
},
schema: {}
}]
});
transformer.on('BillingDetails', function(result) {
// save to database
console.log('Details (from event): %s', JSON.stringify(result));
});
transformer.on('Summary', function(result) {
// push to log or send back to webpage
console.log('Summary (from event): %s', JSON.stringify(result));
});
Use transformer
to transform json data:
var bill_opts = { tax: 0.1 };
var result = transformer.transform({
title: 'JsonFork Billing',
customerId: 'hello.com',
items: [
{ label: 'Item#1', price: 15, amount: 2 },
{ label: 'Item#2', price: 17, amount: 3 }
]
}, bill_opts);
console.log('Result: %s', JSON.stringify(result, null, 2));
FAQs
JSON fork-transforming tool
The npm package jsonfork receives a total of 0 weekly downloads. As such, jsonfork popularity was classified as not popular.
We found that jsonfork 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
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.