dphelper 0.2.37 → 0.2.42

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.
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: passariello
4
+ patreon: passariello
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: passariello
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: passariello
10
+ issuehunt: passariello
11
+ otechie: # Replace with a single Otechie username
12
+ custom: ["https://dario.passariello.ca", "https://www.paypal.me/dariopassariello", "https://www.indiegogo.com/individuals/28513718"]
@@ -0,0 +1,12 @@
1
+ # Basic dependabot.yml file with
2
+ # minimum configuration for two package managers
3
+
4
+ version: 2
5
+ updates:
6
+ # Enable version updates for npm
7
+ - package-ecosystem: "npm"
8
+ # Look for `package.json` and `lock` files in the `root` directory
9
+ directory: "/"
10
+ # Check the npm registry for updates every day (weekdays)
11
+ schedule:
12
+ interval: "daily"
package/README.md CHANGED
@@ -16,12 +16,21 @@ Please visit the github repository @ [dpHelper on Github](https://github.com/pas
16
16
 
17
17
  ```js
18
18
  npm i dphelper
19
+
20
+ or update:
21
+
22
+ npm i dphelper@latest
23
+
19
24
  ```
20
25
 
21
26
  in the index (and only there):
22
27
 
23
28
  ```js
24
29
  import "dphelper"
30
+
31
+ or
32
+
33
+ require("dphelper")
25
34
  ```
26
35
 
27
36
  ## check
package/init.js CHANGED
@@ -17,23 +17,22 @@
17
17
 
18
18
  // CREATE ROOT STORE
19
19
  const dphelper = window.dphelper = {};
20
-
21
- window.dphelper._list = require('./data/list.json');
20
+
21
+ window.dphelper._list = require('./data/list.json');
22
22
  window.dphelper._list.scripts = [];
23
23
  window.dphelper._list.version = pjson.version;
24
24
 
25
25
  const cache = {};
26
26
 
27
- function importAll(r){
28
- r.keys().forEach(
29
- (key) => (
30
- cache[key] = r(key)
27
+ const importAll = ( cntx ) => {
28
+ cntx.keys().forEach(
29
+ ( key ) => (
30
+ cache[ key ] = cntx( key )
31
31
  )
32
- );
33
- }
34
-
35
- importAll( require.context( __dirname + '/scripts/', false, /\.js$/) );
36
-
32
+ );
33
+ };
34
+ var cntx = require.context( __dirname + '/scripts/', false , /\.js$/ );
35
+ importAll( cntx );
37
36
 
38
37
  // FIRST MESSAGE
39
38
  console.groupCollapsed( `%c${pjson.name} v${pjson.version}%c`,"color:orange","" );
@@ -49,88 +48,4 @@
49
48
  console.debug( 'email: %c' + pjson.author.email,"color:orange","" );
50
49
  console.groupEnd();
51
50
 
52
- /*
53
- // SYSTEM
54
- require('./scripts/addListenerMulti.js');
55
-
56
- // 3party
57
- require('./3party/shortcut.js');
58
-
59
- // CURRENCY
60
- require('./scripts/currency.js');
61
-
62
- // MEMORY
63
- require('./scripts/storage.js');
64
- require('./scripts/cookie.js');
65
- require('./scripts/indexedDB.js');
66
-
67
- // NUMBERS
68
- require('./scripts/randomNum.js');
69
- require('./scripts/randomNumTmr.js');
70
-
71
- // TIME
72
- require('./scripts/epoch.js');
73
- require('./scripts/parseDate.js');
74
- require('./scripts/dateUTC.js');
75
- require('./scripts/dateIso2Epoch.js');
76
- require('./scripts/dateConvert.js');
77
- require('./scripts/date2MMDDYYYY.js');
78
- require('./scripts/date2Iso.js');
79
- require('./scripts/dateLocal-ISOTime.js');
80
-
81
- // PATH
82
- require('./scripts/pathRail.js');
83
- require('./scripts/pathQuery.js');
84
- require('./scripts/pathHash.js');
85
- require('./scripts/pushState.js');
86
- require('./scripts/anchorToOnClick.js');
87
-
88
- // FILE
89
- require('./scripts/loadFile.js');
90
- //require('./scripts/loadAsset.js');
91
- require('./scripts/loadJson.js');
92
- require('./scripts/loadJsonExternal.js');
93
-
94
- // FORMS
95
- require('./scripts/serializeForm.js');
96
- require('./scripts/serializeObj.js');
97
-
98
- // ARRAY
99
- // require('./scripts/arrayItemFinder.js');
100
- // require('./scripts/arrayDeleteItem.js');
101
- // require('./scripts/arrayMerge.js');
102
- // require('./scripts/arrayUnique.js');
103
- require('./scripts/array.js');
104
- require('./scripts/object2array.js');
105
-
106
- // SCROLL
107
- require('./scripts/scrollToElement.js');
108
- require('./scripts/scrollSmooth.js');
109
- require('./scripts/scrollIndicator.js');
110
- require('./scripts/scrollMemory.js');
111
- require('./scripts/scrollCustom.js');
112
-
113
- // OTHER
114
- require('./scripts/camelCase.js');
115
- require('./scripts/fontFit.js');
116
- require('./scripts/uuid.js');
117
- require('./scripts/noCache.js');
118
- require('./scripts/parseBool.js');
119
- require('./scripts/isPromise.js');
120
- require('./scripts/textChanger.js');
121
- require('./scripts/nl2br.js');
122
- require('./scripts/sleep.js');
123
- require('./scripts/printInfo.js');
124
- require('./scripts/disableSelect.js');
125
- require('./scripts/fullScreen.js');
126
- require('./scripts/disableSpellCheck.js');
127
- require('./scripts/triggerClick.js');
128
- require('./scripts/handleEvent.js');
129
- require('./scripts/window.js');
130
- require('./scripts/purge.js');
131
- require('./scripts/svgSupport.js');
132
- require('./scripts/stopConsole.js');
133
- require('./scripts/onBeforeUnLoad.js');
134
- */
135
-
136
51
  })();
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "dphelper",
3
- "version": "0.2.37",
3
+ "version": "0.2.42",
4
4
  "description": "Developer Tools",
