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 🙏

© 2026 – Pkg Stats / Ryan Hefner

instagram-model-ts

v1.0.0

Published

Instagram model

Readme

Instagram Model TS Documentation

How to use

const system = instagramSystem;

InstagramSystem

class InstagramSystem {
  /**
   * @param {Array<User>} users
   * @param {Array<Post>} posts
   */

  /**
   * Logs in with email and password.
   *
   * @param {string} email The user's email.
   * @param {string} password The user's password.
   * @return {User} The authenticated user.
   * @throws {UserException} If the email or password is incorrect.
   */
  login(email: string, password: string): User
  
  /**
   * Add a new user to the system.
   *
   * @param {DraftUser} user The user to add.
   * @return {User} The newly created user.
   * @throws {UserException} If the email address is already in use.
   */
  register(draftUser: DraftUser): User

  /**
   * Get a user by its ID.
   *
   * @param {string} id The ID of the user.
   * @return {User} The user with the given ID.
   * @throws {UserException} If the user with the given ID does not exist.
   */
  getUser(id: string): User

  /**
   * Get a post by its ID.
   *
   * @param {string} id The ID of the post.
   * @return {Post} The post with the given ID.
   * @throws {PostException} If the post with the given ID does not exist.
   */
  getPost(id: string): Post

  /**
   * Adds a new post to the system for a given user.
   *
   * @param {string} userId The ID of the user creating the post.
   * @param {DraftPost} draftPost The draft post data to be added.
   * @return {Post} The newly created post.
   * @throws {UserException} If the user with the given ID does not exist.
   */
  addPost(userId: string, draftPost: DraftPost): Post

  
  /**
   * Edits an existing post with new data.
   *
   * @param {string} id The ID of the post to edit.
   * @param {DraftPost} updatedPost The updated post data.
   * @return {Post} The updated post.
   * @throws {PostException} If the post with the given ID does not exist.
   */
  editPost(id: string, updatedPost: DraftPost): Post

  
  /**
   * Deletes a post from the system by its ID.
   *
   * @param {string} id The ID of the post to delete.
   * @return {void}
   * @throws {PostException} If the post with the given ID does not exist.
   */
  deletePost(id: string): void


  /**
   * Adds a comment to a post.
   *
   * @param {string} postId - The ID of the post to comment on.
   * @param {string} userId - The ID of the user making the comment.
   * @param {DraftComment} comment - The comment data to be added.
   * @returns {Post} The updated post with the new comment.
   * @throws {UserException} If the user with the given ID does not exist.
   * @throws {PostException} If the post with the given ID does not exist.
   */
  addComment(postId: string, userId: string, comment: DraftComment): Post

  /**
   * Updates the like status of a post for a given user.
   * If the user has already liked the post, the like is removed; otherwise, a like is added.
   *
   * @param {string} postId - The ID of the post to like or unlike.
   * @param {string} userId - The ID of the user performing the action.
   * @returns {Post} The updated post with the new like status.
   * @throws {UserException} If the user with the given ID does not exist.
   * @throws {PostException} If the post with the given ID does not exist.
   */
  updateLike(postId: string, userId: string): Post

  /**
   * Updates the follower relationship between two users.
   * If the follower already follows the target user, the follow is removed; otherwise, a follow is added.
   *
   * @param {string} fromUserId - The ID of the user who is following or unfollowing.
   * @param {string} toUserId - The ID of the user to be followed or unfollowed.
   * @returns {User} The updated user with the new followers list.
   * @throws {UserException} If either user does not exist.
   */
  updateFollower(fromUserId: string, toUserId: string): User

  /**
   * Searches for posts containing a specific tag in their description.
   *
   * @param {string} tag - The tag to search for (without the # symbol).
   * @returns {Array<Post>} An array of posts containing the specified tag, sorted by date (newest first).
   */
  searchByTag(tag: string): Array<Post>

  /**
   * Searches for posts by users whose names include the specified string.
   *
   * @param {string} name - The name or partial name to search for.
   * @returns {Array<Post>} An array of posts by users matching the name, sorted by date (newest first).
   */
  searchByUserName(name: string): Array<Post>

  /**
   * Searches for posts by a specific user ID.
   *
   * @param {string} userId - The ID of the user whose posts to retrieve.
   * @returns {Array<Post>} An array of posts by the specified user, sorted by date (newest first).
   * @throws {UserException} If the user with the given ID does not exist.
   */
  searchByUserId(userId: string): Array<Post>

  /**
   * Searches for users whose names include the specified string.
   *
   * @param {string} name - The name or partial name to search for.
   * @returns {Array<User>} An array of users matching the name, sorted alphabetically.
   */
  searchByName(name: string): Array<User>

  /**
   * Retrieves the timeline for a user, consisting of posts from users they follow.
   *
   * @param {string} userId - The ID of the user whose timeline to retrieve.
   * @returns {Array<Post>} An array of posts from followed users, sorted by date (newest first).
   * @throws {UserException} If the user with the given ID does not exist.
   */
  timeline(userId: string): Array<Post>
}

Model

type User = {
  id: string,
  name: string,
  email: string,
  password: string,
  image: string,
  followers: Array<User>
}
type Post = {
  id: string,
  image: string,
  description: string,
  user: User,
  date: Date,
  comments: Array<Comment>,
  likes: Array<User>
}
type Comment = {
  id: string,
  body: string,
  user: User,
}

Drafts

type DraftPost = {
  image: string;
  description: string;
}
type DraftComment = {
  body: string;
}
type DraftUser = {
  name: string;
  email: string;
  password: string;
  image: string;
}