Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@
"LICENSE"
],
"main": "./dist/cjs/index.cjs",
"types": "./dist/esm/index.d.ts",
"types": "./dist/index.d.ts",
"module": "./dist/esm/index.js",
"exports": {
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"types": "./dist/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/esm/index.d.ts",
"types": "./dist/index.d.ts",
"default": "./dist/cjs/index.cjs"
}
},
"./promises": {
"import": {
"types": "./dist/esm/promises.d.ts",
"types": "./dist/promises.d.ts",
"default": "./dist/esm/promises.js"
},
"require": {
"types": "./dist/esm/promises.d.ts",
"types": "./dist/promises.d.ts",
"default": "./dist/cjs/promises.cjs"
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ export {}
const indexfile = await import('./index')

describe('indexfile', () => {
it('should export `setInterval(…)` function', () => {
expect(indexfile).toHaveProperty('setInterval', expect.any(Function))
})

it('should export `setRecursive(…)` function', () => {
expect(indexfile).toHaveProperty('setRecursive', expect.any(Function))
})

it('should export the same function under the aliases `setInterval` and `setRecursive`', () => {
it('should export `setRecursive(…)` under the alias `setInterval(…)`', () => {
expect(indexfile.setInterval === indexfile.setRecursive).toBe(true)
})

it('should export `clearRecursive(…)` function', () => {
expect(indexfile).toHaveProperty('clearRecursive', expect.any(Function))
})

it('should export `clearRecursive(…)` under the alias `clearInterval(…)`', () => {
expect(indexfile.clearInterval === indexfile.clearRecursive).toBe(true)
})

it('should export `promises` namespace', () => {
expect(indexfile).toHaveProperty('promises', expect.any(Object))
})
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ export {
createRecursiveTimeout as setRecursive,
createRecursiveTimeout as setInterval, // alias (allows drop-in replacement)
} from './with-callback/create-recursive-timeout'

export {
clearRecursiveTimeout as clearRecursive,
clearRecursiveTimeout as clearInterval, // alias (allows drop-in replacement)
} from './with-callback/clear-recursive-timeout'
14 changes: 9 additions & 5 deletions src/promises.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ export {}
const promises = await import('./promises')

describe('indexfile', () => {
it('should export `setInterval(…)` function', () => {
expect(promises).toHaveProperty('setInterval', expect.any(Function))
})

it('should export `setRecursive(…)` function', () => {
expect(promises).toHaveProperty('setRecursive', expect.any(Function))
})

it('should export the same function under the aliases `setInterval` and `setRecursive`', () => {
it('should export `setRecursive(…)` under the alias `setInterval(…)`', () => {
expect(promises.setInterval === promises.setRecursive).toBe(true)
})

it('should export `clearRecursive(…)` function', () => {
expect(promises).toHaveProperty('clearRecursive', expect.any(Function))
})

it('should export `clearRecursive(…)` under the alias `clearInterval(…)`', () => {
expect(promises.clearInterval === promises.clearRecursive).toBe(true)
})
})
5 changes: 5 additions & 0 deletions src/promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ export {
createRecursiveTimeout as setRecursive,
createRecursiveTimeout as setInterval, // alias (allows drop-in replacement)
} from './with-promises/create-recursive-timeout'

export {
clearRecursiveTimeout as clearRecursive,
clearRecursiveTimeout as clearInterval, // alias (allows drop-in replacement)
} from './with-promises/clear-recursive-timeout'
2 changes: 0 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export default defineConfig({
promises: resolve('src/promises.ts'),
},
fileName(format, entryName) {
console.log({ format, entryName })

if (format === 'es') {
return `esm/${entryName}.js`
}
Expand Down