# patchkit-util

> Common helper functions for Patchkit

Latest version **1.0.3** (published 2016-04-13) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install patchkit-util
pnpm add patchkit-util
yarn add patchkit-util
bun add patchkit-util
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2016-04-13 |
| First published | 2016-03-31 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Paul Frazee |
| Maintainers | pfraze |

## Links

- npm: https://www.npmjs.com/package/patchkit-util
- Repository: https://github.com/patchkit/patchkit-util
- Homepage: https://github.com/patchkit/patchkit-util#readme
- Issues: https://github.com/patchkit/patchkit-util/issues
- npm.io page: https://npm.io/package/patchkit-util

## Dependencies (2)

- [moment](https://npm.io/package/moment.md) ^2.12.0
- [ssb-ref](https://npm.io/package/ssb-ref.md) ^2.3.0

## Recent versions

- 1.0.3 (latest) — 2016-04-13
- 1.0.2 — 2016-04-10
- 1.0.1 — 2016-03-31
- 1.0.0 — 2016-03-31

## README

# Patchkit Util

```js
import * as u from 'patchkit-util'
import * as social from 'patchkit-util/social'

u.plural(0) // => 's'
u.plural(1) // => ''
u.plural(2) // => 's'

u.shortString('123456789') // => '123456...'
u.shortString('123456789', 3) // => '123...'

u.bytesHuman(500) => '500b'
u.bytesHuman(1024) => '1kb'
u.bytesHuman(1024*1024) => '1mb'
// etc

u.niceDate(Date.now()) // => '4:35pm'
u.niceDate(Date.now() - ONEDAY) // => 'Mon 4:35pm'
u.niceDate(Date.now() - ONEWEEK) // => 'Jan 5'
u.niceDate(Date.now(), true) // 'a few seconds ago'
u.niceDate(Date.now() - ONEDAY, true) // => 'one day ago'
u.niceDate(Date.now() - ONEWEEK, true) // => '7 days ago'

u.getName(users, knownUserId) => 'bob'
u.getName(users, unknownUserId) => '@dkc12e...'

u.getProfilePic(users, userId) => blob link
u.getProfilePicRef(users, userId) => blob ref
u.getProfilePicUrl(users, userId, toUrl) => blob url

// does `a` follow `b`?
social.follows(users, a, b) => bool

// did `a` flag `b`?
social.flags(users, a, b) => bool

// get all who `a` follows
social.followeds(users, a) => userIds

// get all who `a` follows, but who doesnt follow `a` back
social.followedNonfriends(users, a) => userIds

// get all who follow `a`
social.followers(users, b) => userIds

// get all who follow `a`, but who `a` doesnt follow back
social.followerNonfriends(users, a) => userIds

// get all who follow `c`, who are followed by `a`
social.followedFollowers(users, a, c, includeA?) => userIds

// get all who follow `c`, who are not followed by `a`
social.unfollowedFollowers(users, a, c) => userIds

// get all who flag `c`, who are followed by `a`
social.followedFlaggers(users, a, c, includeA?) => userIds

// get all who follow `a`, and who `a` follows back
social.friends(users, a) => userIds

// user-sort by # of followers
social.sortByPopularity(users, a, b) => sort integer (-1|0|1)
```

---
_Source: https://npm.io/package/patchkit-util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
