Repository: karen-irc/option-t
Pull request #1267 (2022-04-10 12:42:56)

Sort exported API naming style for expect of PlainOption
this do samething with #1261


Patch:
diff --git a/src/PlainOption/expect.ts b/src/PlainOption/expect.ts
index 6bccc869..27c5c3ac 100644
--- a/src/PlainOption/expect.ts
+++ b/src/PlainOption/expect.ts
@@ -4,10 +4,16 @@ import { Option } from './Option';
  *  Return _input_ as `T` if the passed _input_ is `Some(T)`.
  *  Otherwise, throw `TypeError` with the passed `msg`.
  */
-export function expectIsSome<T>(input: Option<T>, msg: string): T | never {
+export function expectSomeForOption<T>(input: Option<T>, msg: string): T | never {
     if (!input.ok) {
         throw new TypeError(msg);
     }
 
     return input.val;
 }
+
+/**
+ *  @deprecated
+ *  Use {@link expectSomeForOption}
+ */
+export const expectIsSome: typeof expectSomeForOption = expectSomeForOption;
diff --git a/src/PlainOption/index.ts b/src/PlainOption/index.ts
index 2a1b2a94..42779b6e 100644
--- a/src/PlainOption/index.ts
+++ b/src/PlainOption/index.ts
@@ -30,7 +30,7 @@ export { andForOption as and } from './and';
 export { andThenForOption as andThen } from './andThen';
 export { andThenAsyncForOption as andThenAsync } from './andThenAsync';
 export { equalForOption as equal } from './equal';
-export { expectIsSome as expect } from './expect';
+export { expectSomeForOption as expect, expectSomeForOption as expectSome } from './expect';
 export { filterForOption as filter } from './filter';
 export { flattenForOption as flatten } from './flatten';
 export { inspectOption as inspect } from './inspect';
@@ -45,7 +45,7 @@ export { orElseForOption as orElse } from './orElse';
 export { orElseAsyncForOption as orElseAsync } from './orElseAsync';
 export { transposeForOption as transpose } from './transpose';
 export { tapOption as tap } from './tap';
-export { unwrapOption as unwrap } from './unwrap';
+export { unwrapOption as unwrap, unwrapOption as unwrapSome } from './unwrap';
 export { unwrapOrFromOption as unwrapOr } from './unwrapOr';
 export { unwrapOrElseFromOption as unwrapOrElse } from './unwrapOrElse';
 export { unwrapOrElseAsyncFromOption as unwrapOrElseAsync } from './unwrapOrElseAsync';
diff --git a/src/PlainOption/unwrap.ts b/src/PlainOption/unwrap.ts
index 7c181a9f..146dd794 100644
--- a/src/PlainOption/unwrap.ts
+++ b/src/PlainOption/unwrap.ts
@@ -1,4 +1,4 @@
-import { expectIsSome } from './expect';
+import { expectSomeForOption } from './expect';
 import { Option } from './Option';
 
 /**
@@ -8,5 +8,7 @@ import { Option } from './Option';
  *      Throws if the self is a `None`.
  */
 export function unwrapOption<T>(input: Option<T>): T | never {
-    return expectIsSome(input, 'called with `None`');
+    return expectSomeForOption(input, 'called with `None`');
 }
+
+export { unwrapOption as unwrapSomeFromOption };
diff --git a/tools/public_api/table.mjs b/tools/public_api/table.mjs
index d90938d2..a7ce02e8 100644
--- a/tools/public_api/table.mjs
+++ b/tools/public_api/table.mjs
@@ -278,6 +278,7 @@ export const apiTable = Object.freeze({
             'andThenAsync',
             'equal',
             'expect',
+            'expectSome',
             'inspect',
             'filter',
             'flatten',
@@ -293,6 +294,7 @@ export const apiTable = Object.freeze({
             'transpose',
             'tap',
             'unwrap',
+            'unwrapSome',
             'unwrapOr',
             'unwrapOrElse',
             'unwrapOrElseAsync',
@@ -331,6 +333,7 @@ export const apiTable = Object.freeze({
     },
     'PlainOption/expect': {
         'exports': [
+            'expectSomeForOption',
             'expectIsSome'
         ]
     },
@@ -424,7 +427,8 @@ export const apiTable = Object.freeze({
     },
     'PlainOption/unwrap': {
         'exports': [
-            'unwrapOption'
+            'unwrapOption',
+            'unwrapSomeFromOption',
         ]
     },
     'PlainOption/unwrapOr': {


Test patch:
diff --git a/__tests__/PlainOption/expect.test.mjs b/__tests__/PlainOption/expect.test.mjs
index 93e0d593..1688e6fc 100644
--- a/__tests__/PlainOption/expect.test.mjs
+++ b/__tests__/PlainOption/expect.test.mjs
@@ -1,7 +1,7 @@
 import test from 'ava';
 
 import { createSome, createNone } from '../../__dist/esm/PlainOption/Option.mjs';
-import { expectIsSome } from '../../__dist/esm/PlainOption/expect.mjs';
+import { expectSomeForOption } from '../../__dist/esm/PlainOption/expect.mjs';
 
 test('input=Some', (t) => {
     const EXPECTED = Symbol('expected');
@@ -10,7 +10,7 @@ test('input=Some', (t) => {
 
     let actual;
     t.notThrows(() => {
-        actual = expectIsSome(input, 'do not throw any errors');
+        actual = expectSomeForOption(input, 'do not throw any errors');
     });
 
     t.is(actual, EXPECTED);
@@ -22,7 +22,7 @@ test('input=None', (t) => {
     const MSG = 'throw if the input is None';
     t.throws(
         () => {
-            expectIsSome(input, MSG);
+            expectSomeForOption(input, MSG);
         },
         {
             instanceOf: TypeError,