Skip to main content
Home

Built and signed on GitHub Actions

Works with
This package works with Node.js, Deno, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score94%
Downloads70/wk
Published8 months ago (1.0.13)

TypeScript tagging

Tags

A TypeScript utility library for managing tags in JSON objects. This library provides a simple and efficient way to add, remove, and manage tags in your TypeScript/JavaScript applications.

Features

  • Add and remove tags from JSON objects
  • Type-safe tag management with TypeScript interfaces
  • Simple and intuitive API
  • Built for Deno runtime

Installation

Since this is a Deno module, you can import it directly in your Deno project:

import { addTag, removeTag, type TagsInterface } from "@stsoftware/tags";

Usage

Basic Tag Operations

import { addTag, removeTag, type TagsInterface } from "@stsoftware/tags";

// Create a taggable object
const taggable: TagsInterface = { tags: undefined };

// Add a tag
addTag(taggable, "hello", "world");

// Get a tag value
const value = getTag(taggable, "hello"); // Returns "world"

// Remove a tag
const removedValue = removeTag(taggable, "hello"); // Returns "world"

Working with Multiple Tags

import { addTags, type TagsInterface } from "@stsoftware/tags";

const taggable: TagsInterface = { tags: undefined };

// Add multiple tags at once
addTags(taggable, [
  { name: "category", value: "electronics" },
  { name: "price", value: "99.99" },
]);

API Reference

Interfaces

  • TagsInterface: Defines an entity that can have tags
  • TagInterface: Defines the structure of a tag

Functions

  • addTag(taggable: TagsInterface, name: string, value: string): string | null
  • addTags(taggable: TagsInterface, tags: TagInterface[]): void
  • getTag(taggable: TagsInterface, name: string): string | null
  • removeTag(taggable: TagsInterface, name: string): string | null

Application

Tag all JSON files within a directory.

#!/bin/bash
deno run --allow-read --allow-write \
  jsr:@stsoftware/tags/App \
  --directory=.creatures \
  --tagList=ABC=XYZ,HELLO=World

License

This project is licensed under the MIT License - see the LICENSE file for details.

Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.