Comparing version 1.0.4 to 1.0.5
@@ -67,4 +67,4 @@ const fs = require('fs'); | ||
var xml = '', ret = [], collect = false; | ||
return new Promise((resolve, reject) => { | ||
return self.init().then(() => new Promise((resolve, reject) => { | ||
lineReader.on('line', line => { | ||
@@ -76,3 +76,3 @@ try { collector(line) } | ||
.on('close', () => resolve(ret)); | ||
}); | ||
})); | ||
@@ -79,0 +79,0 @@ function collector(line) { |
{ | ||
"name": "ofac", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A module to facilitate OFAC searches", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,12 +18,12 @@ [![npm version](https://badge.fury.io/js/ofac.svg)](https://badge.fury.io/js/ofac) | ||
Fetch from from the repository | ||
``` | ||
```javascript | ||
npm install --save ofac | ||
``` | ||
And set up a usable instance like this: | ||
``` | ||
```javascript | ||
// using ES6 modules | ||
import ofaq from 'ofac'; | ||
import ofac from 'ofac'; | ||
// using CommonJS modules | ||
const ofaq = require('ofac'); | ||
const ofac = require('ofac'); | ||
``` | ||
@@ -33,8 +33,15 @@ | ||
The module must be initialised: | ||
The module can be initialised first or just used directly: | ||
```javascript | ||
// example of initialisation | ||
ofac.init({xml: 'sdn2.xml'}).then(() => ofac.search(...))); | ||
// direct use | ||
ofac.search(...).then(...); | ||
``` | ||
ofaq.init().then(...); | ||
``` | ||
### init(force) | ||
### init(opts) | ||
* force (boolean) - indicates that a fresh fetch of the database should be made | ||
* path - the path where the downloaded archive and extracted database should be stored (default: `/tmp`) | ||
* xml - the name of the file name expected within the archive (default: `sdn.xml`) | ||
@@ -46,3 +53,5 @@ The module downloads, and unpacks the OFAC database unto the local directory and performs | ||
The method returns a NodeJs native promise wrapped around the module itself to allow chaining | ||
### search(cust, [filename]) | ||
* cust - an object consisting of properties to look for in the database | ||
@@ -92,2 +101,3 @@ * filename - an optional filename allowing the caller to run searches against a file other | ||
The method returns the file name used, wrapped in a promise | ||
### zipExtract(archive, filename, [path]) | ||
@@ -122,2 +132,3 @@ * archive - the name of the archive from which to extract | ||
## Example | ||
For more extensive examples please see the test suite | ||
@@ -124,0 +135,0 @@ ```javascript |
@@ -51,5 +51,2 @@ var fs = require('fs'); | ||
describe('Search', () => { | ||
before(() => { | ||
ofac.init(); | ||
}) | ||
it('Searched by id/country', async () => { | ||
@@ -56,0 +53,0 @@ var cust = {id: 'J287011', country: 'Colombia'}; |
18865
165
228