# simple-plist

> A wrapper utility for interacting with plist data.

Latest version **1.3.1** (published 2022-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-plist
pnpm add simple-plist
yarn add simple-plist
bun add simple-plist
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2022-03-31 |
| First published | 2013-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 19.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 57 |
| Author | Joe Wollard |
| Maintainers | wollardj |
| Keywords | plist, binary, bplist, xml |

## Links

- npm: https://www.npmjs.com/package/simple-plist
- Repository: https://github.com/wollardj/simple-plist
- Homepage: https://github.com/wollardj/simple-plist.git
- npm.io page: https://npm.io/package/simple-plist

## Dependencies (3)

- [plist](https://npm.io/package/plist.md) ^3.0.5
- [bplist-parser](https://npm.io/package/bplist-parser.md) 0.3.1
- [bplist-creator](https://npm.io/package/bplist-creator.md) 0.1.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.3.1 (latest) — 2022-03-31
- 1.4.0-0 (next) — 2022-07-10
- 1.4.0 — 2022-07-10
- 1.3.0 — 2021-10-24
- 1.2.3 — 2021-10-24
- 1.2.2 — 2021-10-24
- 1.2.1 — 2021-10-24
- 1.2.0 — 2021-10-24
- 1.1.1 — 2020-10-01
- 2.0.0-rc.0 — 2020-07-26
- 1.1.0 — 2019-11-07
- 1.0.0 — 2018-12-06
- 0.3.0 — 2018-03-25
- 0.2.1 — 2016-11-01
- 0.1.4 — 2016-05-11
- … 4 more at https://npm.io/package/simple-plist/versions

## README

# `simple-plist`

[![npm](https://img.shields.io/npm/dw/simple-plist.svg?style=popout&logo=npm)](https://www.npmjs.org/package/simple-plist)
[![npm](https://img.shields.io/npm/v/simple-plist.svg?style=popout&logo=npm)](https://www.npmjs.com/package/simple-plist)

A simple API for interacting with binary and plain text
[plist](https://en.wikipedia.org/wiki/Property_list) data.

## Installation

```sh
# via npm
npm install simple-plist

# via yarn
yarn add simple-plist
```

## Synchronous API

```js
const plist = require("simple-plist");

let data;

// read
data = plist.readFileSync("/path/to/some.plist");

// write xml
plist.writeFileSync("/path/to/plaintext.plist", data);

// write binary
plist.writeBinaryFileSync("/path/to/binary.plist", data);
```

## Asynchronous API

> Note: all of the async examples can optionally be converted to promises using
> node's [`util.promisify`](https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_util_promisify_original).

```js
const plist = require("simple-plist");

let data;

function callback(err, contents) {
  if (err) throw err;
  data = contents;
}

// read
plist.readFile("/path/to/some.plist", callback);

// write xml
plist.writeFile("/path/to/plaintext.plist", data, callback);

// write binary
plist.writeBinaryFile("/path/to/binary.plist", data, callback);
```

## In Memory

### `plist.stringify()`

```js
const plist = require("simple-plist");

// Convert an object to a plist xml string
plist.stringify({ name: "Joe", answer: 42 });

/*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>name</key>
    <string>Joe</string>
    <key>answer</key>
    <integer>42</integer>
  </dict>
</plist>
*/
```

### `plist.parse()`

```js
const plist = require("simple-plist");

const xml = `<plist>
	<dict>
		<key>name</key>
		<string>Joe</string>
	</dict>
</plist>`;

plist.parse(xml);
// { "name": "Joe" }
```

## TypeScript Support

All functions have typescript signatures, but there are a few handy generics
that are worth pointing out. Those generics belong to `parse`, `readFile`,
and `readFileSync`. Here's an example:

```tsx
import { parse, readFile, readFileSync } from "simple-plist";

type Profile = {
  name: string;
  answer: number;
};

const xml = `<plist>
	<dict>
		<key>name</key>
		<string>Joe</string>
		<key>answer</key>
		<integer>42</integer>
	</dict>
</plist>`;

// typed string parsing
const { answer } = parse<Profile>(xml);
// answer = 42;

// typed file loading
const { name } = readFileSync<Profile>("/path/to/profile.plist");
```

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