skimming
- Deno Module
Skimming is a data fetcher for Deno. The idea is to provide a simple and efficient module to fetch content.
- Fetch documents online
skim()
or in memoryskimContent()
- Customizable cache
- Customizable content preview
- Ignore case option
- Trim content option to display only complete information
- Regex support
Usage
No cache
import { Skimming } from "https://deno.land/x/skimming/mod.ts";
const files = ["README.md"];
const context = { url: "https://raw.githubusercontent.com/petruki/skimming/master/", files };
const query = "Usage";
const skimmer = new Skimming();
skimmer.setContext(context);
const results = await skimmer.skim(query, { previewLength: 200 });
- Where
previewLength
is the number of characters after the found occurrence which will be displayed (default: 200) - Add
ignoreCase
option for whether ignore case or not (default: false)
Using cache
const files = ["README.md"];
const context = { url: "https://raw.githubusercontent.com/petruki/skimming/master/", files };
const query = "Usage";
const skimmer = new Skimming({ expireDuration: 10, size: 10 });
skimmer.setContext(context);
const results = await skimmer.skim(query, { previewLength: 200 });
- Where
expireDuration
the time in seconds that the cached value will expire (default: 1min) - Where
size
is the number of stored queries and its results in cache (default: 60)
Testing
Use deno test --allow-net
to test mod_test.ts
Contributing
Please do open an issue or PR if you feel you have something cool to add.