Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineBuildConfig } from 'unbuild'
import { defineBuildConfig } from 'unbuild';

export default defineBuildConfig({
entries: [
'src/index',
],
declaration: true,
clean: true,
})
});
57 changes: 57 additions & 0 deletions docs/obfuscate-email.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# `obfuscate-email`

## Usage

```js
import { obfuscateEmail } from '@markterence/utils/core';

obfuscateEmail('user@example.com');

// Output: 'u***@e********m'
```

## Options

### `keepNameFirst`

- **Type:** `number`
- **Description:** The number of characters to keep from the start of the name.

### `keepNameLast`

- **Type:** `number`
- **Description:** The number of characters to keep from the end of the name.

### `keepDomainFirst`

- **Type:** `number`
- **Description:** The number of characters to keep from the start of the domain.

### `keepDomainLast`

- **Type:** `number`
- **Description:** The number of characters to keep from the end of the domain. This will include the TLD (.com, .org, .net, etc).

### `replacementChar`

- **Type:** `string`
- **Default:** `'*'`
- **Description:** The character to use as a replacement for obfuscation.

## Example Usage

```typescript
import { obfuscateEmail } from './obfuscate-email';

const email = 'test@example.com';
const options = {
keepNameFirst: 1,
keepNameLast: 1,
keepDomainFirst: 1,
keepDomainLast: 3,
replacementChar: '*'
};

const obfuscatedEmail = obfuscateEmail(email, options);
console.log(obfuscatedEmail); // Output: t**t@e******.com
```
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
"typecheck": "tsc --noEmit",
"prepare": "simple-git-hooks"
},
"dependencies": {
"dayjs": "^1.11.13"
},
"devDependencies": {
"@antfu/eslint-config": "^3.14.0",
"@antfu/ni": "^23.2.0",
Expand Down
Loading