-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
2,008 additions
and
1,721 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- 6 | ||
- 8 | ||
- 10 | ||
- 12 | ||
|
||
script: | ||
- npm run test:verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,74 @@ | ||
node-simple-plist | ||
================= | ||
# node-simple-plist | ||
|
||
[![Build Status](https://api.travis-ci.com/wollardj/node-simple-plist.svg?branch=develop)](https://travis-ci.com/wollardj/node-simple-plist) | ||
[![npm](https://img.shields.io/npm/dw/simple-plist.svg?style=popout&logo=npm)](https://www.npmjs.org/package/simple-plist) | ||
[![npm](https://img.shields.io/npm/v/simple-plist.svg?style=popout&logo=npm)](https://www.npmjs.com/package/simple-plist) | ||
[![Travis (.com) branch](https://img.shields.io/travis/com/wollardj/node-simple-plist/develop.svg?style=popout&logo=Travis%20CI)](https://travis-ci.com/wollardj/node-simple-plist) | ||
|
||
A simple API for interacting with binary and plain text plist data. | ||
|
||
|
||
## Installation | ||
|
||
```sh | ||
$ npm install simple-plist | ||
``` | ||
|
||
|
||
## Reading Data | ||
|
||
```js | ||
var plist = require('simple-plist'); | ||
var plist = require('simple-plist') | ||
|
||
// Read data from a file (xml or binary) (asynchronous) | ||
plist.readFile('/path/to/some.plist', function(err,data){ | ||
if (err) {throw err;} | ||
console.log( JSON.stringify(data) ); | ||
}); | ||
plist.readFile('/path/to/some.plist', function(err, data) { | ||
if (err) { | ||
throw err | ||
} | ||
console.log(JSON.stringify(data)) | ||
}) | ||
|
||
// Read data from a file (xml or binary) (synchronous) | ||
var data = plist.readFileSync('/path/to/some.plist'); | ||
console.log( JSON.stringify(data) ); | ||
var data = plist.readFileSync('/path/to/some.plist') | ||
console.log(JSON.stringify(data)) | ||
``` | ||
|
||
|
||
## Writing Data | ||
|
||
```js | ||
var plist = require('simple-plist'), | ||
data = plist.readFileSync('/path/to/some.plist'); | ||
data = plist.readFileSync('/path/to/some.plist') | ||
|
||
// Write data to a xml file (asynchronous) | ||
plist.writeFile('/path/to/plaintext.plist', data, function(err){ | ||
if (err) { throw err; } | ||
}); | ||
plist.writeFile('/path/to/plaintext.plist', data, function(err) { | ||
if (err) { | ||
throw err | ||
} | ||
}) | ||
|
||
// Write data to a xml file (synchronous) | ||
plist.writeFileSync('/path/to/plaintext.plist', data); | ||
plist.writeFileSync('/path/to/plaintext.plist', data) | ||
|
||
// Write data to a binary plist file (asynchronous) | ||
plist.writeBinaryFile('/path/to/binary.plist', data, function(err){ | ||
if (err) { throw err; } | ||
}); | ||
plist.writeBinaryFile('/path/to/binary.plist', data, function(err) { | ||
if (err) { | ||
throw err | ||
} | ||
}) | ||
|
||
// Write data to a binary plist file (synchronous) | ||
plist.writeBinaryFileSync('/path/to/binary.plist', data); | ||
plist.writeBinaryFileSync('/path/to/binary.plist', data) | ||
``` | ||
|
||
|
||
## Mutating Plists In Memory | ||
|
||
```js | ||
var plist = require('simple-plist'); | ||
var plist = require('simple-plist') | ||
|
||
// Convert a Javascript object to a plist xml string | ||
var xml = plist.stringify( {name: "Joe", answer:42} ); | ||
console.log(xml); // output is a valid plist xml string | ||
var xml = plist.stringify({ name: 'Joe', answer: 42 }) | ||
console.log(xml) // output is a valid plist xml string | ||
|
||
// Convert a plist xml string or a binary plist buffer to a Javascript object | ||
var data = plist.parse("<plist><dict><key>name</key><string>Joe</string></dict></plist>"); | ||
console.log( JSON.stringify(data) ); | ||
var data = plist.parse( | ||
'<plist><dict><key>name</key><string>Joe</string></dict></plist>' | ||
) | ||
console.log(JSON.stringify(data)) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.