JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q52186F
  • License MIT

A persistent indexed item service for app users. User gets a 'slot' to store whatever.

Package Exports

  • sloth-bucket

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sloth-bucket) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Sloth Bucket

A simple, persistent user slot system to store data sequentially with allocate/deallocate functions.

Get started

npm install sloth-bucket --save

Usage

var sloth = require('sloth-bucket');
var username = 'marvin';

//initialize the slots with a starting buffer:

sloth.createUserSlots(username, 'membership', 1200);

var memberNumber = '212-326-543';

//assign varable value above to a new slot:

sloth.allocateSlotId(username, memberNumber).then((result) => {
  var newId = parseInt(result);
  console.log('NEW ID: ', newId);
});

//deallocate a slot at index 3 for user 'marvin':

sloth.deallocateSlotId(username, 3).then((result) => {
  var newIndex = parseInt(result);
  console.log('DEALLOCATED USER DATA AT INDEX: ', newIndex);
});

//get next available slot id:

sloth.nextAvailableSlotId(username).then((result) => {
  console.log('NEXT AVAILABLE ID: ', result);
});

//reset all slots for a user:

sloth.deleteUserSlots(username);

Changes by release

v. 1.2.11 - added nextAvailableSlotId function for retrieving next unallocated slot Id