1.3.1 • Published 3 years ago
simple-plist v1.3.1
node-simple-plist
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-plistReading 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");
}1.4.0-0
3 years ago
1.4.0
3 years ago
1.3.1
4 years ago
1.3.0
4 years ago
1.2.0
4 years ago
1.2.3
4 years ago
1.2.2
4 years ago
1.2.1
4 years ago
1.1.1
5 years ago
2.0.0-rc.0
5 years ago
1.1.0
6 years ago
1.0.0
7 years ago
0.3.0
8 years ago
0.2.1
9 years ago
0.2.0
9 years ago
0.1.4
10 years ago
0.0.4
11 years ago
0.0.3
11 years ago
0.0.2
12 years ago
0.0.1
12 years ago