1.2.0 • Published 3 years ago

field-mapper v1.2.0

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

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!
1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

4 years ago

0.1.0

4 years ago

1.0.7

5 years ago