shinkansen-rails 1.0.299 → 1.1.0

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/eslint.config.mjs CHANGED
@@ -53,7 +53,8 @@ export default [
53
53
  ],
54
54
  languageOptions: {
55
55
  globals: {
56
- ...globals.node
56
+ ...globals.node,
57
+ RailsTypes: 'readonly'
57
58
  }
58
59
  }
59
60
  }),
@@ -64,7 +65,8 @@ export default [
64
65
  ],
65
66
  languageOptions: {
66
67
  globals: {
67
- ...globals.browser
68
+ ...globals.browser,
69
+ RailsTypes: 'readonly'
68
70
  }
69
71
  }
70
72
  })
package/index.d.cts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/index.d.mts ADDED
@@ -0,0 +1,7 @@
1
+ declare global {
2
+ namespace RailsTypes {
3
+ export type ObjectType = Record<PropertyKey, unknown>
4
+ }
5
+ }
6
+
7
+ export {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shinkansen-rails",
3
- "version": "1.0.299",
3
+ "version": "1.1.0",
4
4
  "description": "Shinkansen Rails",
5
5
  "keywords": [
6
6
  "Shinkansen",
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "main": "./src/index.mjs",
13
13
  "type": "module",
14
- "types": "./src/index.d.mts",
14
+ "types": "./index.d.mts",
15
15
  "author": {
16
16
  "name": "Jonathan Perry for Modern Poacher Limited",
17
17
  "email": "modernpoacher@modernpoacher.com",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "license": "ISC",
21
21
  "engines": {
22
- "node": ">=23.0.0"
22
+ "node": ">=22.11.0"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -42,8 +42,8 @@
42
42
  "@babel/eslint-parser": "^7.26.8",
43
43
  "@babel/preset-env": "^7.26.9",
44
44
  "@babel/register": "^7.25.9",
45
- "@sequencemedia/eslint-config-standard": "^0.2.39",
46
- "@sequencemedia/eslint-config-typescript": "^0.1.56",
45
+ "@sequencemedia/eslint-config-standard": "^0.2.41",
46
+ "@sequencemedia/eslint-config-typescript": "^0.1.57",
47
47
  "@types/babel__register": "^7.17.3",
48
48
  "@types/chai": "^5.2.0",
49
49
  "@types/debug": "^4.1.12",
@@ -60,7 +60,10 @@
60
60
  "sinon": "^19.0.2"
61
61
  },
62
62
  "imports": {
63
- "#rails": "./src/index.mjs",
63
+ "#rails": {
64
+ "require": "./src/index.cjs",
65
+ "import": "./src/index.mjs"
66
+ },
64
67
  "#rails/rails": "./src/rails/index.mjs"
65
68
  },
66
69
  "exports": {
package/src/index.cjs CHANGED
@@ -11,7 +11,7 @@ const log = debug('shinkansen-rails')
11
11
  log('`shinkansen` is awake')
12
12
 
13
13
  const {
14
- default: Rails // @ts-ignore
14
+ default: Rails // @ts-expect-error
15
15
  } = require('./rails/index.mjs')
16
16
 
17
17
  module.exports.Rails = Rails
@@ -0,0 +1,3 @@
1
+ export {
2
+ default as Rails // @ts-expect-error MJS
3
+ } from '#rails/rails'
package/src/index.d.mts CHANGED
@@ -1 +1,3 @@
1
- export { default as Rails } from '#rails/rails'
1
+ export {
2
+ default as Rails
3
+ } from '#rails/rails'
package/src/index.mjs CHANGED
@@ -4,4 +4,6 @@ const log = debug('shinkansen-rails')
4
4
 
5
5
  log('`shinkansen` is awake')
6
6
 
7
- export { default as Rails } from './rails/index.mjs'
7
+ export {
8
+ default as Rails
9
+ } from './rails/index.mjs'
@@ -1,14 +1,16 @@
1
- export function any (o: Record<PropertyKey, unknown>): boolean
2
- export function has (o: Record<PropertyKey, unknown>, k: string): boolean
3
- export function get (o: Record<PropertyKey, unknown>, k: string): unknown
1
+ type ObjectType = RailsTypes.ObjectType
2
+
3
+ export function any (o: ObjectType): boolean
4
+ export function has (o: ObjectType, k: string): boolean
5
+ export function get (o: ObjectType, k: string): unknown
4
6
 
5
7
  export function rail (p?: string): string
6
- export function go (o?: Record<PropertyKey, unknown>, p?: string): boolean
7
- export function to (o?: Record<PropertyKey, unknown>, p?: string): string
8
+ export function go (o?: ObjectType, p?: string): boolean
9
+ export function to (o?: ObjectType, p?: string): string
8
10
 
9
11
  export default class Rails { // eslint-disable-line @typescript-eslint/no-extraneous-class -- Static class
10
12
  static pattern (p?: string): string
11
13
  static rail (p?: string): string
12
- static go (o?: Record<PropertyKey, unknown>, p?: string): boolean
13
- static to (o?: Record<PropertyKey, unknown>, p?: string): string
14
+ static go (o?: ObjectType, p?: string): boolean
15
+ static to (o?: ObjectType, p?: string): string
14
16
  }
@@ -1,10 +1,16 @@
1
+ /**
2
+ * @typedef {RailsTypes.ObjectType} ObjectType
3
+ */
4
+
1
5
  import debug from 'debug'
2
6
 
3
7
  const log = debug('shinkansen-rails')
4
8
 
5
9
  log('`shinkansen` is awake')
6
10
 
7
- // @ts-ignore
11
+ /**
12
+ * @type {string}
13
+ */
8
14
  let pattern
9
15
 
10
16
  const map = new Map()
@@ -15,23 +21,23 @@ const CHAR32 = String.fromCharCode(32)
15
21
  const CHAR45 = String.fromCharCode(45)
16
22
 
17
23
  /**
18
- * @param {Record<PropertyKey, unknown>} o The object containing values
24
+ * @param {ObjectType} o The object containing values
19
25
  */
20
- export const any = (o) => !!Reflect.ownKeys(o).length
26
+ export const any = (o) => !!Object.keys(o).length // Reflect.ownKeys(o).length
21
27
 
22
28
  /**
23
- * @param {Record<PropertyKey, unknown>} o The object containing values
29
+ * @param {ObjectType} o The object containing values
24
30
  * @param {string} k The value name
25
31
  * @returns {boolean}
26
32
  */
27
- export const has = (o, k) => Reflect.has(o, k)
33
+ export const has = (o, k) => k in o // Reflect.has(o, k)
28
34
 
29
35
  /**
30
- * @param {Record<PropertyKey, unknown>} o The object containing values
36
+ * @param {ObjectType} o The object containing values
31
37
  * @param {string} k The value name
32
38
  * @returns {unknown}
33
39
  */
34
- export const get = (o, k) => Reflect.get(o, k)
40
+ export const get = (o, k) => o[k] // Reflect.get(o, k)
35
41
 
36
42
  /**
37
43
  * Format simple latin character strings as URL compatible
@@ -48,7 +54,7 @@ export function rail (p) {
48
54
  /**
49
55
  * Interrogate parameters to determine whether or not components can be created
50
56
  *
51
- * @param {Record<PropertyKey, unknown>} o The object containing values for the 'pattern'
57
+ * @param {ObjectType} o The object containing values for the 'pattern'
52
58
  * @param {string} p The 'pattern' according to which URLs should be created
53
59
  * @return {boolean}
54
60
  *
@@ -80,7 +86,7 @@ export function go (o, p) {
80
86
  /**
81
87
  * Interrogate parameters for object field names
82
88
  *
83
- * @param {Record<PropertyKey, unknown>} o The object containing fields
89
+ * @param {ObjectType} o The object containing fields
84
90
  * @param {string} p The string containing field names to be found
85
91
  * @return {string}
86
92
  *
@@ -128,7 +134,7 @@ export default class Rails {
128
134
  }
129
135
 
130
136
  /**
131
- * @param {Record<PropertyKey, unknown>} [o] The object containing values for the 'pattern'
137
+ * @param {ObjectType} [o] The object containing values for the 'pattern'
132
138
  * @param {string | undefined} [p] The 'pattern' according to which URLs should be created
133
139
  * @return {boolean}
134
140
  */
@@ -139,7 +145,7 @@ export default class Rails {
139
145
  }
140
146
 
141
147
  /**
142
- * @param {Record<PropertyKey, unknown>} [o] The object containing values for the 'pattern'
148
+ * @param {ObjectType} [o] The object containing values for the 'pattern'
143
149
  * @param {string} [p] The 'pattern' according to which URLs should be created
144
150
  * @return {string}
145
151
  */