Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
tapmodo committed Nov 6, 2015
1 parent 7ac1cb3 commit 1b477db
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#### Nodejs LDIF (LDAP Data Interchange Format) parser based on [RFC2849](https://github.com/tapmodo/node-ldif/tree/master/rfc)

Unless you are an LDAP aficionado you may not know about the LDIF format.
I was surprised to learn that no LDIF parsing library existed for node.
I was surprised to learn that no LDIF parsing library existed for node.
So I wrote one, with [peg.js](http://pegjs.org).

So I wrote one, with [peg.js](http://pegjs.org). It aims to be RFC-compliant.
Now I'll never have to use that cursed perl script again!

### Design Goals
Expand Down Expand Up @@ -70,31 +70,6 @@ var ldif = require('ldif');

### Converting

##### File data to plain object

```javascript
var ldif = require('ldif');
file = ldif.parseFile('./rfc/example1.ldif'),
output_options = {};

console.log(file.toObject(output_options));
```

Returns the following result:

```javascript
{ type: 'content',
version: 1,
entries:
[ { dn: 'cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com',
attributes: [Object] },
{ dn: 'cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com',
attributes: [Object] } ] }
```

Again, this is for the entire file. It's more common you'd want
to operate on individual records:

##### Record to plain object
```javascript
var ldif = require('ldif');
Expand All @@ -107,7 +82,7 @@ console.log(record.toObject(output_options));

Output of the above code is this:

```
```javascript
{ dn: 'cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com',
attributes:
{ objectclass: [ 'top', 'person', 'organizationalPerson' ],
Expand All @@ -125,13 +100,15 @@ sense in most cases.

##### toObject(options)

The behavior of `toObject()` can be altered with options below.

Option | Type | Description | Deafult
------ | ---- | ----------- | ----------
flatten | boolean | Flatten single values into strings | true
single | boolean | Overrides flatten, only returns single values | false
decode | boolean | Decode values (not yet well-defined, leave true) | true
preserveOptions | boolean | Outputs any attribute options | true
preferOptions | array | Prefer these options when `preserveOptions` is false | []
preferOptions | array | Prefer these options when `preserveOptions` is false | [ ]

##### Outputting LDIF for parsed files

Expand Down

0 comments on commit 1b477db

Please sign in to comment.