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

alexandria-core

v1.0.10

Published

The core module of Alexandria!

Downloads

5

Readme

alexandria-core

An NPM module containing all of the core functionality to run the Alexandria front end.

Work in Progress

This section is a work in progress, so more information will be added periotically. Information may be out of data, for latest information, please read the code :)

Modules

Inside of Alexandria Core there are currently 4 modules. Each of the four modules have specific tasks to try and seperate the logic out. They are seperated as follows:

  • Artifact: This contains helper functions for manipulating artifact JSON.
  • Data: This contains simple access to application information that was fetched by the network layer.
  • Network: Usually called by the Data layer. This module contains all of the server calls & network transfer functions (i.e. IPFS).
  • util: Other generally helpful utility functions that we have found helpful.

Currently, we have implemented or planned the following functions:

Core.Artifact

Core.Artifact.getTXID(oipArtifactID): returns the txid of the given artifact.

Core.Artifact.getTitle(oipArtifactID): returns the title of the given artifact.

Core.Artifact.getType(oipArtifactID): returns the type of the given artifact.

Core.Artifact.getSubtype(oipArtifactID): returns the subtype of the given artifact.

Core.Artifact.getDescription(oipArtifactID): returns the description of the given artifact.

Core.Artifact.getLocation(oipArtifactID): If the whole artifact is free, returns the location address of the given artifact (This is usually the IPFS hash, unless the Artifact uses another data storage layer) as storage:location. If any of the artifact is commercial, return "permission denied"

Core.Artifact.getFiles(oipArtifactID): returns the data related to the files in the given artifact, Including dNames, fNames and playtime and pricing fields. If any of the artifact is commercial, for all of the files which are available(free), returns ipfs file hashes as storage:files:location, and return "permission denied" for files which are not yet available (not yet paid for).

Core.Artifact.getPublisherAlias(oipArtifactID): returns the Publisher Alias for the Publisher that published the Artifact. If no Publisher Alias was specified, returns "Flotoshi"

Core.Artifact.getPublisherAddress(oipArtifactID): returns the Publisher Address which published the artifact.

Core.Artifact.getArtist(oipArtifactID): returns the Artist of the given artifact. If an Artist was not specified, returns Publisher Alias instead.

Core.Artifact.getTipPrefs(oipArtifactID): returns the tipping address and suggested tip values.

Core.Artifact.getThumbnail(oipArtifactID): returns the fName of the Thumbnail for the given artifact. This is calculated as the first File with the type "Image" that does not have a price to view it. Returns "" if no thumbnail can be found.

Core.Artifact.getFirstImage(oipArtifactID): returns the first image in the given artifact. If none are found, "" will be returned.

Core.Artifact.getFirstHTML(oipArtifactID): returns the first html document in the given artifact. This is calculated by grabbing the extension off of files, the first one with an extension of .html will be returned. If none are found, "" will be returned.

Core.Artifact.getSongs(oipArtifactID): returns a formatted JSON object of songs in the given artifact.

Core.Artifact.getEntypoIconForType(oipArtifactID): returns the css class for the artifact type. This will likely be not very useful for most people.

Core.Artifact.paid(oipArtifactID): returns true if any files have either a suggested buy price or suggested play price. Otherwise it will return false.

Core.Index

Core.Index.getSupportedArtifacts(callback(supportedArtifacts)): Provides an array of supported artifacts to the callback. All artifacts will be formatted based on the highest version supported by alexandria-core. Currently this is oip-041.

Core.Index.getLatestArtifacts(callback(latestArtifacts)): This will grab the latest artifacts from OIPd and return them as a JSON array to the callback.

Core.Index.getRegisteredPublishers(callback(registeredPublishers)): Provides an array of registered publishers to the callback. All publishers will be formatted based on the highest version supported by alexandria-core, currently this is oip-041. paginated, sortable by various fields

Core.Index.getPublisherDetail(oipPublisherAddress): returns Publisher Alias, BTC Address, TXID of registration message, registration timestamp, and email md5 hash for given Publisher Address.

Core.Index.getPublisherArtifacts(oipPublisherAddress): returns a list of all artifactIDs by a given Publisher.

Core.Network

Core.Network.getIPFS(callback): Passes the IPFS object to the callback after it has been successfully spawned. You are highly discouraged from using this function, but it is here for advanced functionality.

Core.Network.getThumbnailFromIPFS(hash, onDataCallback): Give it either an IPFS file hash or hash + subfile (i.e. hash/filename.png). Each time data is downloaded (i.e. on download progress), we call the onDataCallback and pass a base64 encoded version of the file. You can feed this directly into an image source and it will load fine :)

Core.Network.getFileFromIPFS(hash, onCompleteCallback): Give it either an IPFS file hash or hash + subfile (i.e. hash/filename.png). When the file download is complete, we call the onDataCallback and pass a base64 encoded version of the file. You can feed this directly into an image source and it will load fine :)

Core.util

Core.util.chunksToFileURL(chunks, onLoad): This is used by the IPFS network layer to load byte arrays into a file URL reader, then return the fileURL base64 data to the onLoad callback.

Core.util.buildIPFSURL(hash, filename): returns a built HTTP link to the IPFS resource. Use this if you don't want to download the file, but just get the URL to access it.

Core.util.getExtension(filename): returns the file extension as a string. For example, pass this index.html and it will return html.

Core.util.decodeMakeJSONSafe(stringToDecode): This checks if there are non JSON supported characters that we should re-encode, if there are, then it encodes them and returns a fixed string, if not, it returns the original string.