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

@reskit/room

v1.3.1

Published

A kit to extract room location

Downloads

6

Readme

Install

Install @reskit/room by pnpm

pnpm add @reskit/room

Run Test Demo

We don't have built in data. You should set buildings by updateBuildings at first.

import { updateBuildings } from "@reskit/room";

updateBuildings([
  {
    name: "GalacticSystem",
    floorMap: {
      SolarSystem: [{ name: "Mars", alias: ["Martis"] }],
    },
  },
]);

That means I create a building GalacticSystem.

This building has a floor SolarSystem.

At this floor, there is a meeting room Mars, we also call the meeeting-room Martis.

You can extract the meeting room location from a text by extractRoom

import { extractRoom, updateBuildings } from "@reskit/room";

updateBuildings([
  {
    name: "GalacticSystem",
    floorMap: {
      SolarSystem: [{ name: "Mars", alias: ["Martis"] }],
    },
  },
]);

console.warn(extractRoom("Let's have a meeting at Mars tomorrow"));
console.warn(extractRoom("Let's have a meeting at Martis tomorrow"));

The output will be

["GalacticSystem/SolarSystem/Mars"]
["GalacticSystem/SolarSystem/Mars"]

Apply to you project

Create a company that have two buildings Headquarters and Affiliate.

import type { IBuilding } from "@reskit/room";

const building1 = {
  "2F": [
    { name: "Agora", alias: "shengwang" },
    { name: "Colosseum", alias: ["theatre", "great theatre"] },
    "Stonehenge",
  ],
  "3F": [{ name: "Suzhou", alias: "Gusu" }, "Hangzhou"],
};
const building2 = {
  "1F": [{ name: "MountHuang", alias: "Mount-Huang" }, { name: "Chizhou" }, "Great Wall", "Google"],
};

const building3 = {
  East: [{ name: "Himalayas", alias: "Highest-Mountain" }],
};

const buildings: IBuilding[] = [
  { name: "Headquarters", floorMap: building1 },
  { name: "Affiliate", floorMap: building2 },
  // Building without name
  { floorMap: building3 },
];

Update building

import { updateBuildings } from "@reskit/room";

updateBuildings(buildings);

Extract room location from text

import { extractRoom, updateBuildings } from "@reskit/room";

console.warn(extractRoom("Let's have a meeting at Gusu tonight."));
console.warn(extractRoom("Let's have a meeting at Highest-Mountain tonight."));

The console will output

["Headquarters/3F/Suzhou"]
[ 'East/Himalayas' ]

Functions

Custom divider

import { extractRoom, updateDivider } from "@reskit/room";

updateDivider("-");

console.warn(extractRoom("Let's have a meeting at Gusu tonight."));

The console will output

["Headquarters-3F-Suzhou"]

Output the same room

import { extractRoom, updateDivider } from "@reskit/room";

console.warn(extractRoom("Let's have a meeting at Chizhou! (Chizhou not Gusu!).", false));

The console will output

[
  "Affiliate-1F-Chizhou",
  "Affiliate-1F-Chizhou",
  "Headquarters-3F-Suzhou"
]

Using alias as the result

import { extractRoom } from "@reskit/room";

console.warn(extractRoom("Let's have a meeting at Gusu tonight.", true, true));

The console will output

[ 'Headquarters-3F-Gusu' ]

Others

Welcome to create PR and make reskit/room better!