Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add masks field as array of strings #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NivaldoFarias
Copy link
Contributor

I noticed that the mask field's returned value from objects varied between a single string and an array of strings. Since the type definitions declares the field as string only, I added the masks field to return an array of strings and changed the objects that had the mask field return an array to return the first string in the array.

changes:

  • adds masks field to objects;
  • now, the mask field returns a string only;
  • update type declarations with JSDoc;
  • update README.md;

I created a temporary file in the root of the project to execute the script below to change JSON file:

import Bun from "bun";

import countries from "./src/countries.json"; 

const updatedCountries = countries.map((country) => {
  const masks = Array.isArray(country.mask) 
    ? country.mask 
    : [country.mask];

  return {
    ...country,
    masks,
    mask: masks[0],
  };
});

await Bun.write("./src/countries.json", JSON.stringify(updatedCountries));
node 22.9.0, bun 1.1.31

@ChristoPy
Copy link
Owner

Nice addition! It gets a more predictable behavior.

Gonna work this this PR after the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants