# `NPM.TypeField`
[🔗](https://github.com/elixir-volt/npm_ex/blob/v0.7.4/lib/npm/type_field.ex#L1)

Analyzes the `type` field from package.json.

The `type` field determines whether `.js` files are treated as
ES modules (`"module"`) or CommonJS (`"commonjs"`, the default).

# `cjs?`

```elixir
@spec cjs?(map()) :: boolean()
```

Checks if the package uses CommonJS.

# `dual?`

```elixir
@spec dual?(map()) :: boolean()
```

Checks if a package is a dual CJS/ESM package.

# `esm?`

```elixir
@spec esm?(map()) :: boolean()
```

Checks if the package uses ES modules.

# `get`

```elixir
@spec get(map()) :: String.t()
```

Returns the type field value (default: "commonjs").

# `module_type`

```elixir
@spec module_type(String.t(), map()) :: :esm | :cjs
```

Determines the module system for a given file path.

# `stats`

```elixir
@spec stats([map()]) :: map()
```

Returns the counts of ESM vs CJS packages.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
