Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

data-shaper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-shaper - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

21

lib/resolve-fragment.js

@@ -74,3 +74,22 @@ 'use strict';

if (typeof value === 'object') {
async.map(Object.keys(value), function(id, cb) {
var keys = Object.keys(value);
// Got a single object back
if (typeof value[keys[0]] !== 'object') {
options.shapeData(value, shape, options, function(err, shapedFragmentData) {
if (err) {
return callback(err);
}
callback(err, {
data: shapedFragmentData,
shape: shape,
id: value.id
});
});
return;
}
// Got multiple objects
async.map(keys, function(id, cb) {
createFragmentHandler(options, shape, id, cb)(null, value[id]);

@@ -77,0 +96,0 @@ }, function(err, res) {

2

package.json
{
"name": "data-shaper",
"version": "1.0.0",
"version": "1.0.1",
"description": "Utility for building meaningful data shapes from normalized, related data",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -108,2 +108,46 @@ 'use strict';

it('can shape object with one-to-one reverse reference fragment', function(done) {
var shape = {
collectionName: 'persons',
shape: {
id: 'id',
name: 'firstName',
address: {
reference: 'addresses(personId==id)',
shape: {
collectionName: 'addresses',
shape: {
id: 'id'
}
}
}
}
};
dataShaper(
data.persons['1'],
shape,
defaultOptions,
function(err, res) {
assert(!err);
assert.deepEqual(res, {
addresses: {
'1': {
id: 1
}
},
persons: {
'1': {
id: 1,
name: 'Fred',
address: { addresses: 1 }
}
}
});
done();
}
);
});
it('can shape object with reverse reference and filter', function(done) {

@@ -110,0 +154,0 @@ var shape = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc