diff --git a/ryjsxt-test.html b/ryjsxt-test.html
new file mode 100644
index 0000000..2185d8d
--- /dev/null
+++ b/ryjsxt-test.html
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ryjsxt.js b/ryjsxt.js
index 7073f48..407b476 100644
--- a/ryjsxt.js
+++ b/ryjsxt.js
@@ -4,6 +4,20 @@
*/
+Array.prototype.index = function (propName, value) {
+ for (let i = 0; i < this.length; i++) {
+ if (typeof(this[i][propName]) == "undefined") {
+ continue;
+ }
+
+ if (this[i][propName] == value){
+ return i;
+ }
+ }
+
+ return -1;
+};
+
Array.prototype.insert = function(index, item) {
if (index < 0) {
this.splice(0, 0, item);
@@ -36,6 +50,64 @@ Array.prototype.joinIfNotNullOrWhitespace = function (separator) {
return result;
};
+Array.prototype.first = function (propName, value) {
+ for (let i = 0; i < this.length; i++) {
+ if (typeof(this[i][propName]) == "undefined") {
+ continue;
+ }
+
+ if (this[i][propName] == value){
+ return this[i];
+ }
+ }
+
+ return null;
+};
+
+Array.prototype.indexes = function (propName, value) {
+ let result = [];
+
+ for (let i = 0; i < this.length; i++) {
+ if (typeof(this[i][propName]) == "undefined") {
+ continue;
+ }
+
+ if (this[i][propName] == value){
+ result.push(i);
+ }
+ }
+
+ return result;
+};
+
+Array.prototype.orderBy = function (propName) {
+ this.sort(function(a, b) {
+ if (a[propName] < b[propName]) {
+ return -1;
+ } else if (a[propName] > b[propName]) {
+ return 1;
+ } else {
+ return 0;
+ }
+ });
+
+ return this;
+};
+
+Array.prototype.orderByDesc = function (propName) {
+ this.sort(function(a, b) {
+ if (a[propName] < b[propName]) {
+ return 1;
+ } else if (a[propName] > b[propName]) {
+ return -1;
+ } else {
+ return 0;
+ }
+ });
+
+ return this;
+};
+
Array.prototype.removeAt = function(index) {
if ((index < 0) || (index >= this.length)) {
return this;
@@ -46,6 +118,22 @@ Array.prototype.removeAt = function(index) {
return this;
};
+Array.prototype.select = function (propName, value) {
+ let result = [];
+
+ for (let i = 0; i < this.length; i++) {
+ if (typeof(this[i][propName]) == "undefined") {
+ continue;
+ }
+
+ if (this[i][propName] == value){
+ result.push(this[i]);
+ }
+ }
+
+ return result;
+};
+
@@ -176,6 +264,26 @@ String.isNullOrWhitespace = function(value) {
}
};
+String.joinIfNotNullOrWhitespace = function (separator, ...values) {
+ const a = this;
+
+ let result = "";
+
+ for (let i = 0; i < values.length; i++) {
+ if (String.isNullOrWhitespace(values[i])) {
+ continue;
+ }
+
+ if (!String.isNullOrWhitespace(result)) {
+ result += separator;
+ }
+
+ result += values[i];
+ };
+
+ return result;
+};
+
String.prototype.contains = function(...args) {
for (let arg of args) {
if (this == arg) {
diff --git a/ryjsxt.min.js b/ryjsxt.min.js
index 466f3de..6623d80 100644
--- a/ryjsxt.min.js
+++ b/ryjsxt.min.js
@@ -2,4 +2,4 @@
* Ray's JavaScript Extension
* @version v0.1.0.018 (2023/12/09 0356)
*/
-Array.prototype.insert=function(t,e){return t<0?this.splice(0,0,e):t>=this.length?this.push(0,0,e):this.splice(t,0,e),this},Array.prototype.joinIfNotNullOrWhitespace=function(t){let e="";for(let r=0;r=this.length||this.splice(t,1),this},Boolean.isFalse=function(t){return!!String.isNullOrUndefined(t)||t.toString().containsCI("false","f","y","0","x")},Boolean.isTrue=function(t){return!String.isNullOrUndefined(t)&&t.toString().containsCI("true","t","n","1","o")},Boolean.ifTrue=function(t,e,r){return Boolean.isTrue(t)?e:r},Date.prototype.toCString=function(t){let e=t;return e=e.replace("fffffff",this.getMilliseconds().toString().padStart(7,"0")),e=e.replace("ffffff",this.getMilliseconds().toString().padStart(6,"0")),e=e.replace("fffff",this.getMilliseconds().toString().padStart(5,"0")),e=e.replace("yyyy",this.getFullYear().toString().padStart(4,"0")),e=e.replace("MMMM","{1}"),e=e.replace("dddd","{2}"),e=e.replace("ffff",this.getMilliseconds().toString().padStart(4,"0")),e=e.replace("yyy",this.getFullYear().toString().padStart(3,"0")),e=e.replace("MMM","{3}"),e=e.replace("ddd","{4}"),e=e.replace("fff",this.getMilliseconds().toString().padStart(3,"0")),e=e.replace("zzz",""),e=e.replace("yy",this.getFullYear().toString().slice(-2)),e=e.replace("MM",(this.getMonth()+1).toString().padStart(2,"0")),e=e.replace("dd",this.getDate().toString().padStart(2,"0")),e=e.replace("HH",this.getHours().toString().padStart(2,"0")),e=e.replace("hh",(this.getHours()>12?this.getHours()-12:this.getHours()).toString().padStart(2,"0")),e=e.replace("mm",this.getMinutes().toString().padStart(2,"0")),e=e.replace("ss",this.getSeconds().toString().padStart(2,"0")),e=e.replace("ff",this.getMilliseconds().toString().padStart(2,"0")),e=e.replace("tt","{5}"),e=e.replace("zz",""),e=e.replace("y",this.getFullYear().toString()),e=e.replace("M",(this.getMonth()+1).toString()),e=e.replace("d",this.getDate().toString()),e=e.replace("H",this.getHours().toString()),e=e.replace("h",(this.getHours()>12?this.getHours()-12:this.getHours()).toString()),e=e.replace("m",this.getMinutes().toString()),e=e.replace("s",this.getSeconds().toString()),e=e.replace("z",""),e=e.replace("t","{6}"),e=e.replace("Z",""),e=e.replace("{1}",this.toLocaleString("default",{month:"long"})),e=e.replace("{2}",this.toLocaleString("default",{weekday:"long"})),e=e.replace("{3}",this.toLocaleString("default",{month:"short"})),e=e.replace("{4}",this.toLocaleString("default",{weekday:"short"})),e=e.replace("{5}",this.getHours()>=12?"PM":"AM"),e=e.replace("{6}",this.getHours()>=12?"P":"A"),e},Document.ready=async function(t){!async function(){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",(function(){t()}))}()},Math.randomN=function(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t)+t)},String.isNullOrUndefined=function(t){return void 0===t||null==t},String.isNullOrWhitespace=function(t){return!!String.isNullOrUndefined(t)||("string"==typeof t?t.trim().length<=0:t.toString().trim().length<=0)},String.prototype.contains=function(...t){for(let e of t)if(this==e)return!0;return!1},String.prototype.containsCI=function(...t){for(let e of t)if(this.toLowerCase()==e.toLowerCase())return!0;return!1},String.prototype.encodeHtmlLinks=function(){return value.replace(/(http[s]{0,1}:\/\/[^\s]+)/g,"$1")},String.prototype.toTitleCase=function(){let t=this;return t=t.replace(/([A-Z]{1})/g," $1"),t=t.trim(),t=t.charAt(0).toUpperCase()+t.substr(1),t},String.prototype.getFilename=function(){return this.substring(this.lastIndexOf("/")+1)},Window.goToTop=function(){Window.scrollTo(0,0)},Window.fragment={get:function(){if(!window.location.hash)return null;const t=window.location.hash.indexOf("?");return t<0?window.location.hash.substring(1):window.location.hash.substring(1,t)},getQuery:function(){if(!window.location.hash)return null;let t=window.location.hash;const e=t.indexOf("?");if(e<0)return null;t=hasQueryString.substring(e+1);const r=new URLSearchParams(t),n={};for(const[t,e]of r.entries())n[t]=e;return n},clear:function(){location.hash="",history.replaceState("","",location.pathname)}};
\ No newline at end of file
+Array.prototype.index=function(t,e){for(let r=0;r=this.length?this.push(0,0,e):this.splice(t,0,e),this},Array.prototype.joinIfNotNullOrWhitespace=function(t){let e="";for(let r=0;rr[t]?1:0})),this},Array.prototype.orderByDesc=function(t){return this.sort((function(e,r){return e[t]r[t]?-1:0})),this},Array.prototype.removeAt=function(t){return t<0||t>=this.length||this.splice(t,1),this},Array.prototype.select=function(t,e){let r=[];for(let n=0;n12?this.getHours()-12:this.getHours()).toString().padStart(2,"0")),e=e.replace("mm",this.getMinutes().toString().padStart(2,"0")),e=e.replace("ss",this.getSeconds().toString().padStart(2,"0")),e=e.replace("ff",this.getMilliseconds().toString().padStart(2,"0")),e=e.replace("tt","{5}"),e=e.replace("zz",""),e=e.replace("y",this.getFullYear().toString()),e=e.replace("M",(this.getMonth()+1).toString()),e=e.replace("d",this.getDate().toString()),e=e.replace("H",this.getHours().toString()),e=e.replace("h",(this.getHours()>12?this.getHours()-12:this.getHours()).toString()),e=e.replace("m",this.getMinutes().toString()),e=e.replace("s",this.getSeconds().toString()),e=e.replace("z",""),e=e.replace("t","{6}"),e=e.replace("Z",""),e=e.replace("{1}",this.toLocaleString("default",{month:"long"})),e=e.replace("{2}",this.toLocaleString("default",{weekday:"long"})),e=e.replace("{3}",this.toLocaleString("default",{month:"short"})),e=e.replace("{4}",this.toLocaleString("default",{weekday:"short"})),e=e.replace("{5}",this.getHours()>=12?"PM":"AM"),e=e.replace("{6}",this.getHours()>=12?"P":"A"),e},Document.ready=async function(t){!async function(){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",(function(){t()}))}()},Math.randomN=function(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t)+t)},String.isNullOrUndefined=function(t){return void 0===t||null==t},String.isNullOrWhitespace=function(t){return!!String.isNullOrUndefined(t)||("string"==typeof t?t.trim().length<=0:t.toString().trim().length<=0)},String.joinIfNotNullOrWhitespace=function(t,...e){let r="";for(let n=0;n$1")},String.prototype.toTitleCase=function(){let t=this;return t=t.replace(/([A-Z]{1})/g," $1"),t=t.trim(),t=t.charAt(0).toUpperCase()+t.substr(1),t},String.prototype.getFilename=function(){return this.substring(this.lastIndexOf("/")+1)},Window.goToTop=function(){Window.scrollTo(0,0)},Window.fragment={get:function(){if(!window.location.hash)return null;const t=window.location.hash.indexOf("?");return t<0?window.location.hash.substring(1):window.location.hash.substring(1,t)},getQuery:function(){if(!window.location.hash)return null;let t=window.location.hash;const e=t.indexOf("?");if(e<0)return null;t=hasQueryString.substring(e+1);const r=new URLSearchParams(t),n={};for(const[t,e]of r.entries())n[t]=e;return n},clear:function(){location.hash="",history.replaceState("","",location.pathname)}};
\ No newline at end of file