Skip to content

Commit

Permalink
Merge pull request #17 from hckrnews/feature/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies and the readme
  • Loading branch information
w3nl authored Jan 21, 2022
2 parents 0625c52 + 9ef98a2 commit e9f5b55
Show file tree
Hide file tree
Showing 4 changed files with 2,038 additions and 2,023 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x],
node-version: [12.x, 14.x, 16.x, 17.x]

steps:
- uses: actions/checkout@v1
Expand Down
94 changes: 47 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,57 @@ or
```javascript
import Enum from '@hckrnews/enum'

class Ecample extends Enum {
class Example extends Enum {
static test = 'TEXT'
static another = 42
}

Encoding.test // 'TEXT'
Encoding.options // { test: 'TEXT', another: 42 }
Encoding.options.test // 'TEXT'

const encoding = Encoding.fromKey('test')
encoding.key // 'test'
encoding.value // 'TEXT'
encoding.values // [ 'TEXT', 42 ]
encoding.keys // [ 'test', 'another ]
encoding.test // 'TEXT'
encoding.another // 42
encoding.length // 2

encoding.is(Encoding.test) // true
encoding.is('TEXT') // true
encoding.is(42) // false
encoding.in([Encoding.test]) // true
encoding.in(['TEXT']) // true
encoding.in([42]) // false

encoding.valueOf() // 42
encoding.toString() // 'test'
encoding.toJSON() // 'test'
JSON.stringify(encoding) // '"test"'

const encoding = Encoding.create('test')
encoding.key // 'test'
encoding.value // 'TEXT'

const encoding = Encoding.fromValue('TEXT')
encoding.key // test
encoding.value // TEXT

Encoding.hasKey('test') // teue
Encoding.hasKey('TEXT') // false
Encoding.hasValue('test') // teue
Encoding.hasValue('TEXT') // false

Encoding.toJSON() // { test: 'TEXT', another: 42 }
JSON.stringify(Encoding) // '{"test":"TEXT","another":42}'

const encoding = Encoding.create('test', { output: 'value' })
encoding.valueOf() // 42
encoding.toString() // '42'
encoding.toJSON() // 42
JSON.stringify(encoding) // '42'
Example.test // 'TEXT'
Example.options // { test: 'TEXT', another: 42 }
Example.options.test // 'TEXT'

const example = Example.fromKey('test')
example.key // 'test'
example.value // 'TEXT'
example.values // [ 'TEXT', 42 ]
example.keys // [ 'test', 'another ]
example.test // 'TEXT'
example.another // 42
example.length // 2

example.is(Example.test) // true
example.is('TEXT') // true
example.is(42) // false
example.in([Example.test]) // true
example.in(['TEXT']) // true
example.in([42]) // false

example.valueOf() // 42
example.toString() // 'test'
example.toJSON() // 'test'
JSON.stringify(example) // '"test"'

const example = Example.create('test')
example.key // 'test'
example.value // 'TEXT'

const example = Example.fromValue('TEXT')
example.key // test
example.value // TEXT

Example.hasKey('test') // teue
Example.hasKey('TEXT') // false
Example.hasValue('test') // teue
Example.hasValue('TEXT') // false

Example.toJSON() // { test: 'TEXT', another: 42 }
JSON.stringify(Example) // '{"test":"TEXT","another":42}'

const example = Example.create('test', { output: 'value' })
example.valueOf() // 42
example.toString() // '42'
example.toJSON() // 42
JSON.stringify(example) // '42'
```

[npm-url]: https://www.npmjs.com/package/@hckrnews/enum
Expand Down
Loading

0 comments on commit e9f5b55

Please sign in to comment.