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

iz-library

v1.0.3

Published

Fake library API for WAD Assignment 1

Downloads

3

Readme

Isaac's Library Module

This node module provides essential functionality for a library book borrowing service. With this module, book readers can create accounts and borrow books with ease.

Installation

Before starting, make sure you have downloaded and installed Node.js. This node module has been tested with Node.js v16.17.0.

Install iz-library with the npm install command:

npm install iz-library

If you have cloned this module from GitHub, install the module dependencies with the npm install command.

Getting Started

Start by requiring the module in your project:

const library = require('iz-library')

If you have cloned this module from GitHub, include the module with require as follows:

const library = require('./IsaacKoh_Library');

Books

1. Add Book(s)

Takes in an object and adds the specified number of books to the library. The object has to have a name, author and quantity.

const newBook = library.books.add({
    name: 'The New Book',
    author: 'Francis Mellow',
    quantity: 2
});
console.log(newBook);

2. Get all Books

Returns an array of all books currently in the library. The array will not include books that have been borrowed.

const allBooks = library.books.getAll();
console.log(JSON.stringify(allBooks, null, 2));

3. Search Book by Name

Returns an array of all books with names containing the search text. It is not case-sensitive.

const nameSearch = library.books.searchName('the M');
console.log(JSON.stringify(nameSearch, null, 2));

4. Get borrowed Books

Returns an array of all books borrowed from the library.

const allBorrowed = library.books.getAllBorrowed();
console.log(JSON.stringify(allBorrowed, null, 2));

5. Get Books borrowed by User

Takes in a user_id and returns an array containing all books borrowed by the user.

const userBorrows = library.books.getUserBorrows("b2b1b3b4-3a3a-4b4b-9c9c-2d2d2d2d2d2d");
console.log(JSON.stringify(userBorrows, null, 2));

6. Borrow Book

Takes in a userId, bookName and quantity. The quantity specifies the number of said book to borrow.

const borrowBook = library.books.borrow("b2b1b3b4-3a3a-4b4b-9c9c-2d2d2d2d2d2d", "The Secret Code", 2);
console.log(JSON.stringify(borrowBook, null, 2));
  • Each user can only borrow up to 2 of the same book

7. Return Book

Takes in a userId, bookName and quantity. The quantity specifies the number of said book to return.

const returnBook = library.books.returnBook("b2b1b3b4-3a3a-4b4b-9c9c-2d2d2d2d2d2d", "The Secret Code", 1);
console.log(JSON.stringify(returnBook, null, 2));

Users

1. Register

Takes in an object and adds it as a new user to the library. Each object has to have an email, username and password.

const newUser = library.users.register({
    email: '[email protected]',
    username: 'bob',
    password: 'p@ssw0rd'
});
console.log(JSON.stringify(newUser, null, 2));
  • Each email is unique to an account
  • Usernames cannot contain whitespaces
  • Passwords have to be at least 8 characters long, containing an alphabet, number and symbol

2. Log in

Authenticates user based on their email and password. Returns an array containing a message and an object containing the user data if the provided credentials are valid.

const loginUser = library.users.login('[email protected]', 'p@ssw0rd');
console.log(JSON.stringify(loginUser, null, 2));

3. Get User by ID

Takes in a userId and returns an object containing specified user data.

const userById = library.users.getById("c5c6c7c8-1b1b-4c4c-7d7d-3e3e3e3e3e3e");
console.log(JSON.stringify(userById, null, 2));

4. Get User by Email

Takes in an email and returns an object containing specified user data.

const userByEmail = library.users.getByEmail("[email protected]");
console.log(JSON.stringify(userByEmail, null, 2));