@indodev/toolkit 0.3.0 → 0.3.1

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.
@@ -988,4 +988,4 @@ declare function compareStrings(str1: string, str2: string, options?: CompareOpt
988
988
  */
989
989
  declare function similarity(str1: string, str2: string): number;
990
990
 
991
- export { type CompareOptions as C, type ExtractOptions as E, type SlugifyOptions as S, type TitleCaseOptions as T, toSentenceCase as a, sanitize as b, capitalize as c, contractAbbreviation as d, expandAbbreviation as e, removeStopwords as f, toFormal as g, truncate as h, isAlay as i, extractWords as j, compareStrings as k, similarity as l, type SanitizeOptions as m, normalizeWhitespace as n, type TruncateOptions as o, profanityFilter as p, removeAccents as r, slugify as s, toTitleCase as t };
991
+ export { type CompareOptions as C, type ExtractOptions as E, type SlugifyOptions as S, type TitleCaseOptions as T, toSentenceCase as a, sanitize as b, capitalize as c, contractAbbreviation as d, expandAbbreviation as e, truncate as f, extractWords as g, removeStopwords as h, toFormal as i, isAlay as j, compareStrings as k, similarity as l, type SanitizeOptions as m, normalizeWhitespace as n, type TruncateOptions as o, profanityFilter as p, removeAccents as r, slugify as s, toTitleCase as t };
@@ -988,4 +988,4 @@ declare function compareStrings(str1: string, str2: string, options?: CompareOpt
988
988
  */
989
989
  declare function similarity(str1: string, str2: string): number;
990
990
 
991
- export { type CompareOptions as C, type ExtractOptions as E, type SlugifyOptions as S, type TitleCaseOptions as T, toSentenceCase as a, sanitize as b, capitalize as c, contractAbbreviation as d, expandAbbreviation as e, removeStopwords as f, toFormal as g, truncate as h, isAlay as i, extractWords as j, compareStrings as k, similarity as l, type SanitizeOptions as m, normalizeWhitespace as n, type TruncateOptions as o, profanityFilter as p, removeAccents as r, slugify as s, toTitleCase as t };
991
+ export { type CompareOptions as C, type ExtractOptions as E, type SlugifyOptions as S, type TitleCaseOptions as T, toSentenceCase as a, sanitize as b, capitalize as c, contractAbbreviation as d, expandAbbreviation as e, truncate as f, extractWords as g, removeStopwords as h, toFormal as i, isAlay as j, compareStrings as k, similarity as l, type SanitizeOptions as m, normalizeWhitespace as n, type TruncateOptions as o, profanityFilter as p, removeAccents as r, slugify as s, toTitleCase as t };
package/dist/index.cjs CHANGED
@@ -1181,6 +1181,76 @@ function formatPlate(plate) {
1181
1181
  return `${match[1]} ${match[2]} ${match[3]}`;
1182
1182
  }
1183
1183
 
1184
+ // src/vin/constants.ts
1185
+ var VIN_LENGTH = 17;
1186
+ var VIN_CHECK_DIGIT_INDEX = 8;
1187
+ var VIN_MODULUS = 11;
1188
+ var VIN_CHECK_DIGIT_X = "X";
1189
+ var VIN_WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2];
1190
+ var VIN_CHAR_VALUES = {
1191
+ "0": 0,
1192
+ "1": 1,
1193
+ "2": 2,
1194
+ "3": 3,
1195
+ "4": 4,
1196
+ "5": 5,
1197
+ "6": 6,
1198
+ "7": 7,
1199
+ "8": 8,
1200
+ "9": 9,
1201
+ "A": 1,
1202
+ "B": 2,
1203
+ "C": 3,
1204
+ "D": 4,
1205
+ "E": 5,
1206
+ "F": 6,
1207
+ "G": 7,
1208
+ "H": 8,
1209
+ "J": 1,
1210
+ "K": 2,
1211
+ "L": 3,
1212
+ "M": 4,
1213
+ "N": 5,
1214
+ "P": 7,
1215
+ "R": 9,
1216
+ "S": 2,
1217
+ "T": 3,
1218
+ "U": 4,
1219
+ "V": 5,
1220
+ "W": 6,
1221
+ "X": 7,
1222
+ "Y": 8,
1223
+ "Z": 9
1224
+ };
1225
+ var EXCLUDED_VIN_CHARS = ["I", "O", "Q"];
1226
+
1227
+ // src/vin/validate.ts
1228
+ function validateVIN(vin) {
1229
+ if (!vin || vin.length !== VIN_LENGTH) {
1230
+ return false;
1231
+ }
1232
+ const normalizedVIN = vin.toUpperCase();
1233
+ for (const char of EXCLUDED_VIN_CHARS) {
1234
+ if (normalizedVIN.includes(char)) {
1235
+ return false;
1236
+ }
1237
+ }
1238
+ let sum = 0;
1239
+ for (let i = 0; i < VIN_LENGTH; i++) {
1240
+ const char = normalizedVIN[i];
1241
+ const weight = VIN_WEIGHTS[i];
1242
+ const val = VIN_CHAR_VALUES[char];
1243
+ if (val === void 0) {
1244
+ return false;
1245
+ }
1246
+ sum += val * weight;
1247
+ }
1248
+ const checkDigitValue = sum % VIN_MODULUS;
1249
+ const expectedCheckDigit = checkDigitValue === 10 ? VIN_CHECK_DIGIT_X : checkDigitValue.toString();
1250
+ const actualCheckDigit = normalizedVIN[VIN_CHECK_DIGIT_INDEX];
1251
+ return actualCheckDigit === expectedCheckDigit;
1252
+ }
1253
+
1184
1254
  // src/currency/format.ts
1185
1255
  function formatRupiah(amount, options) {
1186
1256
  const {
@@ -3194,5 +3264,6 @@ exports.validateNIK = validateNIK;
3194
3264
  exports.validateNPWP = validateNPWP;
3195
3265
  exports.validatePhoneNumber = validatePhoneNumber;
3196
3266
  exports.validatePlate = validatePlate;
3267
+ exports.validateVIN = validateVIN;
3197
3268
  //# sourceMappingURL=index.cjs.map
3198
3269
  //# sourceMappingURL=index.cjs.map