Skip to content

matching keys with regex #37

Answered by jg-rp
rafalkrupinski asked this question in Q&A
Feb 16, 2025 · 5 comments · 10 replies
Discussion options

You must be logged in to vote

Probably not the most intuitive solution, but here's a prototype implementation of has (in TypeScript, some of these helper functions are not currently exported)..

import { check } from "iregexp-check";
import { FilterFunction, FunctionExpressionType } from "./function";
import { isObject, isString } from "../../types";
import { mapRegexp } from "./pattern";

/**
 * A function extension that returns `true` if the first argument is an object
 * value and it contains a property matching the second argument.
 */
export class Has implements FilterFunction {
  readonly argTypes = [
    FunctionExpressionType.ValueType,
    FunctionExpressionType.ValueType,
  ];

  readonly returnType = Functio…

Replies: 5 comments 10 replies

Comment options

You must be logged in to vote
4 replies
@rafalkrupinski
Comment options

@jg-rp
Comment options

@rafalkrupinski
Comment options

@jg-rp
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@rafalkrupinski
Comment options

@rafalkrupinski
Comment options

@jg-rp
Comment options

@jg-rp
Comment options

Answer selected by rafalkrupinski
@rafalkrupinski
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants