{"_id":"@apexo/type","_rev":"6-71e8d1a164531abb5188b5149ceec7d7","name":"@apexo/type","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@apexo/type","version":"0.0.1","keywords":["types","typescript","javascript","validation","schema","runtime","type-inference","data-validation","data-contract","static-types","run-time","data-structure","forms","api","browser","server","backend","validation-library"],"author":{"name":"Lakshay Singh"},"license":"ISC","_id":"@apexo/type@0.0.1","maintainers":[{"name":"bytetologic","email":"bytetologic@gmail.com"}],"homepage":"https://github.com/bytetologic/apexo.js/tree/main#readme","bugs":{"url":"https://github.com/bytetologic/apexo.js/issues"},"dist":{"shasum":"cd6d55dd3c20c3fdf750d502875fa0be8c7a3b4d","tarball":"https://registry.npmjs.org/@apexo/type/-/type-0.0.1.tgz","fileCount":6,"integrity":"sha512-Kl2dwl9Ycj4c8iap0VoiUn9F/mnmxHyPiDBNcOkUJctVHN2iJCP+CQBqcggkNU+QkzXy2P0KCZLZfnrtp2jNXg==","signatures":[{"sig":"MEYCIQCRpBTC7uoOStOsKxSonaEyVNGmxDUXzzcalZtgpNTBtgIhAI8BLO8SjIsTCxdaMYw2/qWKqT7/il4B6IJDGCJ1m9Pv","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53110},"main":"dist/index.js","_from":"file:apexo-type-0.0.1.tgz","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"test":"jest","build":"tsup src/index.ts --format cjs,esm --dts --minify","release":"pnpm publish --access public"},"_npmUser":{"name":"bytetologic","email":"bytetologic@gmail.com"},"_resolved":"/private/var/folders/f2/234rfrqs0b51d3yfgg91sndc0000gn/T/2a3bed5e65996e5c5dbb529d1698e7b8/apexo-type-0.0.1.tgz","_integrity":"sha512-Kl2dwl9Ycj4c8iap0VoiUn9F/mnmxHyPiDBNcOkUJctVHN2iJCP+CQBqcggkNU+QkzXy2P0KCZLZfnrtp2jNXg==","repository":{"url":"git+https://github.com/bytetologic/apexo.js.git#main","type":"git"},"_npmVersion":"10.9.3","description":"@apexo/type is a small, zero-dependency library that gives you easy and reliable type checks in JavaScript and TypeScript.","directories":{},"sideEffects":false,"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^30.2.0","tsup":"^8.5.1","ts-jest":"^29.4.5","typescript":"^5.9.3","@types/jest":"^30.0.0","@types/node":"^24.10.1"},"_npmOperationalInternal":{"tmp":"tmp/type_0.0.1_1764437125248_0.3463613201455089","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@apexo/type","version":"0.0.3","description":"@apexo/type is a small, zero-dependency library that gives you easy and reliable type checks in JavaScript and TypeScript.","main":"dist/index.js","module":"dist/index.mjs","sideEffects":false,"types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"keywords":["types","typescript","javascript","validation","schema","runtime","type-inference","data-validation","data-contract","static-types","run-time","data-structure","forms","api","browser","server","backend","validation-library"],"author":{"name":"Lakshay Singh"},"license":"MIT","devDependencies":{"@types/jest":"^30.0.0","@types/node":"^24.10.1","jest":"^30.2.0","ts-jest":"^29.4.5","tsup":"^8.5.1","typescript":"^5.9.3"},"repository":{"type":"git","url":"git+https://github.com/bytetologic/apexo.js.git#main"},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --minify","test":"jest","release":"pnpm publish --access public"},"_id":"@apexo/type@0.0.3","bugs":{"url":"https://github.com/bytetologic/apexo.js/issues"},"homepage":"https://github.com/bytetologic/apexo.js/tree/main#readme","_integrity":"sha512-/xK0BaGryyCMfW3ZGTGKFctr4GqSdxLaQMdBilZJeRTLtmtu5VcF/my7sSK5F3gKYzhuQo8Z9B+m0QIsOcATfg==","_resolved":"/private/var/folders/f2/234rfrqs0b51d3yfgg91sndc0000gn/T/c155f495b1dbf162e45328aa71b8a72d/apexo-type-0.0.3.tgz","_from":"file:apexo-type-0.0.3.tgz","_nodeVersion":"22.20.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-/xK0BaGryyCMfW3ZGTGKFctr4GqSdxLaQMdBilZJeRTLtmtu5VcF/my7sSK5F3gKYzhuQo8Z9B+m0QIsOcATfg==","shasum":"71532432c92eac4937214c87679f5b00ea49b634","tarball":"https://registry.npmjs.org/@apexo/type/-/type-0.0.3.tgz","fileCount":7,"unpackedSize":53686,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCmlkmHocT8coBfphnQ/8kdOvpCjCBtzFBhhZqytOBNrQIhAOfIGFetNhfDV0b+popT11hwRMzJMoYGUhVXU9l62y/T"}]},"_npmUser":{"name":"bytetologic","email":"bytetologic@gmail.com"},"directories":{},"maintainers":[{"name":"bytetologic","email":"bytetologic@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/type_0.0.3_1764476714613_0.27328693860951847"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-29T17:25:25.137Z","modified":"2025-11-30T04:25:15.028Z","0.0.2":"2025-11-26T15:23:02.721Z","0.0.1":"2025-11-29T17:25:25.460Z","0.0.3":"2025-11-30T04:25:14.804Z"},"bugs":{"url":"https://github.com/bytetologic/apexo.js/issues"},"author":{"name":"Lakshay Singh"},"license":"MIT","homepage":"https://github.com/bytetologic/apexo.js/tree/main#readme","keywords":["types","typescript","javascript","validation","schema","runtime","type-inference","data-validation","data-contract","static-types","run-time","data-structure","forms","api","browser","server","backend","validation-library"],"repository":{"type":"git","url":"git+https://github.com/bytetologic/apexo.js.git#main"},"description":"@apexo/type is a small, zero-dependency library that gives you easy and reliable type checks in JavaScript and TypeScript.","maintainers":[{"name":"bytetologic","email":"bytetologic@gmail.com"}],"readme":"# @apexo/type\n\nEver spent hours writing validation code, only to realize you're doing the same thing in every function? Or maybe you've let AI generate it for you, and now your bundle is bloated with duplicate boilerplate?\n\n**@apexo/type** is a small library that does all your type checking for you. Why do you need it? Because JavaScript's type checking is weird:\n\n- `typeof null` says it's an `\"object\"` (but it's not!)\n- `typeof []` says it's an `\"object\"` (arrays need different checks)\n- `typeof NaN` says it's a `\"number\"` (even though NaN means \"Not a Number\")\n- No easy way to check for empty values or loops in objects\n\nYou could write all the checks yourself:\n\n```javascript\nfunction processUser(data) {\n    if (data === null || data === undefined) {\n        throw new Error('Data is required');\n    }\n    if (typeof data !== 'object' || Array.isArray(data)) {\n        throw new Error('Data must be an object');\n    }\n    if (typeof data.name !== 'string' || data.name.trim() === '') {\n        throw new Error('Name must be a non-empty string');\n    }\n    if (typeof data.age !== 'number' || isNaN(data.age) || data.age < 0) {\n        throw new Error('Age must be a positive number');\n    }\n    // Finally, your actual logic...\n}\n```\n\nOr you could use **@apexo/type** and get it done in 3 lines:\n\n```javascript\nimport { isObject, isNotEmpty, isPositive } from '@apexo/type';\n\nfunction processUser(data) {\n    if (!isObject(data)) throw new Error('Data must be an object');\n    if (!isNotEmpty(data.name)) throw new Error('Name is required');\n    if (!isPositive(data.age)) throw new Error('Age must be positive');\n    // Your actual logic, front and center\n}\n```\n\n## Why would I want that?\n\nJavaScript's `typeof` operator falls short in many real-world scenarios:\n- `typeof null === 'object'` (it's not!)\n- `typeof [] === 'object'` (arrays need special handling)\n- No way to check for `NaN`, empty values, or validate complex structures\n\n**@apexo/type** solves these problems by providing:\n\n- **Runtime Safety**: Validate data from APIs, user input, or any untrusted source before processing\n- **TypeScript Integration**: Type guards automatically narrow types in your code, giving you full IntelliSense support\n- **Readable Code**: Replace verbose checks like `if (value !== null && value !== undefined && typeof value === 'string' && value.trim() !== '')` with `if (isNotEmpty(value))`\n- **Edge Case Handling**: Correctly handles tricky JavaScript edge cases (`null`, `undefined`, `NaN`, `Symbol`, `BigInt`, circular references)\n\n## How little is it?\n\n- **~12KB minified** (entire library)\n- **Tree-shakeable**: Only bundle what you use. Import just `isString`? Your bundle won't include date validators or circular reference detection\n- **Zero dependencies**: No bloat from external packages\n- **Side-effect free**: Marked as `\"sideEffects\": false` for optimal tree-shaking\n\n## How do I install it?\n\n```bash\nnpm install @apexo/type\n```\n\nOr with your preferred package manager:\n\n```bash\npnpm add @apexo/type\nyarn add @apexo/type\n```\n\n## How do I use it?\n\n### Basic Type Guards\n\nType guards return a boolean and automatically narrow TypeScript types:\n\n```typescript\nimport { isString, isNumber, isArray } from '@apexo/type';\n\nfunction process(input: unknown) {\n    if (isString(input)) {\n        // TypeScript knows input is string here\n        console.log(input.toUpperCase());\n    }\n    \n    if (isArray(input)) {\n        // TypeScript knows input is any[] here\n        console.log(input.length);\n    }\n}\n```\n\n### Validating Values\n\nBeyond type checking, validate specific properties:\n\n```typescript\nimport { isPositive, isEven, isFutureDate, isEmpty } from '@apexo/type';\n\nisPositive(10);  // true\nisEven(7);       // false\nisEmpty('   ');  // true\nisFutureDate(new Date('2050-01-01')); // true\n```\n\n### Advanced Utilities\n\n```typescript\nimport { whatTypeOf, hasCircularReference } from '@apexo/type';\n\nwhatTypeOf(null);        // \"null\" (not \"object\"!)\nwhatTypeOf([]);          // \"array\"\nwhatTypeOf(new Date());  // \"date\"\n\nconst obj: any = {};\nobj.self = obj;\nhasCircularReference(obj); // { hasCircular: true, path: \"root.self -> root\" }\n```\n\n## Loading the library\n\n### ES Modules (Recommended)\n\n```typescript\nimport { isString, isObject } from '@apexo/type';\n```\n\n### CommonJS\n\n```javascript\nconst { isString, isObject } = require('@apexo/type');\n```\n\n### TypeScript\n\nThe library is written in TypeScript and includes full type definitions out of the box.\n\n## Are there TypeScript definitions?\n\nYes! The library is **TypeScript-first** and includes complete type definitions. All type guards use TypeScript's type predicate syntax (`value is Type`), providing automatic type narrowing:\n\n```typescript\nfunction example(input: unknown) {\n    if (isString(input)) {\n        // input is automatically typed as 'string'\n        input.toLowerCase(); // ✅ TypeScript knows this is safe\n    }\n}\n```\n\n## Where can I use it?\n\n**Everywhere JavaScript runs:**\n\n- ✅ **Node.js** (v14+)\n- ✅ **Browsers** (Modern browsers, IE11+ with polyfills)\n- ✅ **Deno**\n- ✅ **Bun**\n- ✅ **Edge Functions** (Vercel, Cloudflare Workers, etc.)\n- ✅ **React Native**\n\nThe library has zero dependencies and uses only standard JavaScript features, making it universally compatible.\n\n---\n\n## API Reference\n\n### Primitives\n\n- `isString(value)` - Checks if value is a string\n- `isNumber(value)` - Checks if value is a number (and not NaN)\n- `isNumberStr(value)` - Checks if value is a number or numeric string\n- `isBoolean(value)` - Checks if value is a boolean\n- `isNil(value)` - Checks if value is `null` or `undefined`\n- `isNull(value)` - Checks if value is `null`\n- `isUndefined(value)` - Checks if value is `undefined`\n- `isBigInt(value)` - Checks if value is a BigInt\n- `isSymbol(value)` - Checks if value is a Symbol\n- `isPrimitive(value)` - Checks if value is a primitive type\n\n### Objects & Structures\n\n- `isObject(value)` - Checks if value is a non-null object (excluding arrays)\n- `isPlainObject(value)` - Checks if value is a plain object (`{}` or `new Object()`)\n- `isArray(value)` - Checks if value is an array\n- `isArrayLike(value)` - Checks if value is array-like (has length property)\n- `isFunction(value)` - Checks if value is a function\n- `isClass(value)` - Checks if value is a class constructor\n- `isIterable(value)` - Checks if value is iterable\n- `isAsyncIterable(value)` - Checks if value is async iterable\n- `isGeneratorFunction(value)` - Checks if value is a generator function\n- `isWindow(value)` - Checks if value is a Window object\n\n### Advanced Types\n\n- `isPromise(value)` - Checks if value is a Promise\n- `isMap(value)` - Checks if value is a Map\n- `isSet(value)` - Checks if value is a Set\n- `isWeakMap(value)` - Checks if value is a WeakMap\n- `isWeakSet(value)` - Checks if value is a WeakSet\n- `isRegExp(value)` - Checks if value is a RegExp\n- `isDate(value)` - Checks if value is a Date object\n- `isError(value)` - Checks if value is an Error\n- `isTypeError(value)` - Checks if value is a TypeError\n- `isReferenceError(value)` - Checks if value is a ReferenceError\n- `isSyntaxError(value)` - Checks if value is a SyntaxError\n- `isRangeError(value)` - Checks if value is a RangeError\n- `isURIError(value)` - Checks if value is a URIError\n- `isEvalError(value)` - Checks if value is an EvalError\n- `isAggregateError(value)` - Checks if value is an AggregateError\n- `isBuffer(value)` - Checks if value is a Buffer (Node.js) or ArrayBuffer/View\n- `isJson(value)` - Checks if value is a valid JSON string\n\n### Empty Checks\n\n- `isEmpty(value)` - Checks if value is empty (null, undefined, empty string/array/object)\n- `isNotEmpty(value)` - Inverse of `isEmpty`\n- `isEmptyStr(value)` - Checks if value is an empty string (or whitespace only)\n- `isEmptyArr(value)` - Checks if value is an empty array\n- `isEmptyObj(value)` - Checks if value is an empty object\n\n### Number Validators\n\n- `isFiniteNumber(value)` - Checks if value is a finite number\n- `isInteger(value)` - Checks if value is an integer\n- `isFloat(value)` - Checks if value is a float\n- `isSafeInteger(value)` - Checks if value is a safe integer\n- `isPositive(value)` - Checks if value is > 0\n- `isNegative(value)` - Checks if value is < 0\n- `isZero(value)` - Checks if value is 0\n- `isEven(value)` - Checks if value is even\n- `isOdd(value)` - Checks if value is odd\n- `isPrime(value)` - Checks if value is a prime number\n- `isInRange(value, min, max)` - Checks if value is within [min, max]\n- `isBetween(value, min, max)` - Checks if value is strictly between (min, max)\n\n### Date Validators\n\n- `isValidDate(value)` - Checks if value is a valid Date (not Invalid Date)\n- `isStrictDate(value)` - Alias for `isValidDate`\n- `isFutureDate(date)` - Checks if date is in the future\n- `isPastDate(date)` - Checks if date is in the past\n- `isToday(date)` - Checks if date is today\n- `isSameDay(a, b)` - Checks if two dates are on the same day\n- `isLeapYear(year)` - Checks if year is a leap year\n- `isISODateString(value)` - Checks if value is an ISO 8601 date string\n- `isValidISODateOnly(value)` - Checks if value is a valid YYYY-MM-DD string\n- `isValidTimeString(value)` - Checks if value is a valid time string (HH:mm)\n- `isDateTimeString(value)` - Checks if value is a valid datetime string\n- `isTimestamp(value)` - Checks if value is a valid timestamp\n- `isDateLike(value)` - Checks if value can be converted to a valid Date\n- `isForwardTime(date, offset?)` - Checks if date is after now + offset\n- `isBackwardTime(date, offset?)` - Checks if date is before now - offset\n\n### Utilities\n\n- `whatTypeOf(value)` - Returns a specific type string (e.g., \"array\", \"date\", \"null\")\n- `hasCircularReference(obj)` - Detects circular references in objects/arrays\n\n---\n\n## Architecture\n\nThe library is organized for maximum tree-shaking efficiency:\n\n```\nsrc/\n├── guards/          # Type guards (value is Type)\n│   ├── primitives.ts   # Basic types\n│   ├── objects.ts      # Object structures\n│   ├── advanced.ts     # Promises, Maps, Sets\n│   ├── errors.ts       # Error types\n│   └── empty.ts        # Empty checks\n├── validators/      # Value validators (boolean)\n│   ├── number.ts       # Numeric validations\n│   └── date.ts         # Date validations\n└── utils/           # Helper utilities\n    ├── type-of.ts      # Enhanced typeof\n    └── circular-ref.ts # Circular reference detection\n```\n\nThis structure allows bundlers to eliminate entire categories of checks if you don't use them.\n\n---\n\n## License\n\n[MIT](https://github.com/bytetologic/apexo.js?tab=MIT-1-ov-file)\n\n## Repository\n\n[https://github.com/bytetologic/apexo.js/tree/main/packages/type](https://github.com/bytetologic/apexo.js/tree/main/packages/type)\n","readmeFilename":"README.md"}