Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark remarkablemark

View GitHub Profile
View lerna.json.diff
{
+ "npmClient": "yarn",
+ "useWorkspaces": true,
"packages": ["packages/*"],
"version": "independent"
}
View package.json.diff
{
"name": "root",
"private": true,
+ "workspaces": ["packages/*"],
"devDependencies": {
"lerna": "^4.0.0"
}
}
View browser-hash-usage.js
hash('foo').then((hex) => console.log(hex)); // '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
View browser-hash.js
async function hash(string) {
const utf8 = new TextEncoder().encode(string);
const hashBuffer = await crypto.subtle.digest('SHA-256', utf8);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray
.map((bytes) => bytes.toString(16).padStart(2, '0'))
.join('');
return hashHex;
}
View browser-hash.js
function hash(string) {
const utf8 = new TextEncoder().encode(string);
return crypto.subtle.digest('SHA-256', utf8).then((hashBuffer) => {
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray
.map((bytes) => bytes.toString(16).padStart(2, '0'))
.join('');
return hashHex;
});
}
View nodejs-hash.js
const { createHash } = require('crypto');
function hash(string) {
return createHash('sha256').update(string).digest('hex');
}
View rollup.config.js.diff
// rollup.config.js
import commonjs from '@rollup/plugin-commonjs';
import import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
+import json from '@rollup/plugin-json';
const config = {
input: 'index.js',
output: {
format: 'umd',
@remarkablemark
remarkablemark / facebook-conversions-api.md
Created Aug 5, 2021
Facebook Conversions API (Node.js)
View facebook-conversions-api.md