From b60bd66847d85cace70e376d44993d12935c011c Mon Sep 17 00:00:00 2001 From: Breck Yunits Date: Mon, 23 Dec 2024 13:14:01 -0800 Subject: [PATCH] --- package.json | 4 ++-- particle/Particle.test.ts | 5 +++++ particle/Particle.ts | 12 +++++++++++- products/Particle.browser.js | 11 ++++++++++- products/Particle.js | 11 ++++++++++- products/Particle.test.browser.js | 4 ++++ releaseNotes.scroll | 3 +++ 7 files changed, 45 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 7058a2485..cd2ab9cd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scrollsdk", - "version": "100.1.1", + "version": "100.2.0", "description": "This npm package includes the Particles class, the Parsers compiler-compiler, a Parsers IDE, and more, all implemented in Particles, Parsers, and TypeScript.", "types": "./built/scrollsdk.node.d.ts", "main": "./products/Particle.js", @@ -59,4 +59,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.3" } -} +} \ No newline at end of file diff --git a/particle/Particle.test.ts b/particle/Particle.test.ts index 1bfbe5f5b..4db855187 100755 --- a/particle/Particle.test.ts +++ b/particle/Particle.test.ts @@ -3367,6 +3367,11 @@ testParticles.nest = equal => { equal(new Particle(`${Particle.nest("foo bar", 2)}`).particleAt([0, 0]).content, "foo bar") } +testParticles.hashes = equal => { + // Arrange/Act/Assert + equal(typeof new Particle("hi").murmurHash, "string") +} + testParticles.toDataTable = equal => { // Arrange const data = [ diff --git a/particle/Particle.ts b/particle/Particle.ts index 938d2d740..88200492f 100644 --- a/particle/Particle.ts +++ b/particle/Particle.ts @@ -1045,6 +1045,16 @@ class Particle extends AbstractParticle { return this._subparticlesToString(indentCount) } + get murmurHash(): string { + const str = this.toString() + let h1 = 0xdeadbeef + for (let i = 0; i < str.length; i++) { + const char = str.charCodeAt(i) + h1 = Math.imul(h1 ^ char, 0x5bd1e995) + } + return (h1 >>> 0).toString(16) + } + // todo: implement protected _getChildJoinCharacter() { return "\n" @@ -3109,7 +3119,7 @@ class Particle extends AbstractParticle { return str ? indent + str.replace(/\n/g, indent) : "" } - static getVersion = () => "100.1.1" + static getVersion = () => "100.2.0" static fromDisk(path: string): Particle { const format = this._getFileFormat(path) diff --git a/products/Particle.browser.js b/products/Particle.browser.js index b4c16706b..33590b25d 100644 --- a/products/Particle.browser.js +++ b/products/Particle.browser.js @@ -878,6 +878,15 @@ class Particle extends AbstractParticle { subparticlesToString(indentCount = 0) { return this._subparticlesToString(indentCount) } + get murmurHash() { + const str = this.toString() + let h1 = 0xdeadbeef + for (let i = 0; i < str.length; i++) { + const char = str.charCodeAt(i) + h1 = Math.imul(h1 ^ char, 0x5bd1e995) + } + return (h1 >>> 0).toString(16) + } // todo: implement _getChildJoinCharacter() { return "\n" @@ -2613,7 +2622,7 @@ Particle.iris = `sepal_length,sepal_width,petal_length,petal_width,species 4.9,2.5,4.5,1.7,virginica 5.1,3.5,1.4,0.2,setosa 5,3.4,1.5,0.2,setosa` -Particle.getVersion = () => "100.1.1" +Particle.getVersion = () => "100.2.0" class AbstractExtendibleParticle extends Particle { _getFromExtended(cuePath) { const hit = this._getParticleFromExtended(cuePath) diff --git a/products/Particle.js b/products/Particle.js index 2f51b0df8..618fb9a30 100644 --- a/products/Particle.js +++ b/products/Particle.js @@ -868,6 +868,15 @@ class Particle extends AbstractParticle { subparticlesToString(indentCount = 0) { return this._subparticlesToString(indentCount) } + get murmurHash() { + const str = this.toString() + let h1 = 0xdeadbeef + for (let i = 0; i < str.length; i++) { + const char = str.charCodeAt(i) + h1 = Math.imul(h1 ^ char, 0x5bd1e995) + } + return (h1 >>> 0).toString(16) + } // todo: implement _getChildJoinCharacter() { return "\n" @@ -2603,7 +2612,7 @@ Particle.iris = `sepal_length,sepal_width,petal_length,petal_width,species 4.9,2.5,4.5,1.7,virginica 5.1,3.5,1.4,0.2,setosa 5,3.4,1.5,0.2,setosa` -Particle.getVersion = () => "100.1.1" +Particle.getVersion = () => "100.2.0" class AbstractExtendibleParticle extends Particle { _getFromExtended(cuePath) { const hit = this._getParticleFromExtended(cuePath) diff --git a/products/Particle.test.browser.js b/products/Particle.test.browser.js index 1286b0614..36c120c40 100644 --- a/products/Particle.test.browser.js +++ b/products/Particle.test.browser.js @@ -2769,6 +2769,10 @@ testParticles.nest = equal => { equal(new Particle(`${Particle.nest("foo bar", 1)}`).getParticle(" foo").content, "bar") equal(new Particle(`${Particle.nest("foo bar", 2)}`).particleAt([0, 0]).content, "foo bar") } +testParticles.hashes = equal => { + // Arrange/Act/Assert + equal(typeof new Particle("hi").murmurHash, "string") +} testParticles.toDataTable = equal => { // Arrange const data = [ diff --git a/releaseNotes.scroll b/releaseNotes.scroll index 0de28083f..fa302fe8a 100644 --- a/releaseNotes.scroll +++ b/releaseNotes.scroll @@ -20,6 +20,9 @@ node_modules/scroll-cli/microlangs/changes.parsers thinColumns 4 +📦 100.2.0 2024-12-23 +🎉 added murmurHash for cache use + 📦 100.1.1 2024-12-16 🏥 escape left bracket in htmlCube