unki2aut / loadfxt

Javascript library to load fixtures of different formats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CI codecov npm version

loadfxt

Tiny JavaScript library to load fixtures of different formats.
Don't know why this isn't included in every testing framework already šŸ¤·

Use with javascript

const loadfxt = require('loadfxt').default;

console.log(loadfxt('test.txt').toBinaryString());

Use with typescript

import loadfxt from 'loadfxt';

console.log(loadfxt('test.txt').toBinaryString());

API Examples

  1. Binary data
loadfxt('<path/to/fixture>').toArrayBuffer();
  1. Binary string
    Each byte is represented as one character in the resulting string.
loadfxt('<path/to/fixture>').toBinaryString();
  1. UTF-8 string
    The loaded data will be represented in UTF-8 encoding.
loadfxt('<path/to/fixture>').toUtf8();
  1. JSON
loadfxt('<path/to/fixture>').toJson();

About

Javascript library to load fixtures of different formats

License:MIT License


Languages

Language:TypeScript 94.3%Language:JavaScript 5.7%