# sparkxcel

> DTO (Data Transfer Object) framework for JSON

Latest version **0.0.2** (published 2024-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install sparkxcel
pnpm add sparkxcel
yarn add sparkxcel
bun add sparkxcel
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2024-03-22 |
| First published | 2024-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^3.0.0 |
| Dependencies | 5 |
| Unpacked size | 15.4 KB |
| Known vulnerabilities | 0 (+6 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Simran Bhalode |
| Maintainers | simran20 |
| Keywords | DTO, JSON, transformations |

## Links

- npm: https://www.npmjs.com/package/sparkxcel
- Repository: https://github.com/s-bhalode/sparkXcel
- Homepage: https://github.com/s-bhalode/sparkXcel/blob/master/README.md
- Issues: https://github.com/s-bhalode/sparkXcel/issues
- npm.io page: https://npm.io/package/sparkxcel

## Dependencies (5)

- [joi](https://npm.io/package/joi.md) ^6.6.1
- [hoek](https://npm.io/package/hoek.md) ^2.14.0
- [enjoi](https://npm.io/package/enjoi.md) ^1.0.0
- [lazy.js](https://npm.io/package/lazy.js.md) ^0.4.0
- [json-ptr](https://npm.io/package/json-ptr.md) ^0.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.2 (latest) — 2024-03-22

## README

# DTO (Data Transfer Objects)


## Overview

This library was created to solve the problem of taking a data model from a datasource and needing to remove, add, merge, or translate the data model to a similar or completely different object. 

There are similar libraries in other languages (DataMapper, DTO(C#), etc). I could never find a solution that allowed me to quickly and easily utilize a couple of different approaches: *projection*, *translation*, and *merging*.

## Getting Started


## Projection
There are two simple ways to project (like a SQL SELECT statement) or simplify an object. I found myself deleting the properties on the object, or using libraries such as lodash to restrict the output. I decided to use Lazy.js for performance reasons.

### Only

Given an array of property names, the resulting object will only contain the supplied properties.

**Example**

```js
let Dto = require('dto');
let model = { name: { first: 'Simran', last: 'Bhalode'}, age: 21, gender: 'Female'};

let result = Dto.take.only(model, ['age', 'gender']);
// result = { age: 21, gender: 'Female' }
```

### Without

Given an array of property names, the resulting object will remove any properties supplied.

**Example**

```js
let Dto = require('dto');
let model = { name: { first: 'Simran', last: 'Bhalode'}, age: 21, gender: 'Female'};

let result = Dto.take.without(model, ['name']);
// result = { age: 21, gender: 'Female' }
```

---
_Source: https://npm.io/package/sparkxcel · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
