Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nuskin/bynder-dat

Package Overview
Dependencies
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuskin/bynder-dat

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

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
5
Weekly downloads
 
Created
Source

@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

  • Bynder DAT Doc

License

MIT

Keywords

FAQs

Package last updated on 15 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc