@already-existed/email-obfuscator
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

EmailObfuscator

Lib for obfuscate email on server and unobfuscate on client.

Installation

npm i -S @already-existed/email-obfuscator

Usage

<!-- html -->
<a data-email="true" href="mailto:[email-href]some-email@some.com[/email-href]">
  [email]some-email@some.com[/email]
</a>
// server
import { obfuscateEmail } from '@already-existed/email-obfuscator'

...
res.send(obfuscateEmail(html))
...
// client
import { unobfuscateEmail } from '@already-existed/email-obfuscator'

window.addEventListener('load', () => {
  unobfuscateEmail()
})

Options

// 'binary' - slow
// 'base64' - fast
type ObfuscateType = 'binary' | 'base64'

interface ObfuscateOptions {
  type?: ObfuscateType // default: 'binary'
}

obfuscateEmail(value: string, opts?: ObfuscateOptions): string
unobfuscateEmail(opts?: ObfuscateOptions): void

/@already-existed/email-obfuscator/

    Package Sidebar

    Install

    npm i @already-existed/email-obfuscator

    Weekly Downloads

    7

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    20.9 kB

    Total Files

    29

    Last publish

    Collaborators

    • already-existed