npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2024 – Pkg Stats / Ryan Hefner

@onereach/regular-expressions

v0.5.22

Published

πŸ” OneReach Regular Expressions ecosystem. Components and helpers. To use in external components

Downloads

1,663

Readme

@onereach/regular-expressions

πŸ” OneReach Regular Expressions ecosystem. Components and helpers.

Live demo

πŸ“£ NOTE: @onereach/regular-expressions requires environment with globally available or-ui.

πŸš€ Usage example

Just import stuff you need from npm package

import { RegexBuilder,  getRegexBodyFlags } from '@onereach/regular-expressions'

Package exports:

🧱 Components:

RegexBuilder

Input for writing RegExp with detailed tokens explanation.

RegexBuilder

props: {
  // RegExp as string in format '/\\d{2}/gi'
  regex: {
    type: String,
    default: ''
  },
  readonly: {
    type: Boolean,
    default: false
  },
  label: {
    type: String,
    default: 'Find'
  },
  error: {
    type: String,
    default: ''
  },
  regexDetailsVisibility: {
    type: Boolean,
    default: false
  },
  docsVisibility: {
    type: Boolean,
    default: false
  },
  mergeFields: {
    type: Array,
    default: () => []
  },
  noMergeFields: {
    type: Boolean,
    default: false
  }
}

| Event | Payload | Description | | -| - | -| | update:regex | regexString | Emitted when regex changed | | focus | | Emitted when input field is focused | | blur | | Emitted when input field is unfocused |

RegexMatcher

Input for testing RegExp for matches.

RegexMatcher

props: {
  // RegExp as string in format '/\\d{2}/gi'
  regex: {
    type: String,
    default: ''
  },
  stringToTest: {
    type: String, 
    default: ''
  },
  readonly: {
    type: Boolean,
    default: false
  },
  label: {
    type: String,
    default: 'Test'
  },
  matchDetailsVisibility: {
    type: Boolean,
    default: false
  }
}

| Event | Payload | Description | | -| - | -| | matchFound | arrayOfMatches | Emitted when got match in stringToTest | | update:stringToTest | stringToTest | Emitted when stringToTest is changed |

PlainTextBuilder

Input for creating RegExp, but body is plain text.

PlainTextBuilder

props: {
  // RegExp as string in format '/\\d{2}/gi'
  regex: {
    type: String,
    default: '//i'
  },
  label: {
    type: String,
    default: 'Find'
  },
  readonly: {
    type: Boolean,
    default: false
  },
  error: {
    type: String,
    default: ''
  }
}

| Event | Payload | Description | | -| - | -| | update:regex | regexString | Emitted when regex changed |

RegexDocs

List of available RegExp tokens. Used inside RegexBuilder as modal.

RegexDocs

props: {
  // is 'Add' button hidden
  readonly: {
    type: Boolean,
    default: false
  }
}

| Event | Payload | Description | | -| - | -| | addToRegex | tokenObject | Emitted when 'Add' button clicked |

RegexesStorage

Modal with list of Favorites and Library RegExps.

RegexesStorage

Requires this.$flow to be available. Favorites (items in KeyValueStorage of your account) can be edited via FavoritesAPI.js service (import { FavoritesAPI } from @onereach/regular-expressions) Library (items in KeyValueStorage of Provides account) can be edited via API (https://devdocs-staging.onereach.ai/providers/index.html#/regular%20expressions) or UI flow in Provides account (https://studio.staging.onereach.ai/flows/4289e44f-c771-4abd-b933-696258d987db/bbef6ab4-6f04-4aa3-93b9-78813426ea1c)

Usage:

<template>
  <div>
    <RegexesStorage
      ref="regexesStorage"
      @select="addItem"
    />
  </div>
</template>

<script>
  import { RegexesStorage } from '@onereach/regular-expressions'

  {
    components: {
      RegexesStorage
    },

    methods: {
      openRegexesStorageModal () {
        this.$refs.regexesStorage.open();
      },
      addItem (regexObject) {
        console.log('selected item', regexObject)
      }
    }
  }
</script>

| Event | Payload | Description | | -| - | -| | select | regexObject | Emitted when 'Select' button clicked | | favoritesWasChanged | favoritesArray | Emitted when list of favorites was changed (some item was edited or deleted) |

πŸ›  Helpers:

getRegexBodyFlags

Parse regexString body and flags to use it as new RegExp(body, flags).

'/\d{2}/gi' => { body: '\d{2}', flags: 'gi' }

FavoritesAPI

Class for CRUD operations with Favorites RegExps.

Usage:

import { FavoritesAPI } from '@onereach/regular-expressions'

const favoritesAPI = new FavoritesAPI({
  $flowApiKeyValueSdkApiUrl: this.$flow.api.keyValue.sdkApiUrl,
  $flowToken: this.$flow.token
})

await favoritesAPI.getItems()
await favoritesAPI.setItem(id, { id, name, description, categories, regex })
await favoritesAPI.deleteItem(id)

Some exports, methods and event are non documented, because used in edge case scenarios. But feel free checking out source code on GitLab πŸ˜‰

πŸ“£ NOTE: this project uses changelog-ci. Don't forget to include changelog with merge request.