
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
A lightweight, type-safe TypeScript utility for building complex objects through method chaining
A lightweight, type-safe TypeScript utility for building complex objects through method chaining with full type inference.
npm install scopey
or
yarn add scopey
import { scope } from "scopey";
const config = scope(3000)
.with((port) => ({ port, host: "localhost" }))
.with(({ port, host }) => ({ url: `http://${host}:${port}` }))
.with(({ port }) => ({ isSecure: port === 443 }))
.value();
console.log(config);
// {
// port: 3000,
// host: 'localhost',
// url: 'http://localhost:3000',
// isSecure: false
// }
scope<T>(value: T)Creates a new scope with an initial value.
const result = scope(42).value(); // 42
const result2 = scope({ name: "John" }).value(); // { name: 'John' }
.with(transformer)Transforms the current value. If both the current value and the transformation result are objects, they are merged. Otherwise, the value is replaced.
// Object merging
scope({ a: 1 })
.with(() => ({ b: 2 }))
.value(); // { a: 1, b: 2 }
// Value replacement
scope("hello")
.with(() => ({ message: "world" }))
.value(); // { message: 'world' }
// Property overwriting
scope({ a: 1, b: 2 })
.with(() => ({ b: 3, c: 4 }))
.value(); // { a: 1, b: 3, c: 4 }
.only(transformer)Replaces the entire value with the transformation result, regardless of types.
scope({ a: 1, b: 2 })
.only(() => ({ c: 3 }))
.value(); // { c: 3 }
scope(10)
.only((x) => x * 2)
.value(); // 20
.value()Returns the final value after all transformations.
const result = scope("hello")
.with((msg) => ({ message: msg }))
.value(); // { message: 'hello' }
Scopey provides full type inference throughout the chain:
const config = scope(3000)
.with((port) => ({ port, host: "localhost" }))
// TypeScript knows the value is now { port: 3000, host: "localhost" }
.with(({ port, host }) => ({ url: `http://${host}:${port}` }))
// TypeScript knows the value is now { port: 3000, host: "localhost,
// url: "http://localhost:3000" }
.value();
// TypeScript error: Property 'invalid' does not exist
// .with(({ invalid }) => ({ ... }))
# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Build the project
npm run build
# Run linting
npm run lint
# Type checking
npm run typecheck
scopey/
├── src/
│ ├── index.ts # Main implementation
│ └── index.test.ts # Test suite
├── dist/ # Compiled output (generated)
├── coverage/ # Test coverage reports (generated)
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions CI configuration
├── package.json
├── tsconfig.json # TypeScript configuration
├── jest.config.js # Jest configuration
└── README.md
The project uses Jest for testing with ts-jest for TypeScript support. Tests are located alongside source files with .test.ts extension.
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Generate coverage report
npm run test:coverage
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)Please make sure to update tests as appropriate and ensure all tests pass before submitting a PR.
MIT
FAQs
A lightweight, type-safe TypeScript utility for building complex objects through method chaining
The npm package scopey receives a total of 0 weekly downloads. As such, scopey popularity was classified as not popular.
We found that scopey demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.