Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
breck7 committed Dec 23, 2024
1 parent ec8cf7c commit b60bd66
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -59,4 +59,4 @@
"ts-node": "^10.9.1",
"typescript": "^5.0.3"
}
}
}
5 changes: 5 additions & 0 deletions particle/Particle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
12 changes: 11 additions & 1 deletion particle/Particle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion products/Particle.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion products/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions products/Particle.test.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
3 changes: 3 additions & 0 deletions releaseNotes.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b60bd66

Please sign in to comment.