Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/closeio/addresscompiler
Compile pairs of names & email addresses into an RFC 2822 string
https://github.com/closeio/addresscompiler
Last synced: about 1 month ago
JSON representation
Compile pairs of names & email addresses into an RFC 2822 string
- Host: GitHub
- URL: https://github.com/closeio/addresscompiler
- Owner: closeio
- License: mit
- Created: 2014-11-03T22:40:43.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-06-27T08:46:07.000Z (over 1 year ago)
- Last Synced: 2024-10-01T22:53:24.752Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 7
- Watchers: 21
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Address compiler
`addresscompiler` is a UMD module that allows you to compile name-addr e-mail addresses in node and the browser.
## Usage
### node.js and AMD
```js
require('addresscompiler');
```### Global context
```html
```
### addresscompiler.compile
Compiles name-address e-mail addresses into a single string.
#### Examples
A single address:
```js
addresscompiler.compile({
name: "John Smith",
address: "[email protected]"
});// returns
'John Smith '
```Or a list:
```js
addresscompiler.compile([{
name: "Bach, Sebastian",
address: "[email protected]"
}, {
name: "Mozzie",
address: "[email protected]"
}]);// returns
'"Bach, Sebastian" , Mozzie '
```And when using groups
```js
addresscompiler.compile([{
name: "Composers",
group: [{
address: "[email protected]",
name: "Bach, Sebastian"
}, {
address: "[email protected]",
name: "Mozzie"
}]
}]);// returns
'Composers:"Bach, Sebastian" , Mozzie ;'
```## See also
- [addressparser](https://github.com/whiteout-io/addressparser) - similar library to do the inverse
- [Source partially extracted from whiteout-io/mailbuild](https://github.com/whiteout-io/mailbuild/blob/1a77037e6c2438ee12b6d3e12f1f29c487147bbc/src/mailbuild.js#L661-L713)
- [Python implementation](https://github.com/python-git/python/blob/715a6e5035bb21ac49382772076ec4c630d6e960/Lib/email/utils.py#L83-L98)## MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.