@reldens/utils 0.35.0 → 0.36.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.
Files changed (2) hide show
  1. package/lib/shortcuts.js +16 -1
  2. package/package.json +1 -1
package/lib/shortcuts.js CHANGED
@@ -129,11 +129,26 @@ class Shortcuts
129
129
 
130
130
  sortObjectKeysBy(obj, sortField)
131
131
  {
132
- return Object.keys(obj).sort((a,b) => {
132
+ return Object.keys(obj).sort((a, b) => {
133
133
  return (obj[a][sortField] > obj[b][sortField]) ? 1 : -1;
134
134
  });
135
135
  }
136
136
 
137
+ arraySort(collection, sortField, direction = 'asc')
138
+ {
139
+ if(!collection){
140
+ return collection;
141
+ }
142
+ if(!sortField){
143
+ return collection;
144
+ }
145
+ let directionValue = 'act' === direction ? 1 : -1;
146
+ let directionOpposite = 'act' === direction ? -1 : 1;
147
+ return collection.sort((a, b) => {
148
+ return a[sortField] > b[sortField] ? directionValue : directionOpposite;
149
+ });
150
+ }
151
+
137
152
  propsAssign(from, to, props)
138
153
  {
139
154
  if(!this.isArray(props)){
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reldens/utils",
3
3
  "scope": "@reldens",
4
- "version": "0.35.0",
4
+ "version": "0.36.0",
5
5
  "description": "Reldens - Utils",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",