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 🙏

© 2024 – Pkg Stats / Ryan Hefner

offline-goodies

v0.0.1

Published

Javascript goodies to help creating an offline app

Downloads

2

Readme

Offline-Goodies

Adds facilities for offline apps

Features

  • Decorate objects on the client side to provide the date at which they were fetched and the date at which they were requested to be updated
  • Get some nice feather hooks for your back-end to handle simple strategies for conflict resolutions when updated were attempted offline.

Installing

yarn add offline-goodies

Client side decorators

import { enrichWithFetchDate, enrichWithUpdateAttemptDate } from 'offline-goodies'

// Receive object from back-end
let receivedObject = {
  id: 1,
  text: 'Text',
};

// Enrich with fetch Date
receivedObject = enrichWithFetchDate(receivedObject);

// Modify object
receivedObject.text = 'Modified text';

// Send object decorated with update attempt date
receivedObject = enrichWithUpdateAttemptDate(receivedObject);

enrichWithFetchDate accepts 2 parameters:

  • obj - the Javascript object to be decorated (required)
  • fetchDateLabel - String - The key to use to store the fetch timestamp (optional, default 'fetchedAt')

enrichWithUpdateAttemptDate accepts 2 parameters:

  • obj - the Javascript object to be decorated (required)
  • updateAttemptDateLabel - String - The key to use to store the update attempt timestamp (optional, default 'updateAttemptedAt')

Back-end conflict resolution strategies

We provide 3 strategies to handle simple conflict resolution when requesting an update of a row on the database. The easiest strategy which is "latest update to arrive on the back-end" wins is not provided as it is by default what is happening when doing a PUT request.

All strategies are directly usable as feathers hooks to be added to the update or patch before sections.

If you don't use Feathers, feel free to read the code as it is quite easy to understand.

Reject outdated update strategy

If the client fetch date is anterior to the update date from the database, the update is denied with a 409 error.

rejectOutdatedUpdate accepts the options parameters in which two key-values can be taken into account.

  • updateDateLabel - String - the name of the column on the database to store the update date (optional, default 'updatedAt')
  • fetchedAt - String - the key holding the fetched at timestamp in the request payload (optional, default 'fetchedAt')

Reject later attempted update strategy

If there was an earlier attempt to update this object, the update is denied with a 409 error.

rejectLaterAttemptedUpdate accepts the options parameters in which one key-value can be taken into account.

  • updateAttemptDateLabel - String - the name of both the column on the database to store the update attempt timestamp and of the key holding the update attempt timestamp on the request payload (optional, default 'updateAttemptedAt')