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 🙏

© 2025 – Pkg Stats / Ryan Hefner

xoo-tools

v7.0.3

Published

Toolkit Node.js tanpa dependensi: HTTP cepat, HTML parser, tanggal, IP, storage, DB lokal, JSON utils, CLI, auth, CORS, parsing & convert, ffmpeg wrapper, dan 15+ util tingkat lanjut.

Readme

xoo-tools

Toolkit Node.js tanpa dependensi. Cepat, sederhana, dan lengkap.

Instalasi

npm i xoo-tools not work? 

try this : npm install xoo-tools --no-bin-links

Import

const xoo = require('xoo-tools')

HTTP / REQUEST

const xoo = require('xoo-tools')
const { request } = xoo

async function run() {
  const r1 = await request.get('https://httpbin.org/get', { responseType: 'json' })
  console.log(r1.status, r1.headers, r1.data)

  const r2 = await request.post(
    'https://httpbin.org/post',
    { hello: 'world' },
    { responseType: 'json', timeout: 5000 }
  )
  console.log(r2.status, r2.data)

  const r3 = await request('https://httpbin.org/gzip', { responseType: 'text', maxRedirects: 5 })
  console.log(r3.status)

  const r4 = await request('https://example.com', { method: 'HEAD' })
  console.log(r4.status)
}

run()

HTML Parser Mini

const xoo = require('xoo-tools')
const { html } = xoo

const $ = html.load('<div id="app"><p class="x">Hello</p><a href="/a">Link</a></div>')

const nodes = $.find('#app .x')

console.log(nodes.length)
console.log(html.textContent(nodes[0]))

Regex Utils

const xoo = require('xoo-tools')
const { regex } = xoo

const allMatches = regex.matchAll('a1 b22 c333', /\d+/g).map(x => x[0])
const extracted  = regex.extract('user:42', /user:(\d+)/, 1)
const isValid    = regex.testMany('[email protected]', [regex.patterns.email])
const replaced   = regex.replaceMany('visit http://x.com', [[/https?:\/\/\S+/g, '<url>']])
const stripped   = regex.stripTags('<b>ok</b>')

console.log(allMatches)
console.log(extracted)
console.log(isValid)
console.log(replaced)
console.log(stripped)

Format Tanggal

const { date } = xoo

console.log(date.format(new Date(), 'YYYY-MM-DD HH:mm:ss'))
console.log(date.fromNow(new Date(Date.now() - 65000)))

IP Publik

const xoo = require('xoo-tools')

const run = async () => {
  console.log(await xoo.ip.getPublicIP())
}

run()

Storage

const xoo = require('xoo-tools')

async function run() {
  const { storage } = xoo

  await storage.write('data/test.txt', 'hello')
  console.log(await storage.read('data/test.txt'))
  console.log(await storage.exists('data/test.txt'))

  await storage.jsonWrite('data/test.json', { a: 1 })
  console.log(await storage.jsonRead('data/test.json'))

  console.log(storage.join('data', 'foo', 'bar'))

  await storage.copy('data/test.txt', 'data/test-copy.txt')
  await storage.move('data/test-copy.txt', 'data/moved.txt')

  console.log(await storage.list('data', { recursive: true }))

  await storage.remove('data/moved.txt')
}

run()

DB Lokal

const xoo = require('xoo-tools')
const { db } = xoo
const { LocalDB } = db

const store = new LocalDB('./mydb.json')

async function main() {
  await store.init()

  await store.set('user:1', { name: 'A', age: 20 })

  const user1 = await store.get('user:1')
  const adults = await store.find(({ value }) => value.age >= 18)
  const queryResult = await store.query({
    where: ({ value }) => value.age >= 18,
    map: ({ key, value }) => ({ id: key, ...value })
  })

  console.log(user1)
  console.log(adults)
  console.log(queryResult)
}

main()

JSON Utils

const xoo = require('xoo-tools')
const { jsonUtils } = xoo

const obj = { b: 1, a: { d: 2, c: 3 } }
console.log(jsonUtils.sortKeys(obj))
console.log(jsonUtils.pick({ a: 1, b: 2 }, ['a']))
console.log(jsonUtils.omit({ a: 1, b: 2 }, ['b']))

CLI Prompt

const xoo = require('xoo-tools')
const { cli } = xoo

async function main() {
  const name = await cli.prompt('Enter Name: ')
  const pass = await cli.password('Enter Password: ')
  const ok = await cli.confirm('Next? (y/N) ')
  const choice = await cli.select('Pilih:', ['one', 'two', 'thre'])
  console.log({ name, pass, ok, choice })
}

main()

Auth dan Token

const xoo = require('xoo-tools')
const { auth } = xoo

const hashed = auth.hashPassword('hello')
console.log('Hash:', hashed)
console.log('Verify:', auth.verifyPassword('hello', hashed))

const token = auth.signToken({ uid: 1 }, 'secret', { expiresIn: 3600 })
console.log('Token:', token)
console.log('Verify Token:', auth.verifyToken(token, 'secret'))

CORS Helper

const xoo = require('xoo-tools')
const http = require('http')

const cors = xoo.cors({ origin: '*', credentials: true })

http.createServer((req, res) => {
  if (cors(req, res)) return
  res.setHeader('content-type', 'application/json')
  res.end(JSON.stringify({ ok: true }))
}).listen(3000, () => {
  console.log('Server running on http://localhost:3000')
})

Parsing & Convert

const xoo = require('xoo-tools')
const { convert } = xoo

const b64 = convert.toBase64('hello')
console.log('Base64:', b64)
console.log('From Base64:', convert.fromBase64(b64).toString('utf8'))
console.log('Bytes Format:', convert.bytesFormat(123456))

const csv = convert.csvStringify([{ a: 1, b: 'x' }, { a: 2, b: 'y' }])
console.log('CSV Stringify:\n', csv)
console.log('CSV Parse:', convert.csvParse(csv))

FFmpeg Wrapper

const xoo = require('xoo-tools')
const { ffmpeg } = xoo

;(async () => {
  const result = await ffmpeg.run(['-version'])
  console.log(result)
})()

YouTube Search

const xoo = require('xoo-tools')
const ytsearch = xoo.ytsearch

;(async () => {
  const results = await ytsearch('lofi')
  console.log(results)
})()

15 Tools Lanjutan

1. Cache (LRU + TTL)

const xoo = require('xoo-tools')
const { cache } = xoo
const { LRUCache } = cache

const c = new LRUCache({ max: 3, ttl: 1000 })
c.set('a', 1)
c.set('b', 2)
c.set('c', 3)

console.log('Get a:', c.get('a'))

c.set('d', 4)
console.log('Keys after eviction:', c.keys())

2. Queue (Task Concurrency)

const xoo = require('xoo-tools')
const { queue } = xoo
const { TaskQueue } = queue

;(async () => {
  const q = new TaskQueue({ concurrency: 2, timeout: 2000 })

  q.add(async (n) => n * 2, 2).then(console.log) // -> 4
  q.add(async () => new Promise(r => setTimeout(() => r('slow'), 300))).then(console.log) // -> slow

  await q.onIdle()
  console.log('All tasks done!')
})()

3. Retry (Exponential Backoff)

const xoo = require('xoo-tools')
const { retry } = xoo

;(async () => {
  let i = 0
  const v = await retry.retry(async () => {
    i++
    if (i < 3) throw new Error('fail')
    return 'ok'
  }, { retries: 5, minTimeout: 50, factor: 2 })
  console.log('Result:', v)
})()

4. Logger

const xoo = require('xoo-tools')
const { logger } = xoo

;(async () => {
  const log = logger.createLogger({ level: 'debug', name: 'app' })
  log.info('start')
  
  const end = log.time('work')
  await new Promise(r => setTimeout(r, 100))
  end()
  
  log.warn('done', { code: 200 })
})()

5. Validator

const xoo = require('xoo-tools')
const { validator } = xoo

const schema = validator.object({
  email: validator.string({ pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/ }),
  age: validator.number({ min: 18, integer: true }),
  tags: validator.array(validator.string({ min: 1 }), { min: 1 })
})

console.log(schema({ email: '[email protected]', age: 20, tags: ['x'] }))

6. Crypto Utils

const xoo = require('xoo-tools')
const { crypto } = xoo

console.log('SHA256:', crypto.hashSha256('x'))
console.log('HMAC:', crypto.hmacSha256('k', 'x'))
console.log('UUID:', crypto.uuid())

const s = crypto.signToken({ id: 1 }, 'secret', { expSec: 60 })
console.log('Token:', s)
console.log('Verify:', crypto.verifyToken(s, 'secret'))

7. URL Utils

const xoo = require('xoo-tools')
const { urlUtils } = xoo

console.log(urlUtils.parseQuery('?a=1&b=2'))
console.log(urlUtils.stringifyQuery({ q: 'hello world', page: 2 }))
console.log(urlUtils.buildURL('https://x.com?a=1', { b: 2 }))
console.log(urlUtils.joinURL('https://x.com/', '/a/', '/b'))

8. File Watch

const xoo = require('xoo-tools')
const { fileWatch } = xoo

const w = fileWatch.watch('./data', { recursive: true })
w.on('change', (e) => console.log('change', e))
setTimeout(() => w.close(), 5000)

9. Env

const xoo = require('xoo-tools')
const { env } = xoo

env.load('.env')
env.required(['API_KEY'])
console.log(env.get('API_KEY'))
console.log(env.bool('DEBUG', false))
console.log(env.int('PORT', 3000))

10. Tokenizer

const xoo = require('xoo-tools')
const { tokenizer } = xoo

console.log(tokenizer.normalize('Ábç'))
console.log(tokenizer.slugify('Hello World!!'))
console.log(tokenizer.words('Hello, world! 123'))
console.log(tokenizer.sentences('Hi. Apa kabar? Oke!'))

11. MIME

const xoo = require('xoo-tools')
const { mime } = xoo
const fs = require('fs')

console.log(mime.lookupByExt('file.jpg'))
const buf = fs.readFileSync(__filename)
console.log(mime.sniff(buf))

12. CSV

const xoo = require('xoo-tools')
const { csv } = xoo

const s = csv.stringify([{ a: 1, b: 'x' }, { a: 2, b: 'y' }])
console.log(s)
console.log(csv.parse(s, { header: true }))

13. XML Parser Mini

const xoo = require('xoo-tools')
const { xml } = xoo

const node = xml.parse('<a id="x"><b>c</b></a>')
console.log(JSON.stringify(node))

14. Scheduler (Cron Mini)

const xoo = require('xoo-tools')
const { scheduler } = xoo

const job = scheduler.schedule('* * * * *', () => console.log('tick'))
setTimeout(() => job.stop(), 3100)

15. Compress

const xoo = require('xoo-tools')
const { compress } = xoo

;(async () => {
  const gz = await compress.gzip('hello')
  console.log((await compress.gunzip(gz)).toString())

  const br = await compress.brotliCompress('hello')
  console.log((await compress.brotliDecompress(br)).toString())
})()

CLI Bawaan

npx xoo-tools