simple-plist
A wrapper utility for interacting with plist data.
Last updated 6 years ago by wollardj .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install simple-plist 
SYNC missed versions from official npm registry.

node-simple-plist

npm npm Travis (.com) branch

A simple API for interacting with binary and plain text plist data.

Installation

# with yarn
yarn add simple-plist

# or with npm
npm install simple-plist

Reading Data

import Plist from "simple-plist";

async function foo() {
  const data = await Plist.read("/path/to/some.plist");
  console.log(data);
}

Writing Data

import Plist from "simple-plist";

async function foo() {
  const myPlist = { foo: "bar" };
  // Write data to xml file
  await Plist.write({
    file: "/path/to/xml.plist",
    input: myPlist,
  });

  // Write data to binary file
  await Plist.write({
    binary: true,
    file: "/path/to/xml.plist",
    input: myPlist,
  });
}

In-Memory Conversion

import Plist from "simple-plist";

async function foo() {
  // Convert a Javascript object to a plist xml string
  const xml = Plist.stringify({ name: "Joe", answer: 42 });

  // Convert a plist xml string or a binary plist buffer to a Javascript object
  const data = await parse(
    "<plist><dict><key>name</key><string>Joe</string></dict></plist>"
  );
}

TypeScript Generics

If you're using TypeScript, the parse and read methods both support generics so you don't lose type information. If no type is specified, the default of PlistValue will be used.

import Plist from "simple-plist";

interface Settings {
  showToolbar?: boolean;
  avatar?: string;
}

async function loadSettings() {
  return Plist.read<MyDatabase>("/path/to/settings.plist");
}

Current Tags

  • 1.3.1                                ...           latest (5 years ago)
  • 1.4.0-0                                ...           next (4 years ago)

19 Versions

  • 1.4.0-0                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.3 [deprecated]           ...           5 years ago
  • 1.2.2 [deprecated]           ...           5 years ago
  • 1.2.1 [deprecated]           ...           5 years ago
  • 1.2.0 [deprecated]           ...           5 years ago
  • 1.1.1                                ...           6 years ago
  • 2.0.0-rc.0                                ...           6 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.0                                ...           8 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.1                                ...           10 years ago
  • 0.1.4                                ...           11 years ago
  • 0.0.4                                ...           12 years ago
  • 0.0.3                                ...           12 years ago
  • 0.0.2                                ...           13 years ago
  • 0.0.1                                ...           13 years ago
Downloads
Total 79
Today 0
This Week 0
This Month 26
Last Day 0
Last Week 1
Last Month 32
Dependencies (4)
Dev Dependencies (19)
Dependents (3)

© 2010 - cnpmjs.org x YWFE | Home | YWFE