Skip to content

Commit

Permalink
Fix github action
Browse files Browse the repository at this point in the history
  • Loading branch information
allevo committed Nov 8, 2023
1 parent dd507e6 commit 7ceac5e
Show file tree
Hide file tree
Showing 11 changed files with 3,071 additions and 42 deletions.
45 changes: 24 additions & 21 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
name: Nodejs

on: [push]

jobs:
build:
runs-on: ubuntu-latest
name: Build and Test
timeout-minutes: 15
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2

- uses: pnpm/action-setup@v2
with:
version: latest
strategy:
matrix:
node-version: [18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Run lint
run: pnpm run lint
- name: Run test
run: pnpm run test

- name: Test
run: pnpm test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,5 @@ tmp

bun.lockb
benchmark
pnpm-lock.yaml

*.0x/
12 changes: 6 additions & 6 deletions examples/complex_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ interface Post {
comments: Comment[]
}

function serializeUser(ser: Ser, user: User) {
function serializeUser (ser: Ser, user: User): void {
ser.serializeUInt32(user.id)
ser.serializeString(user.username)
}
function deserializeUser(des: Des): User {
function deserializeUser (des: Des): User {
const id = des.deserializeUInt32()
const username = des.deserializeString()
return { id, username }
}
function serializeComment(ser: Ser, comment: Comment) {
function serializeComment (ser: Ser, comment: Comment): void {
ser.serializeUInt32(comment.id)
ser.serializeString(comment.body)
serializeUser(ser, comment.user)
}
function deserializeComment(des: Des): Comment {
function deserializeComment (des: Des): Comment {
const id = des.deserializeUInt32()
const body = des.deserializeString()
const user = deserializeUser(des)
return { id, body, user }
}
function serializePost (ser: Ser, post: Post) {
function serializePost (ser: Ser, post: Post): void {
ser.serializeUInt32(post.id)
ser.serializeString(post.title)
serializeUser(ser, post.creator)
Expand All @@ -60,7 +60,7 @@ serializePost(ser, {
creator: { id: 1, username: 'bob' },
comments: [
{ id: 1, body: 'hello', user: { id: 1, username: 'bob' } },
{ id: 2, body: 'world', user: { id: 2, username: 'alice' } },
{ id: 2, body: 'world', user: { id: 2, username: 'alice' } }
]
})
const buffer = ser.getBuffer()
Expand Down
4 changes: 2 additions & 2 deletions examples/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Todo {
completed: boolean
}

function serializeTodo (ser: Ser, todo: Todo) {
function serializeTodo (ser: Ser, todo: Todo): void {
ser.serializeUInt32(todo.id)
ser.serializeUInt32(todo.userId)
ser.serializeString(todo.title)
Expand All @@ -27,7 +27,7 @@ serializeTodo(ser, {
id: 1,
userId: 1,
title: 'hello',
completed: false,
completed: false
})
const buffer = ser.getBuffer()

Expand Down
3 changes: 1 addition & 2 deletions examples/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ const f = des.deserializeFloat32()
const s = des.deserializeString()
const a = des.deserializeArray((des) => des.deserializeUInt32())

console.log({b, i, f, s, a})

console.log({ b, i, f, s, a })
5 changes: 2 additions & 3 deletions examples/todos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import type { Ser, Des } from '../src/index'

let buffer


{ // Serialize
const todos = [
{ userId: 1, id: 1, completed: false, title: "delectus aut autem" },
{ userId: 1, id: 2, completed: true, title: "quis ut nam facilis et officia qui" },
{ userId: 1, id: 1, completed: false, title: 'delectus aut autem' },
{ userId: 1, id: 2, completed: true, title: 'quis ut nam facilis et officia qui' }
]
const ser: Ser = createSer()
ser.serializeArray(todos, (ser, todo) => {
Expand Down
Loading

0 comments on commit 7ceac5e

Please sign in to comment.