5
5
  "main": "index.js",
6
- "publishConfig": {},
7
6
  "targets": {
8
7
  "main": {
9
8
  "includeNodeModules": {
@@ -17,6 +16,9 @@
17
16
  "engines": {
18
17
  "node": ">=0.10.0"
19
18
  },
19
+ "scripts": {
20
+ "updateAll": "npm version patch --force -m \"New patch commit\" && git push && git push --tags && npm publish"
21
+ },
20
22
  "repository": {
21
23
  "type": "git",
22
24
  "url": "https://github.com/passariello/dpHelper",
@@ -61,8 +63,7 @@
61
63
  "license": "Apache-2.0",
62
64
  "dependencies": {
63
65
  "jquery": "^3.6.0",
64
- "require": "^0.4.4",
65
- "uglify-js": "^3.14.5"
66
+ "require": "^2.4.20"
66
67
  },
67
68
  "contributors": [
68
69
  {
package/scripts/array.js CHANGED
@@ -24,6 +24,21 @@
24
24
  },{
25
25
  "name":"merge",
26
26
  "description":"test"
27
+ },{
28
+ "name":"asc",
29
+ "description":"test"
30
+ },{
31
+ "name":"desc",
32
+ "description":"test"
33
+ },{
34
+ "name":"duplicates",
35
+ "description":"test"
36
+ },{
37
+ "name":"even",
38
+ "description":"test"
39
+ },{
40
+ "name":"odd",
41
+ "description":"test"
27
42
  }
28
43
  ],
29
44
  "example" : "",
@@ -43,7 +58,7 @@ window.dphelper.array = {
43
58
  if (node.id === id) return node;
44
59
 
45
60
  if (node.children) {
46
- let finalNode = window.dphelper.arrayFindItem(id, node.children);
61
+ let finalNode = window.dphelper.array.find(id, node.children);
47
62
  if (finalNode) return finalNode;
48
63
  }
49
64
  }
@@ -65,14 +80,13 @@ window.dphelper.array = {
65
80
  return true;
66
81
  }
67
82
 
68
- var key = Object.keys(o);
69
-
70
83
  for (let key of Object.keys(o)) {
71
84
  let value = o[key];
72
85
  if(value.length && typeof value === 'object') return value && value.map(iter);
73
86
  }
74
87
 
75
88
  // OLD SCHOOL WAY
89
+ //var key = Object.keys(o);
76
90
  // for (var p=0; p < key.length; ++p){
77
91
  // if( o[key[p]]?.length && typeof o[key[p]] === 'object') return o[key[p]] && o[key[p]].some(iter);
78
92
  // }
@@ -83,13 +97,46 @@ window.dphelper.array = {
83
97
 
84
98
  // MERGE
85
99
  merge: ( arrayA, arrayB ) => {
86
- for (const key of Object.keys(source)) {
87
- if (source[key] instanceof Object && target[key]) Object.assign(source[key], window.dphelper.mergeArrays(target[key], source[key]));
100
+ for (const key of Object.keys(arrayA)) {
101
+ if (arrayA[key] instanceof Object && arrayB[key]) Object.assign(arrayA[key], window.dphelper.mergeArrays(arrayB[key], arrayA[key]));
88
102
  }
89
103
 
90
- Object.assign(target || {}, source);
91
- return target;
92
- }
104
+ Object.assign(arrayB || {}, arrayA);
105
+ return arrayB;
106
+ },
107
+
108
+ // ASCENDING
109
+ asc: ( array ) => {
110
+ array.sort((a, b) => a - b);
111
+ return array;
112
+ },
113
+
114
+ // ASCENDING
115
+ desc: ( array ) => {
116
+ array.sort(function(a, b){ return b-a; });
117
+ return array;
118
+ },
119
+
120
+ // FIND DUPLICATES
121
+ duplicates: ( array ) => {
122
+ const toFindDuplicates = arr => arr.filter( (item, index) => arr.indexOf( item ) !== index);
123
+ const duplicateElements = toFindDuplicates( array );
124
+ return duplicateElements;
125
+ },
126
+
127
+ even: ( array ) => {
128
+ var cur = [];
129
+ for (var i = 0; i < array.length; i++) {
130
+ if (array[i] % 2 === 0 ) cur.push(array[i]);
131
+ } return cur;
132
+ },
133
+
134
+ odd: ( array ) => {
135
+ var cur = [];
136
+ for (var i = 0; i < array.length; i++) {
137
+ if (array[i] % 2) cur.push(array[i]);
138
+ } return cur;
139
+ }
93
140
 
94
141
  };
95
142
 
@@ -39,10 +39,6 @@
39
39
  /***********************************************************************/
40
40
 
41
41
  window.dphelper.browser = {
42
-
43
- state: (state, title, url) => {
44
- return history.pushState( state, title, url );
45
- },
46
42
 
47
43
  state: (state, title, url) => {
48
44
  return history.pushState( state, title, url );
@@ -54,16 +50,16 @@
54
50
 
55
51
  back: ( times ) => {
56
52
  return history.go( -Math.abs( times ) );
57
- },
58
-
53
+ },
54
+
59
55
  reload: () => {
60
56
  // DISCARD POST
61
57
  return window.location.href = window.location.href;
62
- },
63
-
58
+ },
59
+
64
60
  href: ( url ) => {
65
61
  // DISCARD POST
66
62
  return window.location.href = url;
67
63
  }
68
-
64
+
69
65
  };
@@ -0,0 +1,41 @@
1
+ /*!
2
+ * dpHelper <https://github.com/passariello/dpHelper>
3
+ * Copyright (c) 2021, Dario Passariello.
4
+ * Licensed under the Apache-2.0 License.
5
+ */
6
+
7
+ /***********************************************************************/
8
+
9
+ var description = {
10
+ "name" : "Coordinates Tools",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "coords",
14
+ "subCommand" : [],
15
+ "example" : "",
16
+ "author" : "Dario Passariello",
17
+ "active" : true
18
+ };
19
+
20
+ window.dphelper._list.scripts.push( description );
21
+
22
+ /***********************************************************************/
23
+ //
24
+
25
+ let R = 6378.1;
26
+ window.dphelper.coords = {
27
+
28
+ degreesToRadians: ( degrees ) => {
29
+ var pi = Math.PI;
30
+ return degrees * (pi/180);
31
+ },
32
+
33
+ latToMeters: ( latitude , longitude ) => {
34
+ return R * Math.cos(latitude) * Math.cos(longitude);
35
+ },
36
+
37
+ lngToMeters: ( latitude , longitude ) => {
38
+ return R * Math.cos(latitude) * Math.sin(longitude);
39
+ }
40
+
41
+ };
package/scripts/cookie.js CHANGED
@@ -47,7 +47,7 @@
47
47
 
48
48
  // CREATE THE COOKIE
49
49
 
50
- set: function( cname , value , time , path = '/' ) {
50
+ set: ( cname , value , time , path = '/' ) => {
51
51
  var d = new Date();
52
52
  d.setTime( d.getTime() + 3600 * 1000 * 24 * 365 );
53
53
 
@@ -59,7 +59,7 @@
59
59
 
60
60
  // GET THE COOKIE
61
61
 
62
- get: function( cname ) {
62
+ get: ( cname ) => {
63
63
  var asCookies = document.cookie.split( "; " );
64
64
 
65
65
  for ( var i = 0; i < asCookies.length; i++ ){
@@ -72,13 +72,13 @@
72
72
 
73
73
  // DELETE THE COOKIE
74
74
 
75
- delete: function( cname ) {
75
+ delete: ( cname ) => {
76
76
  document.cookie = cname + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;SameSite=' + CookieSameSite + ';requireSSL='+ CookieSecure +';' + CookieSecure;
77
77
  },
78
78
 
79
79
  // CLEAR ALL COOKIE
80
80
 
81
- clearAll: function() {
81
+ clearAll: () => {
82
82
  var cookies = document.cookie.split(";");
83
83
 
84
84
  for ( var i = 0; i < cookies.length; i++ ) {
package/scripts/load.js CHANGED
@@ -34,6 +34,21 @@
34
34
 
35
35
  window.dphelper.load = {
36
36
 
37
+ /*
38
+ Example:
39
+ var cntx = require.context( __dirname + '/scripts/', false , /\.js$/ );
40
+ dphelper.load.import( cntx );
41
+ */
42
+ /*
43
+ import: ( dir , type = false , extension = /\.js$/ ) => {
44
+ let r = require.context( dir , type , extension );
45
+ r.keys().forEach(
46
+ ( key ) => (
47
+ cache[ key ] = r( key )
48
+ )
49
+ );
50
+ },
51
+ */
37
52
  file: (element, path) => {
38
53
  fetch(path).then(async function (response) {
39
54
  const text = await response.text();
@@ -46,7 +46,7 @@
46
46
  custom: ( el, colors, size ) => {
47
47
 
48
48
  if(!colors) colors =[ "black", "transparent" ];
49
- if(!size) size =[ "6px", "6px" ];
49
+ if(!size) size =[ "8px", "8px" ];
50
50
 
51
51
  const $style = `${el}{
52
52
  scrollbar-width:auto;
File without changes
File without changes
File without changes
File without changes