Skip to content

Commit bf8a545

Browse files
committed
add array shufle snippet
1 parent 9f3f81f commit bf8a545

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"arssd",
3838
"artsna",
3939
"artsnd",
40+
"arus",
4041
"aruv",
4142
"caaf",
4243
"caaft",
@@ -57,6 +58,7 @@
5758
"paypal",
5859
"pranav",
5960
"SWPM",
61+
"unsort",
6062
"volta",
6163
"vuejs"
6264
],

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Fixed for any bug fixes.
99
Security to invite users to upgrade in case of vulnerabilities.
1010
-->
1111

12+
## 3.5.0 - 2023/05/17
13+
14+
### Added
15+
16+
- array unsort or shuffle
17+
1218
## 3.4.0 - 2023/04/26
1319

1420
### Added

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,16 @@ Below is a list of all available snippets and the triggers of each one. The `░
163163
| `arfne→` | filter not equal | `const ░newArray = ░array.filter((░element) => ░element !== ░value)█` |
164164
| `arfoeq→` | filter object equal | `const ░newArray = ░array.filter((░element) => ░element.░prop === ░value)█` |
165165
| `arfone→` | filter object not equal | `const ░newArray = ░array.filter((░element) => ░element.░prop !== ░value)█` |
166-
| `arssa→` | sort string ascending | `░array.░sort((a, z) => a.localeCompare(z))█` |
167-
| `arssd→` | sort string descending | `░array.░sort((a, z) => z.localeCompare(a))█` |
168-
| `arsna→` | sort number ascending | `░array.░sort((a, z) => a - z)█` |
169-
| `arsnd→` | sort number descending | `░array.░sort((a, z) => z - a)█` |
170-
| `arsba→` | sort boolean ascending | `░array.░sort((a, z) => Boolean(a) - Boolean(z))█` |
171-
| `arsbd→` | sort boolean descending | `░array.░sort((a, z) => Boolean(z) - Boolean(a))█` |
172-
| `arsda→` | sort date ascending | `░array.░sort((a, z) => new Date(a) - new Date(z))█` |
173-
| `arsdd→` | sort date descending | `░array.░sort((a, z) => new Date(z) - new Date(a))c` |
166+
| `arssa→` | sort string ascending | `░array.░sort((a, z) => a.localeCompare(z))█` |
167+
| `arssd→` | sort string descending | `░array.░sort((a, z) => z.localeCompare(a))█` |
168+
| `arsna→` | sort number ascending | `░array.░sort((a, z) => a - z)█` |
169+
| `arsnd→` | sort number descending | `░array.░sort((a, z) => z - a)█` |
170+
| `arsba→` | sort boolean ascending | `░array.░sort((a, z) => Boolean(a) - Boolean(z))█` |
171+
| `arsbd→` | sort boolean descending | `░array.░sort((a, z) => Boolean(z) - Boolean(a))█` |
172+
| `arsda→` | sort date ascending | `░array.░sort((a, z) => new Date(a) - new Date(z))█` |
173+
| `arsdd→` | sort date descending | `░array.░sort((a, z) => new Date(z) - new Date(a))` |
174174
| `arso→` | sort object by properties | <code>░array.░sort((a, z) => {<br/>&nbsp;&nbsp;const sort = {<br/>&nbsp;&nbsp;&nbsp;&nbsp;░propString: a.░propString.localeCompare(z.░propString),<br/>&nbsp;&nbsp;&nbsp;&nbsp;░propNumber: a.░propNumber - z.░propNumber,<br/>&nbsp;&nbsp;&nbsp;&nbsp;░propBoolean: Boolean(a.░propBoolean) - Boolean(z.░propBoolean),<br/>&nbsp;&nbsp;&nbsp;&nbsp;░propDate: new Date(a.░propDate) - new Date(z.░propDate),<br/>&nbsp;&nbsp;}<br/><br/>&nbsp;&nbsp;return sort.░propString &#124;&#124; -sort.░propNumber &#124;&#124; sort.░propBoolean &#124;&#124; sort.░propDate<br>})█</code> |
175+
| `arus→` | unsort / shuffle | `░array.░sort(() => Math.random() - 0.5)█` |
175176
| `aruv→` | unique values | `const ░newArray = ░array.filter((░current, ░index, ░arr) => ░arr.indexOf(░current) == ░index)█` |
176177

177178
### Functions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "arrow-function-snippets",
33
"description": "VS Code Arrow function snippets for JS and TS",
4-
"version": "3.4.0",
4+
"version": "3.5.0",
55
"displayName": "Arrow Function Snippets",
66
"publisher": "deinsoftware",
77
"icon": "images/light-icon.png",

snippets/arrays.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@
7575
],
7676
"description": "Array sort object by properties"
7777
},
78+
"array.Unsort": {
79+
"prefix": "arus",
80+
"body": "${1:array}.${2|sort,toSorted|}(() => Math.random() - 0.5)$0",
81+
"description": "Array unsort or shuffle"
82+
},
7883
"array.UniqueValues": {
7984
"prefix": "aruv",
8085
"body": "const ${1:newArray} = ${2:array}.filter((${3:current}, ${4:index}, ${5:arr}) => ${5:arr}.indexOf(${3:current}) == ${4:index})$0",

0 commit comments

Comments
 (0)