spooder 4.2.3 → 4.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/api.ts +2 -11
package/README.md CHANGED
@@ -1008,7 +1008,7 @@ generate_hash_subs(40).then(...);
1008
1008
  > [!NOTE]
1009
1009
  > SHA-1 hashes are `40` characters. Git is transitioning to SHA-256, which are `64` characters. Short hashes of `7` are generally sufficient for cache-busting.
1010
1010
 
1011
- Use a different prefix other than `$hash=` by passing it as the first parameter.
1011
+ Use a different prefix other than `hash=` by passing it as the first parameter.
1012
1012
 
1013
1013
  ```ts
1014
1014
  generate_hash_subs(7, '$#').then(subs => hash_sub_table = subs).catch(caution);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "spooder",
3
3
  "type": "module",
4
- "version": "4.2.3",
4
+ "version": "4.2.5",
5
5
  "exports": {
6
6
  ".": {
7
7
  "bun": "./src/api.ts",
package/src/api.ts CHANGED
@@ -131,17 +131,8 @@ export function parse_template(template: string, replacements: Record<string, st
131
131
  } else {
132
132
  const loop_content = template.substring(loop_content_start_index, loop_close_index);
133
133
  if (loop_entries !== undefined) {
134
- // More performat than replaceAll on larger arrays (and equal on tiny arrays).
135
- const content_parts = loop_content.split('%s');
136
- const indicies = [] as Array<number>;
137
-
138
- for (let j = 0; j < content_parts.length; j++)
139
- if (content_parts[j] === '%s')
140
- indicies.push(j);
141
-
142
134
  for (const loop_entry of loop_entries)
143
- for (const index of indicies)
144
- content_parts[index] = loop_entry;
135
+ result += loop_content.replaceAll('%s', loop_entry);
145
136
  } else {
146
137
  result += '{$' + buffer + '}' + loop_content + '{/for}';
147
138
  }
@@ -161,7 +152,7 @@ export function parse_template(template: string, replacements: Record<string, st
161
152
  return result;
162
153
  }
163
154
 
164
- export async function generate_hash_subs(length = 7, prefix = '$hash='): Promise<Record<string, string>> {
155
+ export async function generate_hash_subs(length = 7, prefix = 'hash='): Promise<Record<string, string>> {
165
156
  const cmd = ['git', 'ls-tree', '-r', 'HEAD'];
166
157
  const process = Bun.spawn(cmd, {
167
158
  stdout: 'pipe',