New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

map-factory

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

map-factory - npm Package Versions

1
6

3.1.0

Diff

Changelog

Source

3.1.0

New set() feature to allow you to set a value on the target object without requiring a source field.

mapper
  .set("my.target.mappingStatus", "mapped");

// OR

mapper
  .set("my.target.id", () => createId());
midknight41
published 3.0.0 •

Changelog

Source

3.0.0

Fixes a bug when dealing with arrays of arrays with mapping fields involved in parent-child relationships. This is a breaking change as the values supplied to transforms must preserve a nested array structure to be properly set on the target object. The 2.x versions did not preserve this structure.

The getValue function will also preserve this structure too.


  const createMapper = require("map-factory");

  let mapper = createMapper();
  let src = {
    one: [
      { name: "first", two: [{ three: { value1: "A1", value2: "A2" } }, { three: { value1: "B1", value2: "B2" } }] },
      { name: "second", two: [{ three: { value1: "C1", value2: "C2" } }, { three: { value1: "D1", value2: "D2" } }] }
    ]
  };

  mapper
    .map("one[].name").to("combined[].name")
    .map("one[].two[].three[].value1").to("combined[].values[]", value => {

      // A transform in v2 received ["A1","B1","C1","D1"]
      // The transform in v3 will now receive [["A1","B1"],["C1","D1"]]
      return value;

    });

  let actual = mapper.execute(src);

  // The broken result in v2 {"combined":[{"name":"first","values":[["A1","B1","C1","D1"]]},{"name":"second"}]}
  // The correct result in v3 {"combined":[{"name":"first","values":["A1","B1"]},{"name":"second","values":["C1","D1"]}]}

Additionally the with() modifier has been added that will allow more fine grain control when working with arrays of arrays. More details can be found in the README.

midknight41
published 2.4.1 •

Changelog

Source

2.4.1

Fixed bug where each() returned a null when supplied with an empty array instead of returing an empty array.

midknight41
published 2.4.0 •

Changelog

Source

2.4.0

Added the removing() method that allows you to specify which fields you don't want instead of explicitly stating the fields you do want.


const mapper = createMapper();

const src = {
  user: {
    name: "Tim",
    occupation: "Enchanter",
    password: "scary bunny"
  }
};

mapper
  .map("user").removing("password").to("user");
  .execute(src);

/*
The expected result is:

{
  user: {
    name: "Tim",
    occupation: "Enchanter"
  }
}

*/

midknight41
published 2.3.1 •

Changelog

Source

2.3.1

Fixed a bug where an array of undefined values was calling the transform and set when it shouldn't have.

midknight41
published 2.3.0 •

Changelog

Source

2.3.0

Added chain method to the mapper which allows you to chain multiple mappers together and execute sequentially.

const source = {
  "foo": "bar",
  "bar": "foo"
};

 const mapper = createMapper();
 const secondaryMapper = createMapper();

mapper.map("foo");
secondaryMapper.map("foo").to("bar");

const result = mapper.chain(secondaryMapper).execute(source);

/**
The expected result will be
{
  "bar": "bar"
}
**/

midknight41
published 2.2.0 •

Changelog

Source

2.2.0

Added executeAsync() to the mapper which will return a Promise.

midknight41
published 2.1.2 •

Changelog

Source

2.1.2

Corrected TypeScript definitions.

midknight41
published 2.1.1 •

Changelog

Source

2.1.1

Put some dev dependencies back where they belong.

midknight41
published 2.1.0 •

Changelog

Source

2.1.0

Exposes the main two underlying functions: getValue and setValue.

See README for more details.

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