frontacles 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,9 +10,17 @@ Nothing for now.
10
10
 
11
11
  Compare with [last published version](https://github.com/frontacles/frontacles/compare/0.2.0...main).
12
12
 
13
- ## v1.4.0 (2025-02-28)
13
+ ## v0.2.1 (2025-02-28)
14
14
 
15
- Compare with [previous version](https://github.com/frontacles/frontacles/compare/dda10c3...0.2).
15
+ Compare with [previous version](https://github.com/frontacles/frontacles/compare/0.2.0...0.2.1).
16
+
17
+ ### Improved
18
+
19
+ - `Email` is now a couple of bytes lighter.
20
+
21
+ ## v0.2.0 (2025-02-28)
22
+
23
+ Compare with [previous version](https://github.com/frontacles/frontacles/compare/dda10c3...0.2.0).
16
24
 
17
25
  ### New
18
26
 
package/README.md CHANGED
@@ -7,7 +7,7 @@ Cool utilities for front-end development (and potentially for Node).
7
7
 
8
8
  ## Email
9
9
 
10
- A class to instantiate an `Email` object or validate emails.
10
+ A class to instantiate an `Email` object or validate emails. It’s only [222 B compressed](https://bundlejs.com/?q=frontacles&treeshake=[{Email}]&config={%22compression%22%3A%22brotli%22}&bundle).
11
11
 
12
12
  Unlike most libraries using [RegEx for emails](https://github.com/colinhacks/zod/blob/e2b9a5f9ac67d13ada61cd8e4b1385eb850c7592/src/types.ts#L648-L663) (and prone to [bugs](https://github.com/colinhacks/zod/issues/3913)), Frontacles `Email` class relies on the same mechanism as your browser to validate email addresses, making it robust, and very likely RFC compliant.
13
13
 
@@ -17,11 +17,11 @@ import { Email } from 'frontacles/url/email'
17
17
  const email = new Email('someone@domain.tld')
18
18
  ```
19
19
 
20
- Get the username and the host separately.
20
+ Get the username and the hostname separately.
21
21
 
22
22
  ```js
23
23
  email.username // 'someone'
24
- email.host // 'domain.tld'
24
+ email.hostname // 'domain.tld'
25
25
  ```
26
26
 
27
27
  Turn the email object into a string by using it along another string, or use `toString`.
@@ -53,3 +53,27 @@ const alsoEmail = new Email(email) // ✅ a new Email object!
53
53
 
54
54
  Email.canParse(email) // ✅ true
55
55
  ```
56
+
57
+ ## Changelog
58
+
59
+ See [CHANGELOG.md](https://github.com/frontacles/frontacles/blob/main/CHANGELOG.md) or the [releases](https://github.com/frontacles/frontacles/releases).
60
+
61
+ ## Browser and tooling support
62
+
63
+ `frontacles` is provided [as module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#browser_compatibility) for [modern browsers usage](https://github.com/frontacles/frontacles/blob/main/browserslist) with standard JavaScript syntax:
64
+ - it is up to you to transpile it for legacy browsers;
65
+ - you can’t import it using `require('frontacles')`.
66
+
67
+ [Read more about ESModules](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
68
+
69
+ ## Security
70
+
71
+ See the [security policy](https://github.com/frontacles/frontacles/blob/main/SECURITY.md).
72
+
73
+ ## Contributing
74
+
75
+ See the [contributing guidelines](https://github.com/frontacles/frontacles/blob/main/CONTRIBUTING.md).
76
+
77
+ ## License
78
+
79
+ The _datetime-attribute_ package is open-sourced software licensed under the [DWTFYWTPL](https://github.com/frontacles/frontacles/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontacles",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Front-end utilities for artisans",
5
5
  "type": "module",
6
6
  "sideEffects": false,
package/src/url/email.js CHANGED
@@ -18,8 +18,8 @@ export class Email extends URL {
18
18
  *
19
19
  * In `username@domain.tld`, it is `domain.tld`.
20
20
  */
21
- get host() {
22
- return super.host
21
+ get hostname() {
22
+ return super.hostname
23
23
  }
24
24
 
25
25
  /**
@@ -32,7 +32,7 @@ export class Email extends URL {
32
32
  }
33
33
 
34
34
  toJSON () {
35
- return `${this.username}@${this.host}`
35
+ return this.toString()
36
36
  }
37
37
 
38
38
  /**
@@ -41,18 +41,16 @@ export class Email extends URL {
41
41
  * situation where type casting to string is involved (`console.log`…).
42
42
  */
43
43
  toString () {
44
- return `${this.username}@${this.host}`
44
+ return `${this.username}@${this.hostname}`
45
45
  }
46
46
 
47
47
  /**
48
- * Recompose the email address and compare it to the input. We also make sure
49
- * there is no port since `someone@domain.tld:3000` is valid for the `URL`
50
- * constructor but adds `:{port}` to `this.host` (`domain.tld:3000`).
48
+ * Recompose the email address and compare it to the input.
51
49
  *
52
50
  * @param {string} address
53
51
  */
54
52
  #validate (address) {
55
- return `${this.username}@${this.host}` == address && !this.port
53
+ return this.toString() == address
56
54
  }
57
55
 
58
56
  /**
package/types/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export class Email extends URL {
16
16
  *
17
17
  * In `username@domain.tld`, it is `domain.tld`.
18
18
  */
19
- get host(): string;
19
+ get hostname(): string;
20
20
  /**
21
21
  * The username of the email.
22
22
  *