Skip to content

QSUQuick & Simple Utility

The helpers every project ends up writing by hand, with the same name and the same behavior in JavaScript, Dart and Python. Slugs, text case, date math, file sizes, deep clone and merge, validation, hashing.

qsu

One folder of helpers, three languages

Every project grows the same folder of small utilities, and every language grows its own copy of it. qsu is that folder, written once and published to npm, pub.dev and PyPI, so the call you already know keeps working when the stack changes.

javascript
// JavaScript / Node.js
import { getSlug } from 'qsu';

getSlug('Hello World!');
// 'hello-world'
dart
// Dart / Flutter
import 'package:qsu/qsu.dart';

getSlug('Hello World!');
// 'hello-world'
python
# Python
from qsu import getSlug

getSlug('Hello World!')
# 'hello-world'

Same name, same arguments, same result.

What it looks like in use

Take a language here. Every example below is written for it, and so is every page of the reference.

Examples in

Text, slugs and case

javascript
import { getSlug, strToCamelCase, truncate } from 'qsu';

getSlug('Hello World'); // 'hello-world'
strToCamelCase('--foo-bar--'); // 'fooBar'
truncate('hello', 2, '...'); // 'he...'
dart
import 'package:qsu/qsu.dart';

getSlug('Hello World'); // 'hello-world'
strToCamelCase('--foo-bar--'); // 'fooBar'
truncate('hello', 2, ellipsis: '...'); // 'he...'
python
from qsu import getSlug, strToCamelCase, truncate

getSlug('Hello World')  # 'hello-world'
strToCamelCase('--foo-bar--')  # 'fooBar'
truncate('hello', 2, '...')  # 'he...'

Dates, sizes and durations

javascript
import { today, dayDiff, fileSizeFormat, duration } from 'qsu';

today(); // 'YYYY-MM-DD'
dayDiff(new Date('2021-01-01'), new Date('2021-01-03')); // 2
fileSizeFormat(100000000, 3); // '95.367 MB'
duration(604800000); // '7 Days'
dart
import 'package:qsu/qsu.dart';

today(); // 'YYYY-MM-DD'
dayDiff(DateTime(2021, 1, 1), DateTime(2021, 1, 3)); // 2
fileSizeFormat(100000000, decimals: 3); // '95.367 MB'
duration(604800000); // '7 Days'
python
from datetime import datetime
from qsu import today, dayDiff, fileSizeFormat, duration

today()  # 'YYYY-MM-DD'
dayDiff(datetime(2021, 1, 1), datetime(2021, 1, 3))  # 2
fileSizeFormat(100000000, 3)  # '95.367 MB'
duration(604800000)  # '7 Days'

Arrays, objects and checks

javascript
import { arrUnique, objMerge, isEmail } from 'qsu';

arrUnique([1, 2, 2, 3]); // [1, 2, 3]
objMerge({ a: { b: 1 } }, { a: { c: 2 } }); // { a: { b: 1, c: 2 } }
isEmail('[email protected]'); // true
dart
import 'package:qsu/qsu.dart';

arrUnique([1, 2, 2, 3]); // [1, 2, 3]
objMerge([{'a': {'b': 1}}, {'a': {'c': 2}}]); // {'a': {'b': 1, 'c': 2}}
isEmail('[email protected]'); // true
python
from qsu import arrUnique, objMerge, isEmail

arrUnique([1, 2, 2, 3])  # [1, 2, 3]
objMerge({'a': {'b': 1}}, {'a': {'c': 2}})  # {'a': {'b': 1, 'c': 2}}
isEmail('[email protected]')  # True

What is inside

Thirteen categories, counted for the language you are reading in. A package that does not carry a category says so rather than showing an empty one.

array

16 functions15 functions

Creation, sorting, sampling, deduplication and grouping.

crypto

10 functions8 functions

Hashing, base64, symmetric encryption and id generation.

date

5 functions

Validation, formatting and range calculation.

file

24 functions22 functions

File and directory inspection, path handling and reading or writing.

format

7 functions

Readable sizes, durations and numbers, and parsing that does not throw.

math

12 functions

Arithmetic over argument lists or arrays, and random numbers.

misc

6 functions

Debounce, throttle, retry, sleep and other helpers around a function.

net

1 functionNot in Dart

Network requests.

object

15 functions11 functions

Traversal, merging, flattening and conversion.

os

7 functionsNot in Dart

Facts about the machine the process is running on.

string

29 functions27 functions

Transformation, capitalization, trimming and truncation.

verify

12 functions

Type, equality, range and format validation.

web

9 functions8 functions

URLs, slugs, user agents and other helpers for the browser.

153 functions across 13 categories133 functions across 11 categories

Start with your language

Install the package you need. The documentation follows the language you take here, and so does every page you open after it.

Released under the MIT License