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

sakfjs

v1.0.6

Published

useful functions like a swiss army knife

Downloads

5

Readme

ATTENTION: Jimp's methods are very heavy, so I'm trying to redo them in npm

sakfjs

sakfjs is a lib made by Lucas Christian, this lib was made for be like a swiss army knife, many useful functions, and efficient.

Sumário

Installation

Installation: npm i --save sakfjs

Supported Image Types

  • jpeg;
  • png.

Functions

Files

Fs

Images

Zod

getExtensions

  import { getExtensions } from "sakfjs";

  let extensions = getExtensions("image/jpeg");
  console.log(extensions); // [".jpeg", ".jpg", ".jpe"]

getMIMEType

  import { getMIMEType } from "sakfjs";

  let mimeType = getMIMEType("arquivo.js");
  console.log(mimeType); // "application/javascript"

  mimeType = getMIMEType("C:/Users/User/Pictures/image.jpg");
  console.log(mimeType); // "image/jpeg"

getStat

  import { stat } from "sakfjs";

  let imageStat = await stat("C:/Users/User/Pictures/image.jpg");
  console.log(imageStat); // fs.Stats -> https://nodejs.org/api/fs.html#class-fsstats

changeExtension

  import { changeExtension } from "sakfjs";
  import { writeFile } from "fs";

  const image = await changeExtension("C:/Users/User/Pictures/image.jpg", "png"); 

  // changeExtension returns the Image Buffer!
  console.log(image); // Buffer

  // Combine with writeFile from fs so you can see the change!
  writeFile("C:/Users/User/Pictures/image.png", image);
  // "C:/Users/User/Pictures/image.jpg" -> "C:/Users/User/Pictures/imagem.png"

changeQuality

  import { changeQuality } from "sakfjs";
  import { writeFile } from "fs";

  const image = await changeQuality("C:/Users/User/Pictures/image.jpg", 60); 

  // changeQuality returns the Image Buffer!
  console.log(image); // Buffer

  // Combine with writeFile from fs so you can see the change!
  writeFile("C:/Users/User/Pictures/image.jpg", image);

getSupportedImages

  import { getSupportedImages } from "sakfjs";
  import { readFileSync } from "fs";

  const images = getSupportedImages("C:/Users/User/Pictures");

  console.log(images); 
  /* All supported images will be returned in the array like this
    [
      {          
        name: image.jpg, 
        size: 3000, 
        path: "C:/Users/User/Pictures/image.jpg",
        ext: "jpg",
        mime: "image/jpeg"
      },
      {         
        name: image2.png,
        size: 5000,
        path: "C:/Users/User/Pictures/image2.png",
        ext: "png",
        mime: image/png
      }
    ]
  */

isASupportedImage

  import { isASupportedImage } from "sakfjs";

  let supportedImageByExt = isASupportedImage("jpg"),
  supportedImageByMIME = isASupportedImage("image/jpeg");

  let unsupportedImageByExt = isASupportedImage("gif"),
  unsupportedImageByMIME = isASupportedImage("image/gif");

  console.log(supportedImageByExt); // true
  console.log(supportedImageByMIME); // true

  console.log(unsupportedImageByExt); // false
  console.log(unsupportedImageByMIME); // false

resizeImage

  import { resizeImage } from "sakfjs";
  import { writeFile } from "fs";

  const image = await resizeImage("C:/Users/User/Pictures/image.jpg", {width: 600, height: 400}); // 1200x800 -> 600x400

  // resizeImage returns the Image Buffer!
  console.log(image); // Buffer

  // Combine with writeFile from fs so you can see the change!
  writeFile("C:/Users/User/Pictures/image.jpg", image);

isUndefined

  import { isUndefined } from "sakfjs";

  console.log(isUndefined(undefined); // true
  console.log(isUndefined("hello")); // false

isString

  import { isString } from "sakfjs";

  console.log(isString("hello")); // true
  console.log(isString(321)); // false

isNumber

  import { isNumber } from "sakfjs";

  console.log(isNumber(321)); // true
  console.log(isNumber("hello")); // false

isArray

  import { isArray } from "sakfjs";

  console.log(isArray(["hello", "world"])); // true
  console.log(isArray({hello: "world"})); // false

isBuffer

  import { readFileSync } from "fs";
  import { isBuffer } from "sakfjs";

  let buffer = readFileSync("C:/Users/User/Pictures/image.jpg");

  console.log(isBuffer(buffer); // true
  console.log(isBuffer({hello: "world"})); // false

isObject

  import { isObject } from "sakfjs";

  console.log(isObject({hello: "world"}); // true
  console.log(isObject("hello")); // false

Collaborate

Whenever you think of functions that might be useful, and that would be useful in a lib, make it and send it with a pull request, with tests already implemented in the new function.

Errors in sakfjs

If you have identified an error, just open an issue, and if you have already resolved this error, please make a pull request, so you collaborate with the project!

Authors