field-mapper
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

field-mapper

A field-mapping engine for managing field-to-property relationships and mapping objects. Provides a simple dictionary based on Map to take an array of field-map-like objects, and supports output of modified field-maps as an Azure-like table row. Full support for Typescript included.

Usage

Install via NPM and require in your project. There is also an ESM export, for use with browser or Deno.

const { FieldMapper } = require('field-mapper')
const fieldData = [{ fieldName: 'foo', propertyName: 'bar', objectName: 'FooBar' }]
const myMapper = new FieldMapper(fieldData)
const unmappedObj = { foo: 'hello, world!' }
const mappedObj = Object.create(null)

for (const [key, value] of Object.entries(unmappedObj)) {
  mappedObj[myMapper.getObjectMap('FooBar').getPropertyName(key)] = value
}

console.log(mappedObj.bar) // Expected output: hello, world!

Package Sidebar

Install

npm i field-mapper

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

27.4 kB

Total Files

14

Last publish

Collaborators

  • ahuggins_nhs