Skip to content

peacefultruth/hashtag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hashtag

use hashtags to navigate a code structure.

yarn add @peacefultruth/hashtag
interleave hashtags
import {
  hashtags,
} from "@peacefultruth/hashtag";

expect(
  hashtags(
    "it ws a #nice and #sunny-day in #Berlin"
  )
).toEqual(
  ["nice", "sunny_day", "Berlin"]
)
use hashtags to navigate a code structure
import { instruct } from "@peacefultruth/hashtag";

const degrees_celsius = 28;

expect(
  instruct({
    reference: {
      sunny_day: {},
      nice: {
        sunny_day: ({ degrees_celsius }) => (
          `${degrees_celsius} degrees celsius`
        )
      },
      vitamind: previous_value => (
        `${previous_value}.
        I have had some sun for today.`
      )
    },
    instructions: [
      [
        {
          degrees_celsius
        },
        "it ws a #nice and #sunny-day in #Berlin"
      ],
      ["got some #vitamind"]
    ]
  })
).toEqual(
  `${degrees_celsius} degrees celsius.
  I have had some sun for today.`
);
match hashtag strings by scoring them
import {
  score_hashtags_match,
} from "@peacefultruth/hashtag";

expect(
  score_hashtags_match(
    hashtags(
      "it ws a #nice and #sunny-day in #Berlin"
    ),
    hashtags(
      "all the #nice #sunny days in #Berlin"
    )
  )
).toEqual(
  3
);

About

use hashtags to navigate a code structure in javascript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published