Releases: poppinss/utils
Fix typo in InvalidArgumentsException class name
- fix: typo in InvalidArgumentsException class name 83cf216
Publish v6.2.0 under preview tag
v6.3.0-0 chore(release): 6.3.0-0
Add InvalidArgumentException class
Add createError helper
Add RuntimeException class
Export NormalizeConstructor and Constructor types
- test: fix missing types issue within tests 2fab8ab
- feat: export NormalizeConstructor and Constructor types 60b4333
Full Changelog: v6.0.0-3...v6.0.1-0
Improvements to the types of the ObjectBuilder
- refactor: object builder to build the final type for the object c672620
- chore: update dependencies fff3b25
- ci: use reusable workflow e3a99e5
- chore: update dependencies 2c005a2
Full Changelog: v6.0.0-2...v6.0.0-3
Make tsconfig strict and add coverage
Ergonomic improvements to default export and a method rename
- Rename
string.toSentence
tostring.sentence
. Because, we do not useto
prefix on any other helper, so let's have a uniform API. - In order for TypeScript LSP to suggest auto imports for
export default
, it needs the export to have a name. So we have given names to tostring
andjson
sub-modules default exports. You can learn more about the TypeScript LSP here microsoft/TypeScript#19877
Commits
Rewrite and ESM only
From the release title itself you can expect this package to have a lot of breaking changes. First in the form of being ESM only and another is in the form of restructuring, removing and refactoring existing helpers.
- A lot of helpers are not needed anymore (they were for CJS mainly), some have been removed in favor of other utility packages.
- Also, since we are now using Node sub-path exports, the external API for importing some of the sub-modules has been changed. Please refer to the README file to learn more about it.
Breaking changes
-
Remove
esmRequire
andesmResolver
helper methods. It is not required since we are on native ES modules. -
The
defineStaticProperty
property method arguments API has been changed.// Old API defineStaticProperty( self, BaseClass, options: { propertyName: string, defaultValue: any, strategy: string } ) // New API defineStaticProperty( self, propertyName: string, options: { initialValue: any, strategy: string } )
-
Remove
ManagerConfigValidator
class. We will be using schema-based validation instead. AdonisJS packages used this class (we assume some third-party packages to be using them as well). -
The
Exception
class API has been changed as well. Now, the Exception class allows for defining error message, code, and status when defining the exception.// Old API class UserNotFoundException extends Exception { } throw new UserNotFoundException('User not found', 404, 'E_USER_NOT_FOUND') // New API class UserNotFoundException extends Exception { static message = 'User not found' static status = 404 static code = 'E_USER_NOT_FOUND' } throw new UserNotFoundException() // Changes to Constructor API throw new UserNotFoundException('User not found', { code: 'E_USER_NOT_FOUND', status: 404 }) // Defining cause throw new UserNotFoundException('User not found', { cause: 'Database was down' })
-
The
base64.decode
andbase64.urlDecode
now raises an exception when the value ofstrict
is set totrue
. It returnednull
in strict mode and corrupt value without strict mode. -
The
fsReadAll
method API has been changed a little bit. Instead of accepting the filtercallback
as the 2nd argument, we now accept an options object, and the filter callback is a property on the options object.// Old API fsReadAll('./config', (filePath) => filePath.endsWith('.ts')) // New API fsReadAll('./config', { filter: (filePath) => filePath.endsWith('.ts') })
-
Remove
requireAll
in favor offsImportAll
. The newer helper uses the native ES modulesimport
method and is async. -
Remove
resolveDir
. This helper relied onrequire.resolve
, which does not exist in ES modules. -
Remove
resolveFrom
. Again, the helper relied onrequire.resolve
. -
Remove the
types
helper. We recommend you use the @sindresorhus/is package instead. -
Remove the
file
helper. We recommend you directly use the @poppinss/file-generator package. -
Remove the
cuid
helper. Use the cuid package directly.
String helpers breaking changes
- Remove
string.escapeHTML
andstring.encodeSymbols
methods. These were wrappers over the he, and we recommend you use the package directly. - The
string.defineIrregularRule
,string.defineUncountableRule
are accessible asstring.pluralize.addIrregularRule
and so on. - The
string.pluralize
andstring.pluralize
have been renamed tostring.plural
andstring.singular
. Thepluralize
method is a new function with different functionality (Refer to README). - The
string.prettyBytes
andstring.toBytes
methods have been renamed. You can access them asstring.bytes.format
andstring.bytes.parse
. - The
string.prettyMs
andstring.toMs
methods have been renamed. You can access them asstring.milliseconds.format
andstring.milliseconds.parse
. - The
string.generateRandom
method has been renamedstring.random
. - The
string.toSlug
method has been renamed tostring.slug
.
Commits
- chore: ignore package-lock file 02612c7
- chore: define types file for the lodash module f0a3ce3
- test: replace EOL with \n, since exceptions are separated by unix new lines c980c80
- test: debug statements to find failing tests cause on windows 4e15cdd
- refactor: small improvements 718c058
- test: do not run import ts files tests from compiled code 7623f43
- refactor: massive changes, changelog will cover all 41ba986
- refactor: re-organize all modules 8c21d97
- refactor: move slugify to its own module d5c3ab4
- refactor: move "truncate" and "exceprt" to their own respective modules ac2caca
- refactor: remove string.titleCase in favor of changeCase.titleCase 745a3e3
- refactor: pluralize module 099fdec
- test: remove old tests for change case b150770
- refactor: move casing helpers to "change_case" module 2df46c9
- refactor: remove ManagerConfigValidator 8b211e3
- refactor: exception class 504857e
- refactor: remove "esmResolver" and "esmRequire" utilities 4c3e432
- refactor: internal cleanup for the safe equal utility function ffd0fc5
- refactor: few internal improvements to the object builder class 0ac7b59
- refactor: remove "resolveFrom" and "resolveDir" utilities 1efc0e0
- refactor: remove requireAll utility b10252c
- style: update function description 078e6b6
- refactor: small internal improvements to the message builder dacf85b
- style: update license signature 610d746
- refactor: use secure-json-parse in place of custom implementation b15e0c1
- refactor: use safe-stable-stringify in place of custom implementation a79e770
- chore: update meta files 264ba2a
- refactor: interpolate function 812339f
- chore: lowercase helpers dirname 1d4b35f
- refactor: base64, fs_read_all and compose utilities ba2fa8c
- chore(package): update dependencies e07af33
Full Changelog: v5.0.0...v6.0.0-0