# @reskit/room

> A kit to extract room location

Latest version **1.3.1** (published 2023-09-02) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @reskit/room
pnpm add @reskit/room
yarn add @reskit/room
bun add @reskit/room
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2023-09-02 |
| First published | 2023-08-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | simu |
| Maintainers | simumn |
| Keywords | extract room, extract location, room, location, address, extraction |

## Links

- npm: https://www.npmjs.com/package/@reskit/room
- Repository: https://github.com/simo-an/reskit
- Homepage: https://github.com/simo-an/reskit/tree/main/packages/room
- Issues: https://github.com/simo-an/reskit/issues
- npm.io page: https://npm.io/package/@reskit/room

## Recent versions

- 1.3.1 (latest) — 2023-09-02
- 1.3.0 — 2023-08-23
- 1.2.4 — 2023-08-22
- 1.2.3 — 2023-08-22
- 1.2.2 — 2023-08-21
- 1.2.1 — 2023-08-21
- 1.2.0 — 2023-08-20
- 1.1.0 — 2023-08-19
- 1.0.1 — 2023-08-19
- 1.0.0 — 2023-08-19

## README

## Install

Install `@reskit/room` by `pnpm`

```shell
pnpm add @reskit/room
```

## Run Test Demo

We don't have built in data.
You should set buildings by `updateBuildings` at first.

```typescript
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`

```typescript
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

```text
["GalacticSystem/SolarSystem/Mars"]
["GalacticSystem/SolarSystem/Mars"]
```

## Apply to you project

Create a company that have two buildings `Headquarters` and `Affiliate`.

```typescript
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

```typescript
import { updateBuildings } from "@reskit/room";

updateBuildings(buildings);
```

Extract room location from text

```typescript
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

```text
["Headquarters/3F/Suzhou"]
[ 'East/Himalayas' ]
```

## Functions

### Custom divider

```typescript
import { extractRoom, updateDivider } from "@reskit/room";

updateDivider("-");

console.warn(extractRoom("Let's have a meeting at Gusu tonight."));
```

The console will output

```text
["Headquarters-3F-Suzhou"]
```

### Output the same room

```typescript
import { extractRoom, updateDivider } from "@reskit/room";

console.warn(extractRoom("Let's have a meeting at Chizhou! (Chizhou not Gusu!).", false));
```

The console will output

```text
[
  "Affiliate-1F-Chizhou",
  "Affiliate-1F-Chizhou",
  "Headquarters-3F-Suzhou"
]
```

### Using alias as the result

```typescript
import { extractRoom } from "@reskit/room";

console.warn(extractRoom("Let's have a meeting at Gusu tonight.", true, true));
```

The console will output

```text
[ 'Headquarters-3F-Gusu' ]
```

## Others

Welcome to create PR and make reskit/room better!

---
_Source: https://npm.io/package/@reskit/room · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
