$ npm install simple-plist
A simple API for interacting with binary and plain text plist data.
# with yarn
yarn add simple-plist
# or with npm
npm install simple-plist
import Plist from "simple-plist";
async function foo() {
const data = await Plist.read("/path/to/some.plist");
console.log(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,
});
}
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>"
);
}
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");
}
© 2010 - cnpmjs.org x YWFE | Home | YWFE