ldap-filters
Advanced tools
Comparing version 0.1.6 to 1.0.1
@@ -30,4 +30,10 @@ var soundex = require('soundex'); | ||
}, | ||
toString: function() { | ||
return [ '(', this.attrib, this.comp, this.value, ')' ].join(''); | ||
toString: function(indent,level) { | ||
if (indent === true) indent = Filter.indent; | ||
else if (parseInt(indent) < 1) indent = 0; | ||
level = level || 0; | ||
return [ | ||
' '.repeat(level*indent), | ||
'(', this.attrib, this.comp, this.value, ')' | ||
].join(''); | ||
} | ||
@@ -39,2 +45,5 @@ }; | ||
/* Default indent for beautify */ | ||
Filter.indent = 4; | ||
/* Escape a string value */ | ||
@@ -139,4 +148,13 @@ Filter.escape = function(value){ | ||
}, | ||
toString: function(){ | ||
return '(' + this.comp + this.filters.join('') + ')'; | ||
toString: function(indent,level){ | ||
if (indent === true) indent = Filter.indent; | ||
else if (parseInt(indent) < 1) indent = 0; | ||
var nl = indent ? '\n': ''; | ||
level = level || 0; | ||
return ' '.repeat(level*indent) + | ||
'(' + this.comp + nl + | ||
this.filters.map(function(item){ | ||
return item.toString(indent,level+1) | ||
}).join(nl) + nl + ' '.repeat(level*indent) + | ||
')'; | ||
} | ||
@@ -143,0 +161,0 @@ }; |
{ | ||
"name": "ldap-filters", | ||
"version": "0.1.6", | ||
"version": "1.0.1", | ||
"description": "Library for generating, parsing, and evaluating LDAP filters", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -70,2 +70,31 @@ node-ldap-filters | ||
### Output/print | ||
Whether you've created a filter programatically or by parsing a filter, you | ||
can output with `toString()` method or by concatenating with a string, like so: | ||
query.toString() | ||
query + '' | ||
If you pass a value of `true` or a numeric value to `toString()`, the | ||
output will be beautified: | ||
query.toString(true) | ||
query.toString(2) | ||
Will result in the following output: | ||
``` | ||
(& | ||
(givenName=jenny) | ||
(sn=jensen) | ||
(| | ||
(c=us) | ||
(st=ontario) | ||
) | ||
) | ||
``` | ||
A value of `true` will use `Filter.indent` property, which defaults to 4. | ||
### Evaluate data against a filter | ||
@@ -72,0 +101,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
49630
16
1203
0
159