You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
853 B
28 lines
853 B
"use strict"; |
|
var __assign = (this && this.__assign) || Object.assign || function(t) { |
|
for (var s, i = 1, n = arguments.length; i < n; i++) { |
|
s = arguments[i]; |
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) |
|
t[p] = s[p]; |
|
} |
|
return t; |
|
}; |
|
var escapeRegexp_1 = require("../escapeRegexp"); |
|
exports.__esModule = true; |
|
exports["default"] = function (pattern) { |
|
var regexp = new RegExp("^" + escapeRegexp_1["default"](pattern) + "\\.(.+)"); |
|
return function (action) { |
|
if (action.type === pattern) { |
|
return action; |
|
} |
|
else { |
|
var match = action.type.match(regexp); |
|
if (match) { |
|
return __assign({}, action, { type: match[1] }); |
|
} |
|
else { |
|
return null; |
|
} |
|
} |
|
}; |
|
};
|
|
|