-
Notifications
You must be signed in to change notification settings - Fork 29
/
index.js
54 lines (39 loc) · 1.38 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* jshint node: true */
'use strict';
/**
# addressit
AddressIt is a freeform street address parser, that is designed to take a
piece of text and convert that into a structured address that can be
processed in different systems.
The focal point of `addressit` is on the street parsing component, rather
than attempting to appropriately identify various states, counties, towns,
etc, as these vary from country to country fairly dramatically. These
details are instead put into a generic regions array that can be further
parsed based on your application needs.
## Example Usage
The following is a simple example of how address it can be used:
<<< examples/simple.js
The `address` object would now contain the following information:
```
{ text: '8/431 ST KILDA RD MELBOURNE',
parts: [],
unit: 8,
country: undefined,
number: 431,
street: 'ST KILDA RD',
regions: [ 'MELBOURNE' ] }
```
For more examples, see the tests.
## Reference
**/
/**
### addressit(input, opts?)
Run the address parser for the given input. Optional `opts` can be
supplied if you want to override the default (EN) parser.
**/
module.exports = function(input, opts) {
// if no locale has been specified, then use the default vanilla en locale
var parse = (opts || {}).locale || require('./locale/en-US');
// parse the address
return parse(input, opts);
};