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

@cryptolize/persistence

v2.0.2

Published

cryptolize persistence

Downloads

42

Readme

Install

npm install @cryptolize/persistence --save

Usage

ES6 (Javascript Modules)

import { S3Storage } from '@cryptolize/persistence'

S3Storage.saveFile(bucket, file, filename, progress).then((filename) => console.log(filename))

ES5 (CommonJS)

var CryptolizePersistence = require('@cryptolize/persistence')

var S3Storage = CryptolizePersistence.S3Storage
S3Storage.saveFile(bucket, file, filename, progress).then((filename) => console.log(filename))

UMD (Browser)

CryptolizePersistence.S3Storage.saveFile(bucket, file, filename, progress).then((filename) => console.log(filename))

API

S3Storage

saveText

Saves text to S3

Parameters

  • bucket AWS.S3
  • text String
  • filename String
  • params Object additonal params to attach to the request
  • progress StorageInterface~ProgressCallback?

Returns Promise<(AWS.Response | Error)> the response

getText

Gets text from S3

Parameters

  • bucket AWS.S3
  • filename String
  • params Object additonal params to attach to the request
  • progress StorageInterface~ProgressCallback?

Returns Promise<(AWS.Response | Error)> the requested text in the Body property

saveObject

Saves object to S3

Parameters

  • bucket AWS.S3
  • object Object
  • filename String
  • params Object additonal params to attach to the request
  • progress StorageInterface~ProgressCallback?

Returns Promise<(AWS.Response | Error)> the response

getObject

Gets object from S3

Parameters

  • bucket AWS.S3
  • filename String
  • params Object additonal params to attach to the request
  • progress StorageInterface~ProgressCallback?

Returns Promise<(AWS.Response | Error)> the requested object in the Body property

saveFile

Saves file to S3

Parameters

  • bucket AWS.S3
  • file ArrayBuffer
  • filename String
  • params Object additonal params to attach to the request
  • progress StorageInterface~ProgressCallback?

Returns Promise<(AWS.Response | Error)> the response

getFile

Gets file from S3

Parameters

  • bucket AWS.S3
  • filename String
  • params Object additonal params to attach to the request
  • progress StorageInterface~ProgressCallback?

Returns Promise<(AWS.Response | Error)> the requested file in the Body property

LocalStorage

Parameters

  • saveAs
  • text
  • filename
  • type (optional, default 'application/octet-stream')

saveText

Saves text

Parameters

Returns Promise<String> file's name

saveObject

Saves object

Parameters

Returns Promise<String> file's name

saveFile

Saves file

Parameters

Returns Promise<String> file's name

RecordSerialization

serialize

Serialize record

Parameters

  • record Record the record without data property in the files's objects

Returns String

deserialize

Deserialize record

Parameters

Returns Record the record without data property in the files's objects

serializeURL

Serialize record to be url compatible

Parameters

  • record Record the record without data property in the files's objects

Returns String

deserializeURL

Deserialize record from url serialization

Parameters

Returns Record the record without data property in the files's objects

Record

save

Save record

Parameters

  • recordId String the id under which to save the record
  • record Record the record without data property in the files's objects
  • serializeRecord (RecordSerialization~serialize | RecordSerialization~serializeURL)
  • saveText StorageInterface~saveText

Returns Promise<(String | Error)> record id

get

Get record

Parameters

  • recordId String
  • deserializeRecord (RecordSerialization~deserialize | RecordSerialization~deserializeURL)
  • getText StorageInterface~getText

Returns Promise<(Record | Error)> the record without data property in the files's objects

extract

Extract record

Extract only the record part in order to serialize it before persistence

Parameters

Returns Record the record without files property in the blocks

Files

save

Save files

Parameters

  • files Array<EncryptedFile>
  • saveFile StorageInterface~saveFile

Returns Promise<(Array<AWS.Response> | Error)>

get

Get files

Parameters

  • files Array<{id: String}>
  • getFile StorageInterface~getFile

Returns Promise<(Array<EncryptedFile> | Error)>

extract

Extract files

Extract only the files part in order to persist it

Parameters

Returns Array<EncryptedFile>

RecordAndFiles

save

Save record and files

Parameters

  • recordId String the id under which to save the record
  • record Array<Record>
  • serializeRecord (RecordSerialization~serialize | RecordSerialization~serializeURL)
  • saveText StorageInterface~saveText
  • saveFile StorageInterface~saveFile

Returns Promise<(String | Error)> record id

saveAndSerializeRecord

Save files and serialize record

Parameters

  • record Array<Record>
  • serializeRecord (RecordSerialization~serialize | RecordSerialization~serializeURL)
  • saveFile StorageInterface~saveFile

Returns Promise<(String | Error)> serialized record

StorageInterface

ProgressCallback

Parameters

  • filename String
  • progress Number number between 0 and 1 representing the progress

GetFile

Parameters

Returns Promise<(ArrayBuffer | Error)> the requested file

SaveFile

Parameters

Returns Promise<(String | Error)> file's name

GetObject

Parameters

Returns Promise<(Object | Error)> the requested object

SaveObject

Parameters

Returns Promise<(String | Error)> object's name

GetText

Parameters

Returns Promise<(String | Error)> the requested text

SaveText

Parameters

Returns Promise<(String | Error)> file's name

Development

  • make sure node installed - install nvm if not
  • git clone [email protected]:witalize/cryptolize-persistence.git
  • cd cryptolize-persistence
  • npm install
  • lint code - npm run lint
  • run tests - npm test
  • build from src - npm run build
  • update README - npm run docs
  • publish to npm (runs automatically tests, lint and build before) - npm publish