Skip to content

Commit 21f0c7f

Browse files
committed
Update JsArray.java
1 parent e912a5b commit 21f0c7f

File tree

1 file changed

+25
-23
lines changed
  • src/main/java/io/github/jeemv/springboot/vuejs/utilities

1 file changed

+25
-23
lines changed
Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
11
package io.github.jeemv.springboot.vuejs.utilities;
22

3-
43
/**
5-
* JsArray
6-
* Javascript array utilities
7-
* This class is part of springBoot-VueJS
4+
* JsArray Javascript array utilities This class is part of springBoot-VueJS
5+
*
86
* @author jcheron myaddressmail@gmail.com
9-
* @version 1.0.0
7+
* @version 1.0.1
108
*
119
*/
1210
public class JsArray {
13-
11+
1412
/**
1513
* Remove an element from array
16-
* @param array the array reference
14+
*
15+
* @param array the array reference
1716
* @param element the element to remove
1817
* @return
1918
*/
20-
public static String remove(String array,String element) {
21-
return array+".splice(self.orgas.indexOf("+element+"), 1);";
19+
public static String remove(String array, String element) {
20+
return array + ".splice(array.indexOf(" + element + "), 1);";
2221
}
23-
22+
2423
/**
2524
* Replace an element at index position in array
26-
* @param array the array reference
27-
* @param index The index of the element to replace
25+
*
26+
* @param array the array reference
27+
* @param index The index of the element to replace
2828
* @param element The element to replace with
2929
* @return
3030
*/
31-
public static String replace(String array,String index,String element) {
32-
return " Object.assign("+array+"["+index+"], "+element+");";
31+
public static String replace(String array, String index, String element) {
32+
return " Object.assign(" + array + "[" + index + "], " + element + ");";
3333
}
34-
34+
3535
/**
3636
* Adds an element to array
37-
* @param array The array reference
37+
*
38+
* @param array The array reference
3839
* @param element The element to add
3940
* @return
4041
*/
41-
public static String add(String array,String element) {
42-
return array+".push("+element+");";
42+
public static String add(String array, String element) {
43+
return array + ".push(" + element + ");";
4344
}
44-
45+
4546
/**
4647
* Adds or replace an element in array
47-
* @param array The array reference
48-
* @param index The index of the element to replace or -1 for adding
48+
*
49+
* @param array The array reference
50+
* @param index The index of the element to replace or -1 for adding
4951
* @param element The element to add or replace
5052
* @return
5153
*/
52-
public static String addOrReplace(String array,String index,String element) {
53-
return "if("+index+">-1){"+replace(array, index, element)+"}else{"+add(array, element)+"}";
54+
public static String addOrReplace(String array, String index, String element) {
55+
return "if(" + index + ">-1){" + replace(array, index, element) + "}else{" + add(array, element) + "}";
5456
}
5557
}

0 commit comments

Comments
 (0)