# ember-setp

> The default blueprint for ember-cli addons.

Latest version **0.0.2** (published 2015-12-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-setp
pnpm add ember-setp
yarn add ember-setp
bun add ember-setp
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2015-12-15 |
| First published | 2015-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | davewasmer |
| Keywords | ember-addon |

## Links

- npm: https://www.npmjs.com/package/ember-setp
- Repository: https://github.com/davewasmer/ember-setp
- Homepage: https://github.com/davewasmer/ember-setp#readme
- Issues: https://github.com/davewasmer/ember-setp/issues
- npm.io page: https://npm.io/package/ember-setp

## Dependencies (1)

- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) ^5.1.5

## Recent versions

- 0.0.2 (latest) — 2015-12-15
- 0.0.1 — 2015-12-15

## README

# ember-setp

[![Build Status](https://travis-ci.org/davewasmer/ember-setp.svg?branch=master)](https://travis-ci.org/davewasmer/ember-setp)
[![Dependency Status](https://david-dm.org/davewasmer/ember-setp.svg)](https://david-dm.org/davewasmer/ember-setp)
[![devDependency Status](https://david-dm.org/davewasmer/ember-setp/dev-status.svg)](https://david-dm.org/davewasmer/ember-setp#info=devDependencies)

It's like `mkdir -p`, but for `Ember.Object`.

## Installation

```sh
$ ember install ember-setp
```

## Usage

Just import and use like you would a regular `Ember.set()` call:

```js
import setp from 'ember-setp';

let book = Ember.Object.create();

// setp will create the intermediate objects (in this case, the `author` object)
setp(book, 'author.firstName', 'Dave');

console.log(get(book, 'author'));  //  { firstName: 'Dave' }
```

`setp()` also handles arrays, and will create intermediate arrays for you as well:

```js
import setp from 'ember-setp';

let book = Ember.Object.create();

// setp will create the intermediate objects (in this case, the `author` object)
setp(book, 'reviews.0.summary', 'It was a great book!');

console.log(get(book, 'reviews'));  //  [ { summary: 'It was a great book!' } ]
```

## Implementation

`setp()` will step through each segment of the path you are trying to set (i.e. for `'book.author.firstName'`, it will step through `book` and `author`). If that segment doesn't exist (technically, is `null` or `undefined`), it will create an empty object at that intermediate path. If any segment is a number, it assumes it is an array index. If no array exists at that path, one will be created.

**Caveats**: there's two big caveats to using `setp()`:

* Your property names can't have `.` in them. That's _proabably_ a really bad idea anyway. `setp()` will treat a property with `.` in it as a nested property.
* You can't use numeric property names (i.e. just `'3'` as a property name). Another probably bad idea anyway, but `setp()` will confuse it for an array.

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