v1.0.0
An extended properties parser for Deno
Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
Versions
Properties
A Deno parser for the
.properties
file format.
properties_deno
?
Why not properties_deno
does not support
objects. This implementation deserializes keys with periods in their name to JS
objects (unless the period is prefixed with a backslash). It also supports
arrays with the syntax `greetings = [hello, hey]. Although it contains these
modifications, the variant used by this library is mostly a superset of
properties.
While this may not be completely spec-compliant, it is useful to be able to
work with .properties
files much more effectively. An example is given below.
Example
The properties file below would be serialized to the JS object below.
name=James
favourites.food=Pizza
favourites.drink=Coffee
const properties = {
name: "James",
favourites: {
food: "Pizza",
drink: "Coffee",
},
};
The following code can be used to serialize and deserialize the a properties file.
import { parse, stringify } from "https://deno.land/x/properties/mod.ts";
// An example can be found in ./test/test.properties
const file = await Deno.readTextFile("./example.properties");
const properties = parse(file);
console.log(JSON.stringify(properties, null, 2));
// Some style options can be passed to stringify. See ./src/stringifier.ts
const stringified = stringify(properties);
console.log(stringified);