You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eff7dec
Browse filesBrowse the repository at this point in the historyBrowse files
docs(bundle): regenerate every size figure from the tree-shaking script
The figures were measured before the datasets were packed. They now come from node
scripts/tree-shaking.ts on the built branch: the size table of the getting started page, the
isValidCpf intro figure, the getCities, isValidCid10 and getCid10 sizes of the utilities reference,
the state and city guides and their snippets. getStates is 2.2 KB, not 2.5 KB.
|`getServiceItem`| Service list of the Lei Complementar 116/2003 | 25.5 KB |8.2 KB |
84
+
|`getIsbnInfo` · `formatIsbn`| ISBN ranges of the International ISBN Agency (RangeMessage) | 15.1 - 15.3 KB |5.4 - 5.5 KB |
85
+
|`isValidCbo`|CBO 2002 occupation codes, without the titles|6.7 KB |1.7 KB |
86
+
|`isValidCid10`|CID-10 V2008 category and subcategory codes plus the SIM `U07` codes, without the descriptions| 6.7 KB |2.4 KB |
87
+
|`isValidCnae`| CNAE-Subclasses 2.3 codes, without the descriptions | 4.6 KB | 1.9 KB |
88
+
|`isValidCest`| CEST codes, without the descriptions | 3.6 KB | 0.8 KB |
89
+
|`isValidNbs`| NBS 2.0 codes, without the descriptions | 3.5 KB | 1.3 KB |
90
90
91
91
The root of the package is a single ESM module, so a bundler cannot split one of these datasets out of it: importing a heavy util from the root puts its whole dataset in your main bundle, and a dynamic `import()` of the root does not help. To lazy-load one, import it from its own subpath:
Copy file name to clipboardExpand all lines: docs/guides/state-city.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ keywords: ["state and city select", "IBGE municipalities", "getMunicipalities",
6
6
7
7
Pick a state and its cities fill the second select. Pick the framework: each example runs the code below it, which you can copy as is.
8
8
9
-
The point of this one is when each table is loaded, and the answer is: when someone opens the select that shows it. Not with the page, and not when a state is picked either. A form where the city is filled in by something else, or left alone, never fetches 148 KB of municipalities. The states are 27 rows, 2.5 KB; the municipalities are 5,571 of them, 148 KB. Each util is its own subpath, so `await import("@brazilian-utils/brazilian-utils/get-municipalities")` fetches that table and nothing else. Each option takes the IBGE `code` of the municipality as its value and the `name` as its label, since names repeat across states (there are two "Pau D'Arco"). A bundler makes it a chunk of its own; the browser fetches it once and keeps it, so only the first opening waits.
9
+
The point of this one is when each table is loaded, and the answer is: when someone opens the select that shows it. Not with the page, and not when a state is picked either. A form where the city is filled in by something else, or left alone, never fetches 76 KB of municipalities. The states are 27 rows, 2.2 KB; the municipalities are 5,571 of them, 76 KB. Each util is its own subpath, so `await import("@brazilian-utils/brazilian-utils/get-municipalities")` fetches that table and nothing else. Each option takes the IBGE `code` of the municipality as its value and the `name` as its label, since names repeat across states (there are two "Pau D'Arco"). A bundler makes it a chunk of its own; the browser fetches it once and keeps it, so only the first opening waits.
Copy file name to clipboardExpand all lines: docs/pt-br/getting-started.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,25 +68,25 @@ Alguns utilitários embutem uma base de dados oficial e pesam muito mais que tod
68
68
69
69
| Utilitário | Base de dados | Minificado | Gzip |
70
70
| --- | --- | --- | --- |
71
-
|`getCid10`| categorias e subcategorias da CID-10 V2008 mais os códigos `U07` do SIM, com as descrições do DATASUS |988,3 KB |123,6 KB |
72
-
|`getMunicipalitiesByAreaCode` · `getAreaCodeByMunicipalityCode`| 5571 municípios do IBGE, com o DDD de cada um (Anatel) |165,0 - 167,8 KB |52,1 - 52,8 KB |
73
-
|`getMunicipalities` · `getMunicipalityByCode` · `getCodeByMunicipalityName` · `getMunicipality`| 5571 municípios do IBGE, com nomes e códigos | 153,6 - 154,2 KB |49,4 - 49,8 KB |
74
-
|`getCities`|nomes dos 5571 municípios do IBGE|153,4 KB |49,2 KB |
75
-
|`getCest`| descrições e segmentos do CEST (Convênio ICMS 142/18) | 111,5 KB |24,0 KB |
76
-
|`getCbo`|títulos das ocupações da CBO 2002 | 107,6 KB |24,7 KB |
|`getNbs`| descrições da NBS 2.0 (Nomenclatura Brasileira de Serviços) | 75,5 KB |11,5 KB |
79
-
|`getCfop`| descrições das operações do CFOP | 66,7 KB |5,2 KB |
71
+
|`getCid10`| categorias e subcategorias da CID-10 V2008 mais os códigos `U07` do SIM, com as descrições do DATASUS |721,5 KB |113,5 KB |
72
+
|`getCest`| descrições e segmentos do CEST (Convênio ICMS 142/18) |102,2 KB |24,0 KB |
73
+
|`getMunicipalitiesByAreaCode` · `getAreaCodeByMunicipalityCode`| 5571 municípios do IBGE, com o DDD de cada um (Anatel) | 23,5 - 90,2 KB |5,6 - 32,9 KB |
74
+
|`getCbo`|títulos das ocupações da CBO 2002|80,6 KB |24,1 KB |
75
+
|`getMunicipalities` · `getMunicipalityByCode` · `getCodeByMunicipalityName` · `getMunicipality`| 5571 municípios do IBGE, com nomes e códigos | 76,0 - 76,9 KB |29,4 - 29,9 KB |
|`getBanks` · `getBankByCode` · `getBankByIspb`| participantes do STR do Banco Central (COMPE + ISPB) |26,2 - 26,5 KB |7,6 - 7,8 KB |
83
+
|`getServiceItem`| lista de serviços da Lei Complementar 116/2003 | 25,5 KB |8,2 KB |
84
+
|`getIsbnInfo` · `formatIsbn`| faixas do ISBN da Agência Internacional do ISBN (RangeMessage) | 15,1 - 15,3 KB|5,4 - 5,5 KB |
85
+
|`isValidCbo`|códigos das ocupações da CBO 2002, sem os títulos | 6,7 KB |1,7 KB |
86
+
|`isValidCid10`| códigos das categorias e subcategorias da CID-10 V2008 mais os códigos `U07` do SIM, sem as descrições| 6,7 KB |2,4 KB |
87
+
|`isValidCnae`| códigos da CNAE-Subclasses 2.3, sem as descrições | 4,6 KB | 1,9 KB |
88
+
|`isValidCest`| códigos do CEST, sem as descrições | 3,6 KB | 0,8 KB |
89
+
|`isValidNbs`| códigos da NBS 2.0, sem as descrições | 3,5 KB | 1,3 KB |
90
90
91
91
A raiz do pacote é um único módulo ESM, então o bundler não consegue separar uma dessas bases de dados dele: importar um utilitário pesado da raiz coloca a base inteira no seu bundle principal, e um `import()` dinâmico da raiz não ajuda. Para carregar sob demanda, importe do subpath próprio:
Copy file name to clipboardExpand all lines: docs/pt-br/guides/state-city.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ keywords: ["select de estado e cidade", "municípios do IBGE", "getMunicipalitie
6
6
7
7
Escolha um estado e as cidades dele preenchem o segundo select. Escolha o framework: cada exemplo roda o código logo abaixo dele, que pode ser copiado do jeito que está.
8
8
9
-
O ponto aqui é quando cada tabela é carregada, e a resposta é: quando alguém abre o select que a mostra. Nem com a página, nem ao escolher um estado. Num formulário em que a cidade vem preenchida de outro lugar, ou é deixada em branco, os 148 KB de municípios nunca são buscados. Os estados são 27 linhas, 2,5 KB; os municípios são 5.571, 148 KB. Cada utilitário é um subpath, então `await import("@brazilian-utils/brazilian-utils/get-municipalities")` busca essa tabela e nada mais. Cada opção usa o `code` IBGE do município como valor e o `name` como rótulo, já que os nomes se repetem entre estados (existem dois "Pau D'Arco"). O bundler transforma isso num chunk separado, e o browser busca uma vez e guarda, então só a primeira abertura espera.
9
+
O ponto aqui é quando cada tabela é carregada, e a resposta é: quando alguém abre o select que a mostra. Nem com a página, nem ao escolher um estado. Num formulário em que a cidade vem preenchida de outro lugar, ou é deixada em branco, os 76 KB de municípios nunca são buscados. Os estados são 27 linhas, 2,2 KB; os municípios são 5.571, 76 KB. Cada utilitário é um subpath, então `await import("@brazilian-utils/brazilian-utils/get-municipalities")` busca essa tabela e nada mais. Cada opção usa o `code` IBGE do município como valor e o `name` como rótulo, já que os nomes se repetem entre estados (existem dois "Pau D'Arco"). O bundler transforma isso num chunk separado, e o browser busca uma vez e guarda, então só a primeira abertura espera.
Copy file name to clipboardExpand all lines: docs/pt-br/utilities.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2007,7 +2007,7 @@ Retorna os nomes das cidades brasileiras: todas as cidades, ou só as de um esta
2007
2007
- Ordenadas no locale "pt-BR".
2008
2008
- Qualquer `state` falsy pede a lista completa, enquanto `getMunicipalities` retorna `[]`.
2009
2009
- `state` ignora maiúsculas/minúsculas e espaços nas pontas: `'sp'` retorna as cidades de São Paulo, como `'SP'` (até a 2.4.0 retornava `[]`).
2010
-
- Embute os 5571 nomes (~153,4 KB minificado, ~49,2 KB com gzip). Veja [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle) para carregá-la sob demanda via `@brazilian-utils/brazilian-utils/get-cities`.
2010
+
- Embute os 5571 nomes (~64,2 KB minificado, ~26,4 KB com gzip). Veja [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle) para carregá-la sob demanda via `@brazilian-utils/brazilian-utils/get-cities`.
@@ -3641,7 +3641,7 @@ Valida um código CID-10 contra as tabelas que o DATASUS publica, a edição bra
3641
3641
- Os dois níveis da classificação são válidos: as categorias de 3 caracteres (`A00`) e as subcategorias de 4 caracteres, escritas com o ponto (`A00.0`) ou sem ele (`A000`).
3642
3642
- Maiúsculas, minúsculas e espaços em volta são ignorados. Qualquer outra coisa (outro separador, um quinto caractere, um sufixo de cruz ou asterisco, um valor que não é string) é rejeitada.
3643
3643
- As tabelas são as V2008 do DATASUS, mais a categoria `U07` da tabela da CID-10 que o DATASUS mantém para o SIM (`U07`, `U07.0`, `U07.1` COVID-19 com vírus identificado e `U07.2` vírus não identificado), que as V2008 não têm. Um código que não está em nenhuma delas não é encontrado, como `U09.9` (condição pós-COVID-19) e `U10.9` (síndrome inflamatória multissistêmica associada à COVID-19). Até a 2.4.0 os códigos `U07` também não eram encontrados.
3644
-
- Só uma tabela de códigos é lida (cerca de 26 KB minificada), não as descrições que `getCid10` carrega.
3644
+
- Só uma tabela de códigos é lida (cerca de 7 KB minificada), não as descrições que `getCid10` carrega.
@@ -3691,7 +3691,7 @@ Busca um código CID-10 e retorna a sua descrição oficial em português. O res
3691
3691
3692
3692
- Mesmas regras de entrada de `isValidCid10`. O `code` vem em maiúsculas e sem o ponto. Retorna `null` quando o código é desconhecido ou o valor não está em uma forma documentada.
3693
3693
- Mesma tabela de `isValidCid10`: a V2008 do DATASUS mais os códigos `U07` da tabela do SIM (`getCid10('U07.1')` é `{ code:'U071', description:'Infecção pelo novo Coronavírus (COVID-19)' }`); `U09.9` e `U10.9` não são encontrados.
3694
-
- Este é o utilitário mais pesado do pacote: ele embute as 2046 categorias e 12191 subcategorias com suas descrições, cerca de 990 KB minificado (124 KB com gzip). Carregue-o sob demanda pelo seu subpath, como mostrado em [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle), e use `isValidCid10` quando a descrição não for necessária.
3694
+
- Este é o utilitário mais pesado do pacote: ele embute as 2046 categorias e 12191 subcategorias com suas descrições, cerca de 722 KB minificado (113 KB com gzip). Carregue-o sob demanda pelo seu subpath, como mostrado em [Tamanho do bundle](pt-br/getting-started.md#tamanho-do-bundle), e use `isValidCid10` quando a descrição não for necessária.
0 commit comments