#!/bin/sh
set -eu

node <<'EOF'
const assert = require('assert')
const Fuse = require('fuse.js')

assert.strictEqual(typeof Fuse, 'function')
assert.strictEqual(typeof Fuse.version, 'string')

const fuse = new Fuse(
  [
    { title: "Old Man's War", author: 'John Scalzi' },
    { title: 'The Lock Artist', author: 'Steve Hamilton' },
    { title: 'HTML5', author: 'Remy Sharp' }
  ],
  { keys: ['title', 'author'] }
)

const result = fuse.search('Stve')
assert.ok(result.length > 0)
assert.strictEqual(result[0].item.author, 'Steve Hamilton')

const worker = require('fuse.js/worker')
assert.strictEqual(typeof worker.FuseWorker, 'function')
EOF
