Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
simple-plist
Advanced tools
The simple-plist npm package allows for the reading, writing, and manipulation of plist (Property List) files, which are commonly used in macOS and iOS for storing serialized objects. It provides a straightforward API for handling plist data in XML and binary formats.
Reading plist files
This feature allows for the synchronous reading of plist files from the filesystem. The `readFileSync` method reads the file from the given path and returns the plist data as a JavaScript object.
const plist = require('simple-plist');
const data = plist.readFileSync('/path/to/file.plist');
Writing plist files
This feature enables the synchronous writing of plist data to files. The `writeFileSync` method takes a file path and a JavaScript object, then serializes the object into plist format and writes it to the specified file.
const plist = require('simple-plist');
const data = { key: 'value' };
plist.writeFileSync('/path/to/file.plist', data);
Parsing plist data
This feature involves parsing plist data from a string. The `parse` method takes a plist-formatted string and converts it into a JavaScript object, allowing for easy manipulation and access to the data.
const plist = require('simple-plist');
const plistData = '<plist><dict><key>exampleKey</key><string>exampleValue</string></dict></plist>';
const data = plist.parse(plistData);
The 'plist' package offers similar functionality for parsing and building plist files. It supports both XML and binary plist formats. Compared to simple-plist, it might offer a more comprehensive API and additional options for customization.
This package is specifically designed for parsing binary plist files. While it does not support writing plist files or handling XML plists, it's optimized for fast and efficient parsing of binary plist data, making it a good choice for applications that only need to read plist files.
simple-plist
A simple API for interacting with binary and plain text plist data.
# via npm
npm install simple-plist
# via yarn
yarn add simple-plist
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);
Note: all of the async examples can optionally be converted to promises using node's
util.promisify
.
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);
plist.stringify()
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()
const plist = require("simple-plist");
const xml = `<plist>
<dict>
<key>name</key>
<string>Joe</string>
</dict>
</plist>`;
plist.parse(xml);
// { "name": "Joe" }
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:
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");
FAQs
A wrapper utility for interacting with plist data.
The npm package simple-plist receives a total of 1,345,928 weekly downloads. As such, simple-plist popularity was classified as popular.
We found that simple-plist demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.