All 42 tests passed successfully!
Test Suites: 3 passed, 3 total
Tests: 42 passed, 42 total
Time: 7.917 s
Number-Processor/
βββ src/
β βββ common/ β
Created
β β βββ interfaces/ # All TypeScript interfaces
β β βββ functions/ # Pure utility functions
β β β βββ constants.ts
β β β βββ phone.functions.ts
β β β βββ data.functions.ts
β β βββ helpers/ # Helper classes
β β βββ logger.helper.ts
β β βββ error.helper.ts
β β βββ file.helper.ts
β β βββ validation.helper.ts
β βββ core/ β
Created
β β βββ Numsy.ts # Main class
β β βββ Parser.ts # File parser
β β βββPhoneValidator.ts # Phone validator
β β βββ FileProcessor.ts # File processor
β βββ index.ts β
Created (Package entry)
β βββ server.ts β
Created (Server entry)
β βββ main.ts β
Preserved (NestJS entry)
β βββ app.module.ts β
Preserved
β βββ controllers/ β
Preserved
β βββ services/ β
Preserved
βββ test/ β
Created
β βββ phone-validator.spec.ts
β βββ parser.spec.ts
β βββ numsy.spec.ts
βββ dist/ β
Built successfully
βββ docs/ β
Enhanced
β βββ USAGE_EXAMPLES.md
β βββ API_DOCUMENTATION.md
β βββ ... (existing docs)
βββ .swcrc β
Created
βββ nodemon.json β
Created
βββ .npmignore β
Created
βββ package.json β
Updated
βββ tsconfig.json β
Updated
βββ README_NEW.md β
Created
βββ REFACTORING_SUMMARY.md β
Created
import Numsy from 'numsy';
const numsy = new Numsy();
const result = numsy.validate('9876543210');
import { Numsy, Parser, PhoneValidator } from 'numsy';
const numsy = new Numsy();
const parser = new Parser();
const validator = new PhoneValidator();
import parser from 'numsy/parser';
const parser = new Parser();
import {
sanitizePhoneNumber,
validatePhoneNumber,
extractPhoneNumbers,
normalizeDataRows
} from 'numsy';
// Validate phone number
const numsy = new Numsy();
console.log(numsy.isValid('9876543210')); // true
// Sanitize and format
const clean = numsy.sanitize('+91-987-654-3210'); // '9876543210'
const formatted = numsy.format('9876543210', true); // '+919876543210'
// Extract multiple numbers
const text = 'Call 9876543210 or 8123456789';
const result = numsy.extractMultiple(text);
console.log(result.validNumbers); // ['9876543210', '8123456789']
// Parse and process files
const parseResult = await numsy.parseFile('./contacts.csv');
const processResult = await numsy.processFile('./contacts.csv', './output');
Continue developing:
pnpm run dev # Auto-reload development
pnpm run dev:server # Server with auto-reload
Build and test:
pnpm run build # Build with SWC (fast!)
pnpm test # Run all tests
pnpm test:cov # Coverage report
Check for errors:
pnpm run lint # Lint code
pnpm run format # Format code
Test locally first:
# In this project
pnpm run build
npm link
# In another project
npm link numsy
# Test it out
import Numsy from 'numsy';
package.jsonREADME_NEW.md (rename to README.md when ready)Publish to npm:
# Login to npm (first time only)
npm login
# Publish (prepublish script will run tests and build)
npm publish
# Or if package name is scoped
npm publish --access public
AppError classLoggerHelper classcommon/ folder: interfaces, functions, helperscore/ folder: main classesnumsy/parser)package.json configuration.npmignore to exclude dev files| Old API | New API |
|---|---|
import { FileProcessorService } from '@shreesharma07/number-processor' |
import Numsy from 'numsy' |
new FileProcessorService() |
new Numsy() |
| Service-based | Class-based |
@shreesharma07/number-processor |
numsy |
Before:
import { PhoneValidatorService } from '@shreesharma07/number-processor';
const validator = new PhoneValidatorService();
const result = validator.validatePhoneNumber('9876543210');
After:
import Numsy from 'numsy';
const numsy = new Numsy();
const result = numsy.validate('9876543210');
docs/ folder preservedpnpm run dev # Development mode (nodemon)
pnpm run dev:server # Server development mode
pnpm run start:dev # NestJS development mode
pnpm run build # Build with SWC + TypeScript
pnpm run build:nest # Build with Nest CLI
pnpm run prebuild # Clean dist folder
pnpm test # Run all tests
pnpm test:watch # Watch mode
pnpm test:cov # Coverage report
pnpm test:e2e # End-to-end tests
pnpm run lint # Lint code
pnpm run format # Format code with Prettier
pnpm run start # Start server
pnpm run start:dev # Development with watch
pnpm run start:debug # Debug mode
pnpm run start:prod # Production mode
Use as a library in other projects:
import Numsy from 'numsy';
const numsy = new Numsy();
Run as a web application:
pnpm run start:dev
# Visit http://localhost:3000
Both modes work independently!
When you run npm publish, only these files are included:
numsy@1.0.0
βββ dist/ # Compiled JavaScript + Types
β βββ common/
β βββ core/
β βββ index.js
β βββ index.d.ts
β βββ ...
βββ public/ # Static files (if needed)
βββ README.md
βββ LICENSE
src/)test/)docs/)import numsy from 'numsy')pnpm run start:devpnpm run dev for auto-reloadYour package is:
npm publishpnpm run devpnpm run start:devnpm linkCongratulations! π
You now have a professional, production-ready npm package with:
Package Name: numsy
Version: 1.0.0
Author: Shri Kumar Sharma
License: MIT
Happy coding! π