Changelogs are moved to GitHub's release page.
- Update dependencies.
This is an empty release to announce that option-t/lib
will be remove in near ,future major releases.
option-t/lib/***
has been deprecated in v22.1
but we think some people still continue to use it by some reasons.
Finally, webpack v5 and rollup supports exports
field in their latest stable version. So we think we remove this feature in near future major releases.
If you are still using them,
- Please start to try to migrate them.
- Please file an issue as a new issue and link to the tracking issue.
- Please file your issue if you cannot migrate by some reasons.
- We're not planning to provide an alternative for deprecated APIs. But your problem is serious, we need to resolve it.
-
If you're using this, please migrate by following steps:
-
option-t/lib/Option
: Useoption-t/esm/Option
oroption-t/cjs/Option
. -
option-t/lib/Result
: Useoption-t/esm/Result
oroption-t/cjs/Result
. -
Otherwise, replase
option-t/lib/***
tooption-t/**
.
Handle '.' by tools/generate_import_path_list_markdown #807
- Update dependencies.
- Update 'description' in package.json to clarfy the stance of this package #806
- Update keywords in package.json #805
- Remove 'main' field from package.json #804
- Use .cjs extension for all commonjs files #798, #801
- Update typescript compiler to v4.1 (#792).
- By this change, we would be able to use some new language features for the future change.
Then they might make our
d.ts
imcompatible with typescript v3.9 or earlier. - This version is only change the baseline.
- By this change, we would be able to use some new language features for the future change.
Then they might make our
- Drop Node.js v12 from CI. #762
- Omit unused generic type parameters from
unwrap()
/unwrapErr()
/unwrapOr()
for PlainResult. #793- This would cause some compile error if you specify type parameters for them explicitly.
- Add some memories about why we use same shape. #765
- Move the document related to wrapper objects to
docs/
. #764
- Update dependencies.
- Add some memories about why we use same shape for PlainResult. #753
- Add some note why we deprecated a wrapper object. #754
- Clean up some documents. #723
- Update dependencies.
- Avoid to create a function object for each calling
drop()
forPlainResult
. #727 - Convert scripts to ESM in
tools/
#652
- Update typescript compiler to v4.0 (#716).
- By this change, we would be able to use some new language features for the future change.
Then they might make our
d.ts
imcompatible with typescript v3.9 or earlier. - This version is only change the baseline.
- By this change, we would be able to use some new language features for the future change.
Then they might make our
- Stop to update the link to compare each tags in this file.
- We can compare them by GitHub's release page now.
- Use prettier to format codes. #714
- Update dependencies.
- Use dependabot v2 configuration. #672.
- Move to GitHub Actions from CircleCI. #443.
- Refactor CI workflow.
- Fix the return type of
asMutResult()
asMutable
. #670.
- Add sections to docs/public_apis.md. #656.
- Update dependencies.
- Add docs/public_api_list.md to list all public API paths for conditional exports #655.
Support conditional exports for public API paths. #575.
- If toolchains support conditional exports, you can load modules with a same path from both commonjs and ES Module.
- We tested this feature on Node.js v12.7 or v14.
- Some legacy APIs have not marked for this yet.
- The following list is all:
option-t/Maybe
option-t/Maybe/and
option-t/Maybe/andThen
option-t/Maybe/expect
option-t/Maybe/map
option-t/Maybe/Maybe
option-t/Maybe/mapOr
option-t/Maybe/mapOrElse
option-t/Maybe/or
option-t/Maybe/orElse
option-t/Maybe/tap
option-t/Maybe/unwrap
option-t/Maybe/unwrapOr
option-t/Maybe/unwrapOrElse
option-t/Maybe/xor
option-t/Nullable
option-t/Nullable/and
option-t/Nullable/andThen
option-t/Nullable/expect
option-t/Nullable/map
option-t/Nullable/mapOr
option-t/Nullable/mapOrElse
option-t/Nullable/Nullable
option-t/Nullable/or
option-t/Nullable/orElse
option-t/Nullable/tap
option-t/Nullable/unwrap
option-t/Nullable/unwrapOr
option-t/Nullable/unwrapOrElse
option-t/Nullable/xor
option-t/PlainOption
option-t/PlainOption/and
option-t/PlainOption/andThen
option-t/PlainOption/asMut
option-t/PlainOption/drop
option-t/PlainOption/expect
option-t/PlainOption/filter
option-t/PlainOption/flatten
option-t/PlainOption/map
option-t/PlainOption/mapOr
option-t/PlainOption/mapOrElse
option-t/PlainOption/okOr
option-t/PlainOption/okOrElse
option-t/PlainOption/Option
option-t/PlainOption/or
option-t/PlainOption/orElse
option-t/PlainOption/transpose
option-t/PlainOption/tap
option-t/PlainOption/unwrap
option-t/PlainOption/unwrapOr
option-t/PlainOption/unwrapOrElse
option-t/PlainOption/xor
option-t/PlainResult
option-t/PlainResult/and
option-t/PlainResult/andThen
option-t/PlainResult/asMut
option-t/PlainResult/drop
option-t/PlainResult/expect
option-t/PlainResult/flatten
option-t/PlainResult/map
option-t/PlainResult/mapErr
option-t/PlainResult/mapOr
option-t/PlainResult/mapOrElse
option-t/PlainResult/or
option-t/PlainResult/orElse
option-t/PlainResult/Result
option-t/PlainResult/tap
option-t/PlainResult/toOption
option-t/PlainResult/transpose
option-t/PlainResult/unwrap
option-t/PlainResult/unwrapOr
option-t/PlainResult/unwrapOrElse
option-t/Undefinable
option-t/Undefinable/and
option-t/Undefinable/andThen
option-t/Undefinable/expect
option-t/Undefinable/map
option-t/Undefinable/mapOr
option-t/Undefinable/mapOrElse
option-t/Undefinable/or
option-t/Undefinable/orElse
option-t/Undefinable/tap
option-t/Undefinable/Undefinable
option-t/Undefinable/unwrap
option-t/Undefinable/unwrapOr
option-t/Undefinable/unwrapOrElse
option-t/Undefinable/xor
- Update dependencies.
- Remove renamer-cli from depdendencies. (#610)
- Implement
flatten()
for PlainResult. (#608)
- Update dependencies.
- Add more test cases. (#609)
- Update dependencies.
- Fix the order of arguments for eslint-cli. (#606)
- Fix
ERR_PACKAGE_PATH_NOT_EXPORTED
error on loadingoption-t
. (#602)- This problem was reproducible with Node.js v13.10 or later.
- Add exist paths to 'exports' fields in package.json. (#579)
- By the behavior of Node.js v13.8,
if we add
exports
field once even if its object is empty{}
, user could not load all subpaths byoption-t/esm/Bar/Foo
. This causes a breaking change. So I added these entries to keep the backward compatibility.
- By the behavior of Node.js v13.8,
if we add
- Add
mapOr()
forPlainResult<T, E>
. (#572)
- Fix changelog outline.
Not recommend to use tap()
for Nullable
/Undefinable
/Maybe
generally (#571).
- We added these functions to
- Sort with other types.
- Future enhancement for pipelining functions.
- But in generally, simple
if
statement or similar way would be readable and efficient.if (!!v) { ... }
orif (v) { }
are completely same behavior, more straight way, and the standard way.
- We'll continue to provide these functions including for
PlainOption
/PlainResult
.- For
PlainOption
/PlainResult
, we think that this kind of functions are useful becausetap()
can hide to touch their properties.
- For
- Update dependencies.
- Update dependencies.
- Stop to use Reviewable. (#544)
Deprecate option-t/lib/***
(#527)
- This does not mean that we will remove
option-t/lib
in the next release. - For the future relase, we will stop to publish
option-t/lib/***
.- This is a preparation for it.
- To do this, we need dual (cjs+mjs) package support by Node.js
- If you depend on it, you should move to
option-t/esm
(recommended) oroption-t/cjs
. - See the PR to know more details.
- Fix the custom babel plugin: Early return correctly if import/export declaration does not have StrngLiteral as
source
. (#523)
- Fix dead link in CHANGELOG.md
- Clean up the custom babel plugin to rewrite import/export path with
.mjs
. (#522)
- We remove
.js
files fromesm/
(#504) and we supply.mjs
extension for all import/export declaration by #520/#521. - By this change, you can import
import 'option-t/esm/Nullable/index.mjs';
orimport 'option-t/lib/Nullable/index.mjs';
after Node.js v13. - However, this change may cause these problems:
- If your module bundler does not support
.mjs
, it will raise some errors. - If you import files in
esm/
with.js
extensions, it will raise some errors.
- If your module bundler does not support
- Implement
xor()
forMaybe<T>
. (#411)
- Update dependencies.
- Revendor eslint configs. (#519)
- Migrate all tests to ava.
- By this change, we removed mocha.
- We always transform test code via TypeScript compiler.
- Update typescript compiler to v3.7 (#427).
- By this change, we would be able to use some new language features for the future change.
Then they might make our
d.ts
imcompatible with typescript v3.6 or earlier. - This version is only change the baseline.
- By this change, we would be able to use some new language features for the future change.
Then they might make our
- Replace the minimum support version of Node.js from v10 to v12.
- See more details.
- Update a bunch of dependencies.
- See more details.
- Mark legacy
Option<T>
andResult<T, E>
as deprecated (#462).- This does mean that we don't recommend to use them in your newer code.
- This does not mean that we drop them soon.
- See more details.
- Remove power-assert (#446).
- Rename all tests (#452).
- Update dev dependencies.
- See more details: v20.2.3...v20.2.4.
- Fix changelogs.
- Migrate to CircleCI.
- Update dev dependencies.
- See more details: v20.2.1...v20.2.2.
- Enable
reportUnusedDisableDirectives
to warn unused disable ESLint directives #428).
- Implement
xor()
#409).- We have not completed to implement this for
Maybe<T>
. We added the signature but we don't implement the actual implementation for it because there are considerable options such Nullish Coalescing Proposal or Optional Chaining Proposal.
- We have not completed to implement this for
- Update dev dependencies.
- See v20.1.1...v20.2.0.
Fix the changelog we missed to update in v20.1.0.
- Add comments to not recommend to create
PlainOption
/PlainResult
without factory functions (#395).
- Add the test to ensure that required properties exist on objects for
PlainOption
/PlainResult
(#395). - Add tests for
PlainOption
/PlainResult
. - Update dependencies.
- Add comments which explains undocumented design (#391).
- Add comments for operators of
PlainOption
/PlainResult
(#385).
- Allow to compile with TypeScript 3.5 (#381).
- Updete
devDependencies
.
- Add comments why we don't recommend to use wrapper objects (#379).
- We have already written this reason in README.
- Fix misusing
assert.notStrictEqual()
in the test forOption<T>.flatMap()
. (#373)- This is the bug only for our unit testing, not for our production code.
- Introduce dependabot (#370).
- Update babel. (#372).
v20.0.0
is a missing number.
- Remove deprecated APIs (#364).
new Some()
forlib/Option
.new None()
forlib/Option
.new Ok()
forlib/Result
.new Err()
forlib/Result
.
- Disallow import from 'option-t' (#365).
- These style importing will no longer work.
import {} from 'option-t';
const OptionT = require('option-t');
- For the future, we might provide all APIs from this entry points.
- These style importing will no longer work.
- Mark deprecated APIs. #361 & #363
These are deprecated for a long time since
v14.1
(#232). We'll remove them in the next major release.new Some()
forlib/Option
.new None()
forlib/Option
.new Ok()
forlib/Result
.new Err()
forlib/Result
.
- Update dev dependencies. #354
- Migrate to use typescript-eslint. #350
- Use
fs.promises
directly in our toolchain. #353
- Introduce
transpose()
forPlainOption<Result<T, E>>
&PlainResult<Option<T>, E>
. (#348)
- Fix the link to the idiom about express progressive data. (#347)
- Add the idiom to express progressive data. (#346)
- Introduce
Not***
types forNullable
,Undefinable
, andMaybe
. (#344)- These ensure statically that the type will not be nullable by TypeScript's conditional type.
NotNullAndUndefined<T>
will not benull | undefined
.NotNull<T>
will not benull
.NotUndefined<T>
will not beundefined
.
- We use
Not***
prefixes for these type because typescript compiler hasNonNullable<T>
as its builtin type. - We might make a function's type signature more strict for the future in #345
by these types.
- You can try it via
npm install option-t@next
oryarn add option-t@next
. Your feedback is welcome!
- You can try it via
- These ensure statically that the type will not be nullable by TypeScript's conditional type.
Drop Node v8 support (#338)
- This does not mean that this code will not run with Node.js v8 immediately.
- But this allow to introduce a change which is incompatible with Node v8.
Reorganize modules to place Mut***
in PlainOption
& PlainResult
(#341)
- This improve the intelliSense provided by vscode (tsserver) for
PlainOption/Plain
&PlainResult
.- e.g. The previous one is shown as
Readonly<MutSome<T>>
. This is not straight forward.
- e.g. The previous one is shown as
-
Mut**
is only used in unsafe operation to improve extreme performance issue.- We don't have to expose it in almost case.
- Change
.ok
property onMutOption<T>
andMutResult<T, E>
to mutable. - Removed
MutSome<T>
,MutOk<T>
, andMutErr<E>
.- We cannot (or it's hard to) ensure their types statically if we allow to change
.ok
.
- We cannot (or it's hard to) ensure their types statically if we allow to change
- Enforce import
{PlainOption, PlainResult}/asMut
to useMutOption<T>
orMutResult<T, E>
.- These types are extreme usecase. I think user should import them explicitly.
Introduce unsafe destructing function for PlainOption
& PlainResult
(#342)
- This introduce these functions to allow to cut off the reference to the internal values from the outer container object.
PlainOption/drop
unsafeDropForOption()
PlainResult/drop
unsafeDropBothForResult()
unsafeDropOkForResult()
unsafeDropErrForResult()
- These functions might be unsafe in some case. So we add
unsafe
prefixes to them at this moment. The unsafe example is here:
const some = createSome(1);
isSome(some); // -> true.
unsafeDropForOption(some, (some) => {
some.ok = false;
});
isSome(some); // -> false. This is dangerous by breaking the immutability of `PlainOption/Option` unexpectedly.
- Refactoring Build System.
Add the guide to no recommendation to use wrapper objects (optiont-/{cjs,esm,lib}/Option<T>
& optiont-/{cjs,esm,lib}/Result<T, E>
) in almost case.
(#337)
- Basically, we recommend to use utility types & functions.
- Wrapper objects has some downside if your project has multiple versions of this package in its project dependencies.
instanceof
might not work expectedly if you(a instanceof b)
in this case. This is confusable behavior.a
is created by the constructor provided by the version a of this.b
is the constructor provided by the version b of this.
- Broat bundle size unnecessarily.
- It's hard for almost JS code minifier to minify a property on prototype chain.
- So we decide to no-recommend wrapper objects without any strong motivation.
- This does not mean to make them obsolete or deprecate now.
- We don't have any concrete plan to deprecate these API.
- Of course, however, we would lower priorities of them.
- Fix the failure to release #332.
- Update dependencies. (#328)
- Add ESLint as the linter for TypeScript. (#329)
- Overhaul build system. (#330)
- Add
mapOrElse()
operation forResult<T, E>
&PlainResult<T, E>
. #327
- Move to use @babel/preset-env to tranform code from set plugins directly. #323
- This might cause some regression...
- Relax
this
type for callback functions. #322- This change is for TypeScript 3.2's
strictBindCallApply
option.
- This change is for TypeScript 3.2's
- Lock yarnpkg on CI to v1.10.1 (#318.
- This changes only effects for a contributor.
- This avoids the problem like 317.
- Update typescript compiler to v3.0 (#314).
- Update dependencies (#314).
- Obsolete
instanceof
checking forlib/Option
andlib/Result
. (#287)- We preserve constructors:
Ok
,Err
,Some
, andNone
for a backward compatibility. - We don't have any plan to remove these constructors. If we remove them, we might provide some refactoring scripts.
- We preserve constructors:
- Overhaul type definitions for
lib/Option
andlib/Result
. (#287)- If your code use their type definitions, this may breaks your code.
- Rename
ResultBase._is_ok
toResultBase._isOk
. (#287)- These are private APIs. You should not use this.
index.js
exportscreateSome
andcreateNone
forlib/Option
. (#283)- This follows up #235.
- By this change, you can write
import { createSome } from 'option-t';
.- We don't recommend this usage because this is kept for the backward compatibility.
However, if your code still uses
import { Some, None } from 'option-t'
, then you can migrate them.
- We don't recommend this usage because this is kept for the backward compatibility.
However, if your code still uses
Throw TypeError
if you "null" value as default value to unwrapOr()
/unwrapOrElse
operation for Maybe
/Nullable
/Undefinable
. (#278)
- As we warning in v14.3.0, we assert a default value for
unwrapOr()
/unwrapOrElse
operation forMaybe
/Nullable
/Undefinable
. - In these case, these functions will throw
TypeError
.- Pass these type as a default value for
unwrapOr()
null
forunwrapOrFromNullable()
undefined
forunwrapOrFromUndefinable()
null
orundefined
forunwrapOrFromMaybe()
- Pass these type as the result of default value factory function for
unwrapOrElse()
null
forunwrapOrElseFromNullable()
undefined
forunwrapOrElseFromUndefinable()
null
orundefined
forunwrapOrElseFromMaybe()
- Pass these type as a default value for
- Rename
lib/utils
->lib/shared
. (#276)- If you use
option-t/lib/utils
, please replace withoption-t/lib/shared
.
- If you use
- Return the input value on
tap(
) forMaybe
/Nullable
/Undefinable
/PlainOption
/PlainResult
. (#271)- This function returned
void
previously. - You would not have to change your code if you don't use the returned value (e.g.
const bar: void = tap(input, fn)
orsomefunc(tap(input, fn))
).
- This function returned
- Implement
okOr()
/okOrElse()
forPlainOption
. (#275)
- Deduplicate error message strings for
Maybe
/Nullable
/Undefinable
. (#272)
- Fix the changelog.
- Fix the changelog.
Add factory functions for lib/Option
and lib/Result
. (#235)
- This introduces:
createSome<T>(v: T)
andcreateNone<T>()
forlib/Option
.createOk<T, E>(v: T)
andcreateErr<T, E>(e: E)
forlib/Result
.
- These are migration plans for (#232).
- We may make these obsolete for the future. So we recommend to use these factory functions instead of these costructors.
new Some()
forlib/Option
.new None()
forlib/Option
.new Ok()
forlib/Result
.new Err()
forlib/Result
.
- We may make these obsolete for the future. So we recommend to use these factory functions instead of these costructors.
- Add the comment for some functions:
map()
forMaybe
/Nullable
/Undefinable
. (#259)mapOr()
forMaybe
/Nullable
/Undefinable
. (#262)andThen()
forMaybe
/Nullable
/Undefinable
. (#261)mapOrElse()
forMaybe
/Nullable
/Undefinable
. (#263)orElse()
forMaybe
/Nullable
/Undefinable
. (#259)and()
forMaybe
/Nullable
/Undefinable
. (#265)or()
forMaybe
/Nullable
/Undefinable
. (#266)tap()
forMaybe
/Nullable
/Undefinable
. (#264)
- We don't recommend to pass a nullable value to the def argument for
unwrapOr(v, def)
. (#253)- We may assert the value for the future.
- We don't recommend to return a nullable value as the result of def argument for
unwrapOrElse(v, def)
. (#253)- We may assert the value for the future.
- Upgrade our TypeScript version to v2.7. (#255)
- We don't introdue any new syntaxes by this change. So we'd not like to mark this as major.
- Reconfig tsconfig.json. (#256)
- Update our
devDependencies
. (#252)- If you're just an user, this change does not related to you.
- Add the comment for some functions
- Update dependencies. (#252)
- Add the comment why
map()
forMaybe
/Nullable
/Undefinable
throw theTypeError
if the selector returns a nullable type. (#236)
- Stabilize the shape for
PlainOption<T>
/PlainResult<T, E>
. (#231)- By this change,
None.val
inlib/PlainOption/Option
, andOk.err
/Err.val
inlib/PlainResult/Result
would be filled withundefined
and they are[[Enumerable]]
. - We don't think this is a breaking change because this library would not be used with
for-in
statement and others.- If you use these object with those operations, please don't do that.
- By this change,
Deprecate instanceof
checking for Some
/None
in option-t/lib/Option
and Ok
/Err
in option-t/lib/Result
.
- We plan to deprecate
instanceof
checking for above objects for the future release to stabilize object shapes of them for the performance reason.- See #232.
- At this major version, we will not obsolete them. But we might make them be obsolete for the next or the next-next major release.
- Instead use
Option<T>.isSome
,Option<T>.isNone
,Result<T, E>.isOk()
, orResult<T, E>.isErr()
.
- Remove
do()
functions (#230).- You can migrate your code with v13.2.
- Remove
option-t/cjs/PlainResult/Function
andoption-t/esm/PlainResult/Function
.- This is a part of refactoring internal types. (#223)
- This would affect TypeScript user.
Add tap()
functions (Rename do()
functions to tap()
at all) (#229)
We rename do()
functions to tap()
at all to sort with rxjs
or ixjs
.
We leave do()
as an alias for tap()
with a backward compatibility.
You code will works well if you don't change your code on updating this version.
But it will be gone in the next major release. We recommends to change your code. Basic migration guides is here:
- Instead of
DoFn
, importTapFn
fromoption-t/***utils/Function
. - If you use
import { doOnA } from 'option-t/***/A/do';
, instead useimport { tapA } from 'option-t/***/A/tap';
. - If you use
import AMod from 'option-t/***/A'; AMod.do();
, instead useimport AMod from 'option-t/***/A'; AMod.tap();
.
If you'd like to know more details see option-t#229.
- Publish
lib/
to npm correctly. (#227)
- Fix the indent problem in README.md. (#225)
- Add
lib/
directory which contains both of commonjs style.js
file and es module style.mjs
file. (#224)- Please see How to import section in README.md.
- Unship a source map. (#220)
- Our shipping code is down-level transformed. But ours not a complicated transform. We can read the transformed code.
- For debugging purpose, Showing transformed code would be better if it's not complicated.
- Thus We stop to ship a source map.
- Remove license header comment. (#222)
- After we merged #221, we can remove them.
- If you expect that a minifier preserve
@license
comment to preserve license comment, you should care this.
- Add LICENSE.MIT. (#221)
- Rename from
lib/
tocjs/
. (#218)- If you use
option-t/lib
, please replace it withoption-t/cjs
- If you use
- You can use
import { ok, err, } from 'option-t/esm/PlainResult';
instead ofimport { toOptionFromOk, toOptionFromErr, } from 'option-t/esm/PlainResult';
. (#219)
- Rename functions. (#208)
option-t/lib/Maybe
/and
:andMaybe()
->andForMaybe()
/or
:orMaybe()
->orForMaybe()
option-t/lib/Nullable
/and
:andNullable()
->andForNullable()
/or
:orNullable()
->orForNullable()
option-t/lib/Undefinable
/and
:andUndefinable()
->andForUndefinable()
/or
:orUndefinable()
->orForUndefinable()
option-t/lib/PlainOption
/or
:orOption()
->orForOption()
option-t/lib/PlainResult
/or
:orResult()
->orForResult()
- Inline
isUndefined()
/isNotUndefined()
by hand to decrease calling a function. (#209) - Inline
isSome()
/isNone()
by hand to decrease calling a function. (#210) - Inline
isOk()
/isErr()
by hand to decrease calling a function. (#211) - Inline
isNotNullAndUndefined()
/isNullOrUndefined()
by hand to decrease calling a function. (#212)
- Inline
isNull()
/isNotNull()
by hand to decrease calling a function. (#207)
- Remove to support Node v6 LTS. (#204)
- Update dev dependnecies. (#202)
- Fix the bug which does not emit some modules as ES module syntax into
esm/
. (#201)- This fixes that some files in
option-t/esm
are not ES module.option-t/esm
option-t/esm/Option
option-t/esm/Result
- This fixes that some files in
- Clean up internals types. (#200)
- We transfer this repository from github:saneyuki/option-t.js to github:karen-irc/option-t.
- Use
babel-plugin-transform-es2015-block-scoping
to useconst
/let
for plain js files undersrc/
. (#198)
- Change the internal design for
Option<T>
. (#195) - Rethink
PlainResult/do
. (#197)- Add
doOnBoth
forPlainResult/do
. - Change exporting from
PlainResult/index
. You need to changeimport { do, doErr, } from 'option-t/PlainResult';
->import { doOnOk, doOnErr, } from 'option-t/PlainResult';
.
- Add
- Fix the serious problems.
PlainOption.isSome()
andPlainResult.isOk()
returns wrong results. (#196)
- Add
.mjs
code tooption-t/es6
directory. (#191) - Clean up README.md (#193)
- Add type aliases for a plain object (#194)
- See
option-t/PlainOption
andoption-t/PlainResult
. - CAUTION: This is still expetimental APIs. We might change an interface for the future with the braking change
- See
- Rename
option-t/es6
tooption-t/esm
(#192)
Maybe::unwrap()
should throw more detailed message. (#186)
- Rename: (#184)
Maybe::isSomeValue()
->Maybe::isNotNullAndUndefined()
- Enhancement for tree shaking via a bundler (#177).
- Upgrade dependencies. (#172)
- This includes upgrading TypeScript to 2.3.
- Drop support node v4. (#173)
- Upgrade our language baseline to ES5 (#174)
- If you use this package for a product targeted to ES3 environment (e.g. ~IE8), You need to care about it.
- Rename: (#176)
Maybe::isUndefinedOrNull()
->Maybe::isNullOrUndefined()
Maybe::isSomeActual()
->Maybe::isSomeValue()
- By (#169),
- You can use
andThen()
function fromoption-t/lib/Nullable
oroption-t/lib/Undefinable
. - We drop to support for
flatMap()
forNullable
orUndefinable
.- It's too hard to undarstand that "flatMap" operation for
T | undefined
orT | null
.
- It's too hard to undarstand that "flatMap" operation for
- You can use
- You can use
orElse()
function fromoption-t/lib/Nullable
oroption-t/lib/Undefinable
. (#170)
Add utility functions for values which may be null
or undefined
(#167)
- This is just utility function for their "null value" in ECMA262 world.
- This is experimental feature. Their names are not stable.
- You can use them by:
const Nullable = require('option-t/lib/Nullable');
fornull
const Undefinable = require('option-t/lib/Undefinable');
forundefined
const Maybe = require('option-t/lib/Maybe');
fornull
orundefined
- Remove
engines
field from package.json. (#163) - All distribution codes are in
lib/
now. (#164)- If you use
require('option-t/src/Result')
, please change torequire('option-t/lib/Result')
- If you use
- Add
yarn.lock
for library developers (#162)
- Rewrite d.ts (#157)
- By this change, you might have some failure to compile your code with this library. So we think this would be a breaking change.
- Use
never
type. (#154) - Use literal type. (#152)
- Fix the bug which cannot pack files correctly. (#150)
this
type are specfied for callbacks (#142)- This change requires to use TypeScript 2.0 or highers.
- Drop to support
classic
module resolutions (#145)- Use
--moduleResolution node
or others.
- Use
- Use TypeScript v2.0 (#141)
- These would causes
TypeError
instread ofError
. (#132)Option<T>.unwrap()
Option<T>.expect()
Result<T, E>.unwrap()
Result<T, E>.unwrapErr()
Result<T, E>.expect()
- Remove Node v5 from CI. (#136)
- Add links to pull request for CHANGELOG.md. (#129)
- Fix the sample code of casting from
Option<T>
toPromise
. (#130)
- Fix the link to API documentations.(#128)
- Add more descriptions about runtime nullability checking in README.md (#127)
- Add some semantics description to README.md (#126)
Remove Option<T>.asPromise()
(#125)
In previous version (~v0.17), we provide Option<T>.asPromise()
utility method casting from Option<T>
to Promise
.
Its methods always treats None
as a rejected Promise
.
But there are various cases which we would not like to cast to a Promise from an Optional type with single way,
there are various context to handle a None
value.
Thus we don't provide a default way to cast to Promise
. Please define a most suitable way to your project.
You can write a custom cast function or use Option<T>.mapOrElse()
.
// This functon treats `None` as a rejected `Promise`
function castToPromise1(option: Option<T>): Promise<T> {
return option.mapOrElse(() => Promise.reject(), (v: T) => Promise.resolve(v));
}
// This function treats `None` as a `Promise` which is fulfilled with a tagged union object.
function castToPromise2(option: Option<T>): Promise<{ ok: boolean; value: T }> {
const result = {
ok: false,
value: undefined,
};
return option.mapOrElse(() => {
return Promise.resolve(result);
}, (v: T) => {
result.ok = true;
result.value = v;
return Promise.resolve(result);
});
}
- Rename internal types' naming in
Result.d.ts
. (#122)
- Update ESLint to v2.3.0. (#109)
- Enable lint for
/test/
dir. (#110) - Use
assert.strictEqual()
instead ofassert.ok()
. (#112) - Split off
OptionT.d.ts
from '/option-t.es6.d.ts'. (#115)
- Throw
TypeError
instead ofError
if a callbacks forOption<T>.andThen()
/orElse()
returns nonOption<T>
type. (#116)
We introduce the new experimental feature Result<T, E>
which is inspired by
Rust's std::result::Result<T, E>
by #88, #111.
See /src/Result.ts
for more details.
This feature is not exported by default now. If you'd like to use it, let's try to import this:
const ResultMod = require('option-t/src/Result');
const Ok = ResultMod.Ok;
const Err = ResultMod.Err;
import {Result, Ok, Err, ResultBase} from 'option-t/src/Result';
Now, Option<T>.drop()
can take a custom destructor function by #118.
So you can pass a custom destructor function to dispose the inner value.
const some = new Some(largeSensitiveObject);
some.drop((v) => v.dispose());
- Revert #97 to fix the compile error on tsc nightly
a missing version.
- Remove Support iojs. #98
- Support only after NodeJS 4.2 LTS.
Option<T>
is just eitherSome<T>
orNone<T>
. #99- The previous interface
Option<T>
was renamed toOptionMethods<T>
, and marked it as a private.- This is just only for a defensive programming style.
- If you get a new problem by this change, please file a new issue. We'll consider to republish it.
- The previous interface
- Define
Option<T>.isSome
andOptionT.isNone
as a type guard function. #97- This causes the breaking change which cannot compile
~typescript@1.7.x
.
- This causes the breaking change which cannot compile
- This version drops to support Node.js v0.10.
- This version would work on Node.js v0.10
- But we don't ensure to work on it in a future release.
- Add Node.js v5 as a CI tested environment #89
- Remove Node.js v0.10 from a CI tested environment #90
- This change does not have any effects to existed codes.
- Polish the documentation about casting to
Promise
#91
- Update README.md's 'semantics' section. #85
- Support TypeScript 1.6 stable's
--moduleResolution node
mode. #83
- Change
OptionBase
type definition to abstract class. (#81)- We require TypeScript 1.6 to use this feature.
- Upgrade TypeScript compiler which our supports to
^1.6.0-beta
. #76
- Expose
OptionBase
to TypeScript's type definition.- NOTICE:
- In general purpose, you must not use this object.
- You can only this object if you need to cooperate with some libralies
like
React.PropTypes
which are useinstanceof
checking to work together with others in the pure JavaScript world. The typical case is TSX (TypeScript JSX) syntax. - Our basic stance is that you don't use this and need not it in almost case.
- See also #77
- NOTICE:
- Support Node.js v4. #79
- Fix the bug whic is
SomeInstance instanceof None
will betrue
. (#78)
- Add API documentations to TypeScript's type definition.
- Fix to forget the bump up version in CHANGELOG.md.
- Support
typings
field in package.json for TypeScript.- See more details: microsoft/TypeScript#4352
- TypeScript's type definition only support ES6 target officially.
- You may continue to use this package without make your code to ES6 target. See more details: #72
- Remove
OptionT.OptionT
. ( #67 )- This was marked as deprecated in 0.10.x.
- Fix typos in changelog.
- Add
OptionT.OptionBase
.- This change also marks
OptionT.OptionT
as deprecated. - We recommend to use this new base object instead of
OptionT.OptionT
. See more details ( #66 ).
- This change also marks
- Add
keywords
section to package.json.
- Support 'typescript' in package.json for tsd & dtsm. (#62)
- This does not affect this library's API model. Thus we release this as patch version.
- Thanks @gifnksm!
- Fix the compiler error if we use tsc's '--noImplicitAny' flag (#58)
- Make
Option<T>.mapOr()
andOption<T>.mapOrElse()
stable.- We accept current signitures of these APIs as stable. When Rust's upstream changes these APIs, we might follow them with bumping our major version.
- Rust might change these API signitures. see: rust-lang/rfcs#1025.
- Add
Option<T>.asPromise()
.
- Fix
Uncaught TypeError: Illegal invocation
on browsers.
- Add
Option<T>.isNone
. - Add
Option<T>.unwrapOr()
. - Add
Option<T>.unwrapOrElse()
. - Add
Option<T>.expect()
. - Add some experimental APIs. These are unstable.
- Add
Option<T>.mapOr()
. - Add
Option<T>.mapOrElse()
.
- Add
- JSDoc: Change
Option<T>
used as parameter/return value to non-nullable type.- This might cause some compile error if you use closure compiler's advanced optimization.
- JSDoc: Remove needless
@template
annotations.
- Don't preserve the needless license block when minifying.
- Fix JSDoc.
- Add
@extends
annotation toSome
&None
. - Fix warning of closure compiler.
- Add
- Use
OptionT
to check whether the object isOption<T>
.
- Share the same object as prototype between
OptionT.Some
andOptionT.None
.
- Remove
@nosideeffect
annotation fromOption<T>.isSome
. It was a invalid annotation.
OptionType<T>
is obsolated. This API will be no longer supported.
- Add
Option<T>.and()
. - Add
Option<T>.or()
. - Add
Option<T>.orElse()
. - Export the definition of
Option<T>.andThen()
.
- Fix JSDoc in OptionT.js
- Add new interfaces. These constructors make interfaces more clear and explicit.
OptionT.Some()
constructor creates aSome<T>
representation.OptionT.None()
constructor creates aNone
representation.OptionT.Option<T>
interface meansOption<T>
.- This can be used only on an environment having a interface in its type system (e.g. TypeScript).
- If you'd like to check whether the object
option
isOption<T>
or not in an environment likeReact.PropTypes
which has no interface feature, you can useoption instanceof OptionT.OptionT
to check the object. But this way is not a tier-1 approach. We recommend to use a interface strongly. (Thus we don't exportOptionT
to the type definition for TypeScript).
- Add type definitions for TypeScript.
OptionT.OptionType()
is now deprecated. This will be removed in future release.- Of cource, this constructor is simple api,
but it don't handle
None
orSome<T>
properly if we passundefined
value. In some case, this api cannot differentiate whether theundefined
value meansNone
or "the value returnsundefined
correctly". See more derails.
- Of cource, this constructor is simple api,
but it don't handle
- New Feature
- Add methods:
unwrap()
map()
flatMap()
drop()
- Add methods:
- Documentation
- Write more descriptions to README.md.
- Documentation
- Fix JSDoc.
- Initial Release.