@quenty/attributeutils 4.2.0 → 4.2.2-canary.4c04014.0

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
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.2.2-canary.4c04014.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/attributeutils@4.2.1...@quenty/attributeutils@4.2.2-canary.4c04014.0) (2022-01-17)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add AttributeUtils.getAttribute method ([af2742f](https://github.com/Quenty/NevermoreEngine/commit/af2742f792a07c2409d7cac3bfec54e004a056b2))
12
+
13
+
14
+
15
+
16
+
17
+ ## [4.2.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/attributeutils@4.2.0...@quenty/attributeutils@4.2.1) (2022-01-16)
18
+
19
+ **Note:** Version bump only for package @quenty/attributeutils
20
+
21
+
22
+
23
+
24
+
6
25
  # [4.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/attributeutils@4.1.0...@quenty/attributeutils@4.2.0) (2022-01-07)
7
26
 
8
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/attributeutils",
3
- "version": "4.2.0",
3
+ "version": "4.2.2-canary.4c04014.0",
4
4
  "description": "Provides utility functions to work with attributes in Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,12 +25,12 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/loader": "^3.3.0",
29
- "@quenty/maid": "^2.0.2",
30
- "@quenty/rx": "^3.7.0"
28
+ "@quenty/loader": "3.3.1-canary.4c04014.0",
29
+ "@quenty/maid": "2.0.3-canary.4c04014.0",
30
+ "@quenty/rx": "3.7.2-canary.4c04014.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "5a3f3fb6c908fd3874f5ceacc70b404780275119"
35
+ "gitHead": "4c040145693283525ba3f4c793cead7abee28fb2"
36
36
  }
@@ -86,6 +86,9 @@ end
86
86
  @return any? -- The value of the attribute
87
87
  ]=]
88
88
  function AttributeUtils.initAttribute(instance, attributeName, default)
89
+ assert(typeof(instance) == "Instance", "Bad instance")
90
+ assert(typeof(attributeName) == "string", "Bad attributeName")
91
+
89
92
  local value = instance:GetAttribute(attributeName)
90
93
  if value == nil then
91
94
  instance:SetAttribute(attributeName, default)
@@ -94,4 +97,21 @@ function AttributeUtils.initAttribute(instance, attributeName, default)
94
97
  return value
95
98
  end
96
99
 
100
+ --[=[
101
+ Retrieves an attribute, and if it is nil, returns the default
102
+ instead.
103
+ @param instance Instance
104
+ @param attributeName string
105
+ @param default T?
106
+ @return T?
107
+ ]=]
108
+ function AttributeUtils.getAttribute(instance, attributeName, default)
109
+ local value = instance:GetAttribute(attributeName)
110
+ if value == nil then
111
+ return default
112
+ end
113
+
114
+ return value
115
+ end
116
+
97
117
  return AttributeUtils