From 709b4a1df939fa0ea52d4158d6b611428e171e65 Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 30 May 2026 20:32:41 +0100 Subject: [PATCH 1/2] feat: add `strip-bom` and `strip-bom-string` to replacements --- manifests/micro-utilities.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/manifests/micro-utilities.json b/manifests/micro-utilities.json index 3758477e..dfffe190 100644 --- a/manifests/micro-utilities.json +++ b/manifests/micro-utilities.json @@ -342,6 +342,12 @@ "description": "You can split a string into lines using a regular expression.", "example": "const splitLines = (str) => str.split(/\\r?\\n/);" }, + "snippet::strip-bom": { + "id": "snippet::strip-bom", + "type": "simple", + "description": "You can check the start of a string for the BOM character and use `String.prototype.slice` if it is present.", + "example": "str.startsWith('\\ufeff') ? str.slice(1) : str;" + }, "snippet::to-lower": { "id": "snippet::to-lower", "type": "simple", @@ -774,6 +780,16 @@ "moduleName": "split-lines", "replacements": ["snippet::split-lines"] }, + "strip-bom": { + "type": "module", + "moduleName": "strip-bom", + "replacements": ["snippet::strip-bom"] + }, + "strip-bom-string": { + "type": "module", + "moduleName": "strip-bom-string", + "replacements": ["snippet::strip-bom"] + }, "toarray": { "type": "module", "moduleName": "toarray", From dc4db0ccb35cb6b6d04db83f7768023a1f9efab0 Mon Sep 17 00:00:00 2001 From: Roman Date: Sun, 31 May 2026 21:32:11 +0100 Subject: [PATCH 2/2] Apply suggestion from @gameroman --- manifests/micro-utilities.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/micro-utilities.json b/manifests/micro-utilities.json index dfffe190..6bc77f1a 100644 --- a/manifests/micro-utilities.json +++ b/manifests/micro-utilities.json @@ -345,8 +345,8 @@ "snippet::strip-bom": { "id": "snippet::strip-bom", "type": "simple", - "description": "You can check the start of a string for the BOM character and use `String.prototype.slice` if it is present.", - "example": "str.startsWith('\\ufeff') ? str.slice(1) : str;" + "description": "You can check if the first character of the string is the BOM and strip it using `String.prototype.slice` if it is.", + "example": "str.charCodeAt(0) === 0xFEFF ? str.slice(1) : str;" }, "snippet::to-lower": { "id": "snippet::to-lower",