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

@nuskin/bynder-dat

v1.0.0

Published

This library hosts a collection of wrapper functions for bynder's DAT API.

Downloads

64

Readme

@nuskin/bynder-dat

This library hosts a collection of wrapper functions for bynder's DAT API. The library also builds in both cjs and esm formats. ESM for better treeshaking support. CJS for node/backend apps.

Installing

Usng npm:

npm add @nuskin/bynder-dat

Usng yarn:

yarn add @nuskin/bynder-dat

Example usage

CommonJS

const { useFormat, transformFill } = require('@nuskin/bynder-dat');

// apply format
const url = useFormat('http://foo.baz.bar', 'webp');
console.log(url); // http://foo.baz.bar?format=webp

// transform
const url = transformFill('http://foo.baz.bar', { height: 100, width: 100 });
console.log(url); // http://foo.baz.bar?io=transform:fill,height:100,width:100;

// combination
const url = transformFill(useFormat('http://foo.baz.bar', 'webp'), { height: 100, width: 100 });
console.log(url); // http://foo.baz.bar?format=webp&io=transform:fill,height:100,width:100;

// inter-changeable
const url = useFormat(transformFill('http://foo.baz.bar', { height: 100, width: 100 }), 'webp');
console.log(url); // http://foo.baz.bar?io=transform:fill,height:100,width:100&format=webp;

ESM

import { useFormat, transformFill } from '@nuskin/bynder-dat';
// The same examples above can be performed.

Real world use cases

optimize

Using webp already reduces file size by alot

import { useFormat } from '@nuskin/bynder-dat';

// retrieve the DAT derivative - transformBaseUrl
const { transformBaseUrl } = bynderImageObject.derivatives;
const webpImage = useFormat(transformBaseUrl, 'webp');

optimize + tailor fit images

You know the dimensions of the image you need to render.

import { useFormat, transformFill } from '@nuskin/bynder-dat';

// retrieve the DAT derivative - transformBaseUrl
const { transformBaseUrl } = bynderImageObject.derivatives;
const webpThumbnailImage = transformFill(useFormat(transformBaseUrl, 'webp'), { height: 100, width: 100 });

optimize + responsive using image srcset attribute

You know the dimensions of the image you need to render.

import { useFormat, transformFill } from '@nuskin/bynder-dat';

// retrieve the DAT derivative - transformBaseUrl
const sourcesetMap = [
  { width: 320, height: 200 },
  { width: 800, height: 400 }
];
const { transformBaseUrl } = bynderImageObject.derivatives;
const imageSourceSet = sourcesetMap
  .map((dimensions) => `${transformFill(useFormat(transformBaseUrl, 'webp'), dimensions)} ${dimensions.width}w`)
  .join(',');
// "media.nuskin.com/transform/foo?format=webp&transform:fill,width:320,height:200 320w, media.nuskin.com/transform/foo?format=webp&transform:fill,width:800,height:400 800w"

Resources

License

MIT