Product
Introducing Java Support in Socket
We're excited to announce that Socket now supports the Java programming language.
@types/plist
Advanced tools
TypeScript definitions for plist
@types/plist provides TypeScript type definitions for the plist package, which is used to parse and build Apple Property List (plist) files. These files are commonly used in macOS and iOS applications for configuration and serialization of data.
Parsing plist files
This feature allows you to parse a plist XML string into a JavaScript object. The code sample demonstrates how to parse a plist XML string containing a dictionary with keys 'name' and 'age'.
const plist = require('plist');
const xml = '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n<dict>\n <key>name</key>\n <string>John Doe</string>\n <key>age</key>\n <integer>30</integer>\n</dict>\n</plist>';
const obj = plist.parse(xml);
console.log(obj);
Building plist files
This feature allows you to build a plist XML string from a JavaScript object. The code sample demonstrates how to convert a JavaScript object with properties 'name' and 'age' into a plist XML string.
const plist = require('plist');
const obj = { name: 'John Doe', age: 30 };
const xml = plist.build(obj);
console.log(xml);
The plist package is the core library for parsing and building plist files. It provides the same functionalities as @types/plist but without TypeScript type definitions. It is suitable for JavaScript projects that do not require type checking.
fast-plist is another package for parsing and building plist files. It is designed to be faster and more efficient than the plist package. However, it may not have the same level of compatibility with all plist formats as the plist package.
bplist-parser is a package specifically for parsing binary plist files, which are a more compact and efficient format used by Apple. It does not support building plist files, so it is only suitable for reading binary plist data.
npm install --save @types/plist
This package contains type definitions for plist (https://github.com/TooTallNate/node-plist#readme).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/plist.
/// <reference types="node" />
import { XMLToStringOptions } from "xmlbuilder";
// plist
export as namespace plist;
// plist.parse()
export function parse(xml: string): PlistValue;
// plist.build()
export function build(obj: PlistValue, opts?: PlistBuildOptions): string;
// PlistValue
export type PlistValue = string | number | boolean | Date | Buffer | PlistObject | PlistArray;
export interface PlistObject {
readonly [x: string]: PlistValue;
}
export interface PlistArray extends ReadonlyArray<PlistValue> {}
// PlistBuildOptions
// The instance of this type is passed to 'xmlbuilder' module as it is.
export type PlistBuildOptions = XMLToStringOptions;
These definitions were written by Yusuke Higuchi.
FAQs
TypeScript definitions for plist
The npm package @types/plist receives a total of 186,448 weekly downloads. As such, @types/plist popularity was classified as popular.
We found that @types/plist demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.
Security News
Deno 2.0 is now available with enhanced package management, full Node.js and npm compatibility, improved performance, and support for major JavaScript frameworks.