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

@ableroy1996/camera-js

v1.0.0

Published

@ableroy1996/camera-js is a lightweight JavaScript package that enables easy integration of camera functionality into any web application. It allows you to open the camera, take multiple photos, and retrieve them for use in your application.

Readme

@ableroy1996/camera-js

@ableroy1996/camera-js is a lightweight JavaScript package that enables easy integration of camera functionality into any web application. It allows you to open the camera, take multiple photos, and retrieve them for use in your application.

Installation

Install the package using npm:

npm install @ableroy1996/camera-js

Usage

Follow these steps to integrate @ableroy1996/camera-js into your web application:

1. Import the Package

import Camera from '@ableroy1996/camera-js';

2. Initialize the Camera

Create a container in your HTML where the camera feed will be displayed:

<div id="camera-container" style="width: 100%; height: auto;"></div>

Then, initialize the camera in your JavaScript:

const camera = new Camera();

3. Open the Camera

Call the openCamera method to open the camera in the specified container:

await camera.openCamera('camera-container');

4. Take Photos

Use the clickPhoto method to capture a photo. This will return a base64-encoded image string:

const photo = camera.clickPhoto();
console.log(photo); // Logs the base64-encoded image data

5. Retrieve All Photos

Call the getPhotos method to retrieve all photos taken in the current session:

const photos = camera.getPhotos();
console.log(photos); // Array of base64-encoded images

6. Stop the Camera

To release the camera and stop the feed, use the stopCamera method:

camera.stopCamera();

Example Integration

Here’s a full example:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>@ableroy1996/camera-js Example</title>
</head>
<body>
  <div id="camera-container" style="width: 100%; height: auto;"></div>
  <button id="take-photo">Take Photo</button>
  <button id="stop-camera">Stop Camera</button>
  <div id="photos"></div>

  <script type="module">
    import Camera from '@ableroy1996/camera-js';

    const camera = new Camera();

    // Open camera
    await camera.openCamera('camera-container');

    // Take photo
    document.getElementById('take-photo').addEventListener('click', () => {
      const photo = camera.clickPhoto();
      const img = document.createElement('img');
      img.src = photo;
      document.getElementById('photos').appendChild(img);
    });

    // Stop camera
    document.getElementById('stop-camera').addEventListener('click', () => {
      camera.stopCamera();
    });
  </script>
</body>
</html>

API Reference

openCamera(containerId: string): Promise<void>

Opens the camera and displays the feed in the specified container.

  • containerId: ID of the HTML container where the camera feed will be displayed.

clickPhoto(): string

Captures a photo from the camera feed and returns a base64-encoded image string.


getPhotos(): string[]

Returns an array of all photos taken during the current session.


stopCamera(): void

Stops the camera feed and releases resources.


License

MIT