Giter Club home page Giter Club logo

Comments (4)

altavir avatar altavir commented on September 25, 2024

An example. Here how test looked before:

        val input = bytes.input()
        val ba = ByteArray(2)
        input.readArray(ba)

        assertEquals(0x11, ba[0])
        assertEquals(0x22, ba[1])

        assertEquals(0x12, input.readByte())
        assertEquals(0x82u, input.readUByte())
        assertEquals(0x3456, input.readShort())
        assertEquals(0x789abcde, input.readInt())
        assertEquals(1.25, input.readDouble())
        assertEquals(1.25f, input.readFloat())

        val ll = (1..8).map { input.readByte().toInt() and 0xff }.joinToString()
        assertEquals("18, 52, 86, 120, 154, 188, 222, 240", ll)
        assertEquals(0x123456789abcdef0, input.readLong())

        assertEquals("OK", input.readUTF8Line())

After:

        bytes.read {
            val ba = ByteArray(2)
            readArray(ba)

            assertEquals(0x11, ba[0])
            assertEquals(0x22, ba[1])

            assertEquals(0x12, readByte())
            assertEquals(0x82u, readUByte())
            assertEquals(0x3456, readShort())
            assertEquals(0x789abcde, readInt())
            assertEquals(1.25, readDouble())
            assertEquals(1.25f, readFloat())

            val ll = (1..8).map { readByte().toInt() and 0xff }.joinToString()
            assertEquals("18, 52, 86, 120, 154, 188, 222, 240", ll)
            assertEquals(0x123456789abcdef0, readLong())

            assertEquals("OK", readUTF8Line())
        }

from kotlinx-io.

altavir avatar altavir commented on September 25, 2024

Implemented with tests in altavir@9ab810d and altavir@6602436

from kotlinx-io.

jnorthrup avatar jnorthrup commented on September 25, 2024

the .read{} call plays well in my mind as a coroutinecontext with keys supporting the needs of readers, writers, and parser frameworks given their specific generic context keys that reduce the explicit accumulators and signalling parameters of being semi-stateful expression evaluations

from kotlinx-io.

fzhinkin avatar fzhinkin commented on September 25, 2024

We're rebooting the kotlinx-io development (see #131), all issues related to the previous versions will be closed. Consider reopening it if the issue remains (or the feature is still missing) in a new version.

from kotlinx-io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.