statebus 6.1.30 → 6.1.32
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/extras/esm-test.jsm +3 -0
- package/package.json +1 -1
- package/server.js +1 -0
- package/statebus.js +15 -7
package/package.json
CHANGED
package/server.js
CHANGED
package/statebus.js
CHANGED
|
@@ -663,14 +663,17 @@
|
|
|
663
663
|
|
|
664
664
|
function pattern_matcher (pattern) {
|
|
665
665
|
var param_names = []
|
|
666
|
-
|
|
666
|
+
function replace_param (match, prefix, param, star) {
|
|
667
667
|
// Replace * with .*
|
|
668
|
-
if (
|
|
668
|
+
if (star === '*') return '.*'
|
|
669
669
|
|
|
670
670
|
// Replace :foo with ([^/]+), and remember the "foo" name
|
|
671
|
-
param_names.push(
|
|
672
|
-
return '([^/]+)'
|
|
673
|
-
}
|
|
671
|
+
param_names.push(param.slice(1))
|
|
672
|
+
return prefix + '([^/]+)'
|
|
673
|
+
}
|
|
674
|
+
var regex = new RegExp('^'
|
|
675
|
+
+ pattern.replace(/(^|\/)(:[^/()]+)|(\*)/g, replace_param)
|
|
676
|
+
+ '$')
|
|
674
677
|
|
|
675
678
|
return function (path) {
|
|
676
679
|
var match = path.match(regex)
|
|
@@ -752,7 +755,7 @@
|
|
|
752
755
|
method: method,
|
|
753
756
|
params: matches
|
|
754
757
|
}
|
|
755
|
-
result.push({method, key:handler.pattern, func:handler.funk})
|
|
758
|
+
result.push({method:method, key:handler.pattern, func:handler.funk})
|
|
756
759
|
seen[funk_key(handler.funk)] = true
|
|
757
760
|
}
|
|
758
761
|
}
|
|
@@ -761,6 +764,11 @@
|
|
|
761
764
|
}
|
|
762
765
|
|
|
763
766
|
function run_handler(funck, method, arg, options) {
|
|
767
|
+
// If method == "save", then arg is an object {}
|
|
768
|
+
// If method == "fetch", then arg is a key
|
|
769
|
+
// If method == "forget", then arg is a key
|
|
770
|
+
// If method == "delete", then arg is a key
|
|
771
|
+
|
|
764
772
|
options = options || {}
|
|
765
773
|
var t = options.t,
|
|
766
774
|
just_make_it = options.dont_run,
|
|
@@ -821,7 +829,7 @@
|
|
|
821
829
|
// Fresh fetch/save/forget/delete handlers will just be regular
|
|
822
830
|
// functions. We'll store their arg and transaction and let them
|
|
823
831
|
// re-run until they are done re-running.
|
|
824
|
-
function key_arg () { return ((typeof arg.key)
|
|
832
|
+
function key_arg () { return ((typeof arg.key) === 'string') ? arg.key : arg }
|
|
825
833
|
function rest_arg () { return (key_arg()).substr(binding.length-1) }
|
|
826
834
|
function vars_arg () {
|
|
827
835
|
var r = rest_arg()
|