New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

discord-snowflake

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-snowflake

A library for identifying and parsing Discord Snowflakes

  • 2.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
106
increased by9.28%
Maintainers
2
Weekly downloads
 
Created
Source

discord-snowflake

discord-snowflake is a library for parsing Discord Snowflakes.

Usage

To install the package, run the following in your terminal:

npm install discord-snowflake

Then in your code import the library:

import * as SnowflakeUtils from "discord-snowflake";

API

EPOCH

A constant representing the Discord epoch.

import { EPOCH } from "discord-snowflake";

Type: Snowflake

A type representing a Discord Snowflake.

import type { Snowflake } from "discord-snowflake";

Typeguard: isSnowflake(id: string): boolean

A typeguard function that returns whether the string is a valid Snowflake or not.

import { isSnowflake } from "discord-snowflake";

console.log(isSnowflake("90339695967350784"));
// => true

getTimestamp(snowflake: Snowflake): number

import { getTimestamp } from "discord-snowflake";

console.log(getTimestamp("90339695967350784"));
// => 1441609061949

getDate(snowflake: Snowflake): Date

import { getDate } from "discord-snowflake";

console.log(getDate("90339695967350784"));
// =>  2015-09-07T06:57:41.949Z (date object)

getWorkerId(snowflake: Snowflake): number

import { getWorkerId } from "discord-snowflake";

console.log(getWorkerId("90339695967350784"));
// => 0

getProcessId(snowflake: Snowflake): Number

import { getProcessId } from "discord-snowflake";

console.log(getProcessId("90339695967350784"));
// => 3

getIncrement(snowflake: Snowflake): number

import { getIncrement } from "discord-snowflake";

console.log(getIncrement("90339695967350784"));
// => 0

parse(snowflake: Snowflake)

import { parse } from "discord-snowflake";

console.log(parse("90339695967350784"));
// => { timestamp: 1441609061949, workerId: 0, processId: 3, increment: 0 }

Credits

Special thanks to theking465 for the original package implementation.

FAQs

Package last updated on 28 Jul 2022

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