@cocreate/unique 1.20.0 → 1.20.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
@@ -1,3 +1,10 @@
1
+ ## [1.20.1](https://github.com/CoCreate-app/CoCreate-unique/compare/v1.20.0...v1.20.1) (2024-12-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * formating ([3bfb89f](https://github.com/CoCreate-app/CoCreate-unique/commit/3bfb89fec9dfb643655f3e0ba093a98e447ee7c3))
7
+
1
8
  # [1.20.0](https://github.com/CoCreate-app/CoCreate-unique/compare/v1.19.8...v1.20.0) (2024-11-04)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/unique",
3
- "version": "1.20.0",
3
+ "version": "1.20.1",
4
4
  "description": "A simple unique component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "unique",
package/src/server.js CHANGED
@@ -1,47 +1,46 @@
1
1
  class CoCreateUnique {
2
- /**
3
- * @param crud
4
- */
5
- constructor(crud) {
6
- this.wsManager = crud.wsManager
7
- this.crud = crud
8
- this.init();
9
- }
2
+ /**
3
+ * @param crud
4
+ */
5
+ constructor(crud) {
6
+ this.wsManager = crud.wsManager;
7
+ this.crud = crud;
8
+ this.init();
9
+ }
10
10
 
11
- init() {
12
- if (this.wsManager) {
13
- this.wsManager.on('isUnique', (data) => this.isUnique(data));
14
- }
15
- }
11
+ init() {
12
+ if (this.wsManager) {
13
+ this.wsManager.on("isUnique", (data) => this.isUnique(data));
14
+ }
15
+ }
16
16
 
17
+ /**
18
+ * Checks if a object is unique by sending a message to the socket. This is a blocking call so it returns a Promise
19
+ *
20
+ * @param socket - the socket to send the message to
21
+ * @param data - the data to read from the database usually an object
22
+ *
23
+ * @return { Promise } - resolves with the response from the server or rejects with an error if there was a
24
+ */
25
+ async isUnique(data) {
26
+ const self = this;
27
+ try {
28
+ data.method = "object.read";
29
+ this.crud.send(data).then((data) => {
30
+ data.method = "isUnique";
17
31
 
18
- /**
19
- * Checks if a object is unique by sending a message to the socket. This is a blocking call so it returns a Promise
20
- *
21
- * @param socket - the socket to send the message to
22
- * @param data - the data to read from the database usually an object
23
- *
24
- * @return { Promise } - resolves with the response from the server or rejects with an error if there was a
25
- */
26
- async isUnique(data) {
27
- const self = this
28
- try {
29
- data.method = 'object.read'
30
- this.crud.send(data).then((data) => {
31
- data.method = 'isUnique'
32
-
33
- if (data.object.length) {
34
- data.unique = false;
35
- } else
36
- data.unique = true;
37
-
38
- return self.wsManager.send(data);
39
- })
40
- } catch (error) {
41
- console.log(error);
42
- }
43
- }
32
+ if (data.object.length) {
33
+ data.unique = false;
34
+ } else {
35
+ data.unique = true;
36
+ }
44
37
 
38
+ return self.wsManager.send(data);
39
+ });
40
+ } catch (error) {
41
+ console.log(error);
42
+ }
43
+ }
45
44
  }
46
45
 
47
- module.exports = CoCreateUnique;
46
+ module.exports = CoCreateUnique;