# sticky-identity

> Transformware that maintains consistent object identity when using a sticky datastore.

Latest version **1.0.1** (published 2014-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install sticky-identity
pnpm add sticky-identity
yarn add sticky-identity
bun add sticky-identity
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2014-06-02 |
| First published | 2014-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Brandon Valosek |
| Maintainers | bvalosek |
| Keywords | sticky, datastore, identity, transformware |

## Links

- npm: https://www.npmjs.com/package/sticky-identity
- Repository: git@github.com:bvalosek/sticky-identity
- Homepage: https://github.com/bvalosek/sticky-identity
- Issues: https://github.com/bvalosek/sticky-identity/issues
- npm.io page: https://npm.io/package/sticky-identity

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2014-06-02
- 1.0.0 — 2014-06-02

## README

# sticky-identity

[![Build Status](https://travis-ci.org/bvalosek/sticky-identity.png?branch=master)](https://travis-ci.org/bvalosek/sticky-identity)
[![NPM version](https://badge.fury.io/js/sticky-identity.png)](http://badge.fury.io/js/sticky-identity)

Transformware that maintains consistent object identity when using a
[sticky](https://github.com/bvalosek/sticky) datastore.

[![browser support](https://ci.testling.com/bvalosek/sticky-identity.png)](https://ci.testling.com/bvalosek/sticky-identity)


## Installation

```
$ npm install sticky-identity
```

## Usage

Assuming we have a [sticky](https://github.com/bvalosek/sticky) `Datastore` as
`db` and some sourced repository for the `User` model:

```javascript
var identity = require('sticky-identity');

db.use(User, identity());
```

Model identity is consistent now across all calls.

```javascript
var user = new User();
user.email = 'awesome@cool.net';
db.add(User)(user)
  .then(function(u) {
    u === user; // true
    return db.get(User)(user.id);
  })
  .then(function(u) {
    u === user; // true
  });
```

Identity is checked via the `id` parameter by default, but can be determined by
any string-like return value from a function argument:

```javascript
db.user(User, identity(function(x) { return x._id; }));
```

Keep in mind that the memory usage of this transformware will scale as the
number ofunique objects that are output or input into the repository grows.

## Testing

```
$ npm test
```

## License

MIT

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