3.1.0 • Published 10 months ago

plist v3.1.0

Weekly downloads
1,468,873
License
MIT
Repository
github
Last release
10 months ago

plist.js

Apple's Property list parser/builder for Node.js and browsers

ci

Provides facilities for reading and writing Plist (property list) files. These are often used in programming OS X and iOS applications, as well as the iTunes configuration XML file.

Plist files represent stored programming "object"s. They are very similar to JSON. A valid Plist file is representable as a native JavaScript Object and vice-versa.

Usage

Node.js

Install using npm:

$ npm install --save plist

Then require() the plist module in your file:

var plist = require('plist');

// now use the `parse()` and `build()` functions
var val = plist.parse('<plist><string>Hello World!</string></plist>');
console.log(val);  // "Hello World!"

Browser

Include the dist/plist.js in a <script> tag in your HTML file:

<script src="plist.js"></script>
<script>
  // now use the `parse()` and `build()` functions
  var val = plist.parse('<plist><string>Hello World!</string></plist>');
  console.log(val);  // "Hello World!"
</script>

API

Parsing

Parsing a plist from filename:

var fs = require('fs');
var plist = require('plist');

var obj = plist.parse(fs.readFileSync('myPlist.plist', 'utf8'));
console.log(JSON.stringify(obj));

Parsing a plist from string payload:

var plist = require('plist');

var xml =
  '<?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">' +
    '<key>metadata</key>' +
    '<dict>' +
      '<key>bundle-identifier</key>' +
      '<string>com.company.app</string>' +
      '<key>bundle-version</key>' +
      '<string>0.1.1</string>' +
      '<key>kind</key>' +
      '<string>software</string>' +
      '<key>title</key>' +
      '<string>AppName</string>' +
    '</dict>' +
  '</plist>';

console.log(plist.parse(xml));

// [
//   "metadata",
//   {
//     "bundle-identifier": "com.company.app",
//     "bundle-version": "0.1.1",
//     "kind": "software",
//     "title": "AppName"
//   }
// ]

Building

Given an existing JavaScript Object, you can turn it into an XML document that complies with the plist DTD:

var plist = require('plist');

var json = [
  "metadata",
  {
    "bundle-identifier": "com.company.app",
    "bundle-version": "0.1.1",
    "kind": "software",
    "title": "AppName"
  }
];

console.log(plist.build(json));

// <?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">
//   <key>metadata</key>
//   <dict>
//     <key>bundle-identifier</key>
//     <string>com.company.app</string>
//     <key>bundle-version</key>
//     <string>0.1.1</string>
//     <key>kind</key>
//     <string>software</string>
//     <key>title</key>
//     <string>AppName</string>
//   </dict>
// </plist>

Cross Platform Testing Credits

Much thanks to Sauce Labs for providing free resources that enable cross-browser testing on this project!

Testing Powered By SauceLabs

License

(The MIT License)

fork-appcenter-cli42-pro-react-native-code-pushaircastcordova-ioscordova-commonreact-native-bluetooth2killi8n-react-native-fast-image@bonobolabs/firebase-tools-deploy-parallelismreact-native-code-push-ptmlaunchd-wizardtimefibersrn-send-smsryoma_rssmacos-bundlecordova-plugin-openwithcordova-internal-plugins-group-storagesblogreact-native-wk-view@fabapp/publicadorcatalogparseritunes-matcherreact-native-template-rfbasebrowser-launcher-tempjj-editor-installernativescript-hook-versioningairscanairscan-example@ivanmoskalev/barnbugsnag-react-native-clireact-native-esc-pos-sahaab@seabird22/cordova-plugin-firebasex@borisovart/atol-kkt-module@jimmychang/react-native-code-pushwi-react-native-code-pushdeneme323112@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjamesreact-native-proximity-sdkreact-native-covid-sdk@interaktiv/mibuilderreact-native-thanh-toast-libraryappletools-lib@thanhnguyen14797/react-native-thanh-toast-librarytrustwise-react-native@letea/alfred-library@johnf/electron-builder@stmp/stamp-clifastlanenode-fastlanereact-native-printer-brothersrn-pdf-reader-offlinesima-rnsmallstack-cli@jonz94/capacitor-set-versioncws-nw-builderjsec-custom-pluginreact-native-shekhar-bridge-testinnomobile-branch-cordova-sdkwilscanner@oiti/documentoscopy-react-nativeastro-tmbundlerrn-0.45-fork-oreoreact-native-slider-kfthemeport@ekx/cli@infinitebrahmanuniverse/nolb-pli@niklv/firebase-tools@sj-dixon/capacitor-clijotive-clinativescriptrsshub@everything-registry/sub-chunk-2447@commoners/solidarity@corelmax/react-native-my2c2p-sdk@damruravihara/react-native-testing-package@damian.lnc/core@cypress/core-launcher@cqingwang/react-native@cqingwang/react-native-code-push@cross2d/react-native-ushare@cross2d/react-native-alipay@cross2d/react-native-code-push@creaspan/kjl-rn@cresc/cli@crherman7/react-native-asset@darron1217/react-native-background-geolocation@con-test/react-native-concent-commoncommunity-admob-plus-cordovacompass-electron@ikeda/react-native@ikeda/react-native-for-ojtcom.dwm.it.plugin.deeplink@innomobile-native/branch-io@insightt/react-native-background-geolocation@inlight/react-nativecordova-acoustic-mobile-push-betaconfmanconnect-plist@icapps/translations@iceleaf/react-native-qqsdk
3.1.0

10 months ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.0

7 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.2.0

8 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.4.3

11 years ago

0.4.2

11 years ago

0.4.1

11 years ago

0.4.0

12 years ago

0.3.3

12 years ago

0.3.2

12 years ago

0.3.1

12 years ago

0.2.1

12 years ago

0.2.0

13 years ago

0.1.1

13 years ago

0.1.0

13 years ago