is-even-is-odd
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

is-even-is-odd

is-even-is-odd is a lightweight utility package written in TypeScript to determine if a number is even or odd. It is designed to be simple, fast, and compatible with various JavaScript frameworks.

Table of Contents

Installation

You can install is-even-is-odd via npm or Yarn.

Using npm

npm install is-even-is-odd

Using Yarn

```bash
yarn add is-even-is-odd

## Usage

### JavaScript

```javascript
const { isEven, isOdd } = require('is-even-is-odd');

console.log(isEven(2)); // true
console.log(isOdd(2)); // false

TypeScript

import { isEven, isOdd } from 'is-even-is-odd';

console.log(isEven(2)); // true
console.log(isOdd(2)); // false

API Reference

isEven(num: number): boolean

Determines if a number is even.

  • num - The number to check.

Returns true if the number is even, false otherwise.

isOdd(num: number): boolean

Determines if a number is odd.

  • num - The number to check.

Returns true if the number is odd, false otherwise.

Framework Integrations

React

import React from 'react';
import { isEven, isOdd } from 'is-even-is-odd';

const App = () => {
  console.log(isEven(2)); // true
  console.log(isOdd(2)); // false

  return <div>Hello, world!</div>;
};

export default App;

Vue.js

<template>
  <div>
    {{ isEven(2) }} <!-- true -->
    {{ isOdd(2) }} <!-- false -->
  </div>
</template>

<script>
import { isEven, isOdd } from 'is-even-is-odd';

export default {
  methods: {
    isEven,
    isOdd,
  },
};
</script>

Angular

import { Component } from '@angular/core';
import { isEven, isOdd } from 'is-even-is-odd';

@Component({
  selector: 'app-root',
  template: `
    <div>
      {{ isEven(2) }} <!-- true -->
      {{ isOdd(2) }} <!-- false -->
    </div>
  `,
})
export class AppComponent {
  isEven = isEven;
  isOdd = isOdd;
}

Svelte

<script>
  import { isEven, isOdd } from 'is-even-is-odd';

  console.log(isEven(2)); // true
  console.log(isOdd(2)); // false
</script>

<div>
  Hello, world!
</div>

Advanced Usage

Node.js

import { isEven, isOdd } from 'is-even-is-odd';

console.log(isEven(2)); // true
console.log(isOdd(2)); // false

Browser

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>is-even-is-odd</title>
</head>
<body>
  <script type="module">
    import { isEven, isOdd } from 'https://cdn.skypack.dev/is-even-is-odd';

    console.log(isEven(2)); // true
    console.log(isOdd(2)); // false
  </script>
</body>
</html>

Contribution Guide

Please read the Contribution Guide to learn how you can contribute to this project.

License

This project is licensed under the MIT License.

FAQ

Why should I use is-even-is-odd?

is-even-is-odd is a simple, fast, and lightweight utility package that allows you to determine if a number is even or odd. It is compatible with various JavaScript frameworks and can be used in both Node.js and the browser.

How can I report a bug or request a feature?

Please open an issue on the [GitHub repository](


# Output: README.md
# is-even-is-odd

**is-even-is-odd** is a lightweight utility package written in TypeScript to determine if a number is even or odd. It is designed to be simple, fast, and compatible with various JavaScript frameworks.

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
  - [JavaScript](#javascript)
  - [TypeScript](#typescript)
- [API Reference](#api-reference)
  - [isEven](#isevennum-number-boolean)
  - [isOdd](#isoddnum-number-boolean)
- [Framework Integrations](#framework-integrations)
  - [React](#react)
  - [Vue.js](#vuejs)
  - [Angular](#angular)
  - [Svelte](#svelte)
- [Advanced Usage](#advanced-usage)
  - [Node.js](#nodejs)
  - [Browser](#browser)
- [Contribution Guide](#contribution-guide)
- [License](#license)
- [FAQ](#faq)

Readme

Keywords

Package Sidebar

Install

npm i is-even-is-odd

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

19.1 kB

Total Files

8

Last publish

Collaborators

  • anosirjonov