Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
necolas committed Jan 29, 2025
1 parent 37f3b88 commit 6f11819
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions packages/shared/src/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,18 @@ const hash = (str: string): string => murmurhash2_32_gc(str, 1).toString(36);

export default hash as (str: string) => string;

const base62Chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
function toBase62(num) {
const base62Chars =
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
function toBase62(num: number) {
let result = '';
while (num > 0) {
const remainder = num % 62;
let _num = num;
while (_num > 0) {
const remainder = _num % 62;
result = base62Chars[remainder] + result;
num = Math.floor(num / 62);
_num = Math.floor(_num / 62);
}
return result;
}

export const createShortHash = (str: string): string => toBase62(murmurhash2_32_gc(str, 1) % (62 ** 5))
export const createShortHash = (str: string): string =>
toBase62(murmurhash2_32_gc(str, 1) % 62 ** 5);
3 changes: 2 additions & 1 deletion packages/shared/src/stylex-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import type {
} from './common-types';
import type { ComputedStyle, IPreRule } from './preprocess-rules/PreRule';

import createHash, { createShortHash } from './hash';
// import createHash from './hash';
import { createShortHash } from './hash';
import { IncludedStyles } from './stylex-include';
import { defaultOptions } from './utils/default-options';
import { flattenRawStyleObject } from './preprocess-rules/flatten-raw-style-obj';
Expand Down

0 comments on commit 6f11819

Please sign in to comment.