@sjcrh/proteinpaint-shared 2.99.0 → 2.99.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-shared",
3
- "version": "2.99.0",
3
+ "version": "2.99.1",
4
4
  "description": "ProteinPaint code that is shared between server and client-side workspaces",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -9,7 +9,7 @@
9
9
  "./*": "./src/*"
10
10
  },
11
11
  "scripts": {
12
- "build": "esbuild src/*.ts --platform=node --outdir=src/ --format=esm",
12
+ "build": "esbuild src/*.ts --platform=node --outdir=src/ --format=esm && prettier --no-semi --use-tabs --write src/urljson.js src/joinUrl.js src/doc.js",
13
13
  "prepack": "npm run build",
14
14
  "test": "ls src/test/*.spec* | xargs node"
15
15
  },
package/src/doc.js CHANGED
@@ -1,10 +1,6 @@
1
- const test = {};
1
+ const test = {}
2
2
  function doc(opts) {
3
- if (opts.type in test)
4
- throw `test['${opts.type}'] already exists`;
5
- test[opts.type] = opts.test;
3
+ if (opts.type in test) throw `test['${opts.type}'] already exists`
4
+ test[opts.type] = opts.test
6
5
  }
7
- export {
8
- doc,
9
- test
10
- };
6
+ export { doc, test }
package/src/joinUrl.js ADDED
@@ -0,0 +1,7 @@
1
+ function joinUrl(p1, p2) {
2
+ if (typeof p1 != 'string' || typeof p2 != 'string') throw `both arguments must be string type`
3
+ if (!p1 || !p2) throw 'blank string not allowed'
4
+ if (p1.indexOf('?') != -1) throw 'search string not allowed'
5
+ return (p1.endsWith('/') ? p1 : p1 + '/') + (p2.startsWith('/') ? p2.substring(1) : p2)
6
+ }
7
+ export { joinUrl }
package/src/urljson.js CHANGED
@@ -1,30 +1,32 @@
1
- import { isNumeric } from "./helpers.js";
2
- const reserved = ["false", "true", "null", "undefined"];
3
- const delimiters = ['"', "{", "["];
1
+ import { isNumeric } from './helpers.js'
2
+ const reserved = ['false', 'true', 'null', 'undefined']
3
+ const delimiters = ['"', '{', '[']
4
4
  function encode(rawObject) {
5
- const params = [];
6
- for (const [key, value] of Object.entries(rawObject)) {
7
- if (typeof value == "string" && !isNumeric(value) && !reserved.includes(value) && !delimiters.includes(value[0])) {
8
- params.push(`${key}=${encodeURIComponent(value)}`);
9
- } else if (value !== void 0) {
10
- params.push(`${key}=${encodeURIComponent(JSON.stringify(value))}`);
11
- }
12
- }
13
- return params.join("&");
5
+ const params = []
6
+ for (const [key, value] of Object.entries(rawObject)) {
7
+ if (typeof value == 'string' && !isNumeric(value) && !reserved.includes(value) && !delimiters.includes(value[0])) {
8
+ params.push(`${key}=${encodeURIComponent(value)}`)
9
+ } else if (value !== void 0) {
10
+ params.push(`${key}=${encodeURIComponent(JSON.stringify(value))}`)
11
+ }
12
+ }
13
+ return params.join('&')
14
14
  }
15
15
  function decode(query) {
16
- const encoding = query.encoding;
17
- for (const [key, value] of Object.entries(query)) {
18
- if (encoding == "json" || value == "null" || // not new, always been
19
- value == "true" || // NEED TO FIND-REPLACE CODE THAT USES value == 'true'
20
- value == "false" || // NEED TO FIND-REPLACE CODE THAT USES value == 'false'
21
- isNumeric(value) || // NEED TO check
22
- value.startsWith('"') && value.endsWith('"') || value.startsWith("{") && value.endsWith("}") || value.startsWith("[") && value.endsWith("]"))
23
- query[key] = JSON.parse(value);
24
- }
25
- return query;
16
+ const encoding = query.encoding
17
+ for (const [key, value] of Object.entries(query)) {
18
+ if (
19
+ encoding == 'json' ||
20
+ value == 'null' || // not new, always been
21
+ value == 'true' || // NEED TO FIND-REPLACE CODE THAT USES value == 'true'
22
+ value == 'false' || // NEED TO FIND-REPLACE CODE THAT USES value == 'false'
23
+ isNumeric(value) || // NEED TO check
24
+ (value.startsWith('"') && value.endsWith('"')) ||
25
+ (value.startsWith('{') && value.endsWith('}')) ||
26
+ (value.startsWith('[') && value.endsWith(']'))
27
+ )
28
+ query[key] = JSON.parse(value)
29
+ }
30
+ return query
26
31
  }
27
- export {
28
- decode,
29
- encode
30
- };
32
+ export { decode, encode }