(propertyPath: string)
| 532 | }; |
| 533 | |
| 534 | export const pathAsArray = (propertyPath: string): Array<any> => { |
| 535 | const properties: Array<string> = []; |
| 536 | |
| 537 | if (propertyPath === '') { |
| 538 | properties.push(''); |
| 539 | return properties; |
| 540 | } |
| 541 | |
| 542 | // will match everything that's not a dot or a bracket, and "" for consecutive dots. |
| 543 | const pattern = new RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g'); |
| 544 | |
| 545 | // Because the regex won't match a dot in the beginning of the path, if present. |
| 546 | if (propertyPath[0] === '.') { |
| 547 | properties.push(''); |
| 548 | } |
| 549 | |
| 550 | propertyPath.replaceAll(pattern, match => { |
| 551 | properties.push(match); |
| 552 | return match; |
| 553 | }); |
| 554 | |
| 555 | return properties; |
| 556 | }; |
| 557 | |
| 558 | // Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693 |
| 559 | export const isError = (value: unknown): value is Error => { |
no outgoing calls
no test coverage detected