Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zag-js/i18n-utils

Package Overview
Dependencies
Maintainers
0
Versions
460
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/i18n-utils - npm Package Compare versions

Comparing version 0.71.0 to 0.72.0

12

dist/index.d.ts

@@ -0,1 +1,11 @@

interface FilterReturn {
startsWith(string: string, substring: string): boolean;
endsWith(string: string, substring: string): boolean;
contains(string: string, substring: string): boolean;
}
interface FilterOptions extends Intl.CollatorOptions {
locale?: string;
}
declare function filter(options?: FilterOptions): FilterReturn;
interface FormatBytesOptions {

@@ -41,2 +51,2 @@ unit?: "bit" | "byte";

export { type FormatBytesOptions, type Locale, type LocaleOptions, formatBytes, formatDate, formatList, formatNumber, formatRelativeTime, getDefaultLocale, getLocaleDir, isRTL, trackLocale };
export { type FilterOptions, type FilterReturn, type FormatBytesOptions, type Locale, type LocaleOptions, filter, formatBytes, formatDate, formatList, formatNumber, formatRelativeTime, getDefaultLocale, getLocaleDir, isRTL, trackLocale };

@@ -19,2 +19,47 @@ 'use strict';

// src/filter.ts
var collatorCache = i18nCache(Intl.Collator);
function filter(options) {
const { locale, ...rest } = options || {};
const collator = collatorCache(locale || "en-US", { usage: "search", ...rest });
function normalize(string) {
string = string.normalize("NFC");
if (collator.resolvedOptions().ignorePunctuation) {
string = string.replace(/\p{P}/gu, "");
}
return string;
}
function startsWith(string, substring) {
if (substring.length === 0) return true;
string = normalize(string);
substring = normalize(substring);
return collator.compare(string.slice(0, substring.length), substring) === 0;
}
function endsWith(string, substring) {
if (substring.length === 0) return true;
string = normalize(string);
substring = normalize(substring);
return collator.compare(string.slice(-substring.length), substring) === 0;
}
function contains(string, substring) {
if (substring.length === 0) return true;
string = normalize(string);
substring = normalize(substring);
let scan = 0;
let sliceLen = substring.length;
for (; scan + sliceLen <= string.length; scan++) {
let slice = string.slice(scan, scan + sliceLen);
if (collator.compare(substring, slice) === 0) {
return true;
}
}
return false;
}
return {
startsWith,
endsWith,
contains
};
}
// src/format-number.ts

@@ -394,2 +439,3 @@ var getNumberFormatter = i18nCache(Intl.NumberFormat);

exports.filter = filter;
exports.formatBytes = formatBytes;

@@ -396,0 +442,0 @@ exports.formatDate = formatDate;

4

package.json
{
"name": "@zag-js/i18n-utils",
"version": "0.71.0",
"version": "0.72.0",
"description": "Interationalization utilities for Zag.js",

@@ -27,3 +27,3 @@ "keywords": [

"dependencies": {
"@zag-js/dom-query": "0.71.0"
"@zag-js/dom-query": "0.72.0"
},

@@ -30,0 +30,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc