GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Notices by Axel Rauschmayer (rauschma@fosstodon.org), page 4

  1. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Monday, 22-Jan-2024 10:55:47 JST Axel Rauschmayer Axel Rauschmayer

    1/ #TypeScript & ESM—modern approach that works for me (feedback appreciated!)

    ## package.json

    – Only "exports"—no more "main", "module", "types", "typesVersions"
    – Pairings:
    – m.d.ts next to m.js
    – m.d.mts next to m.mjs

    Tree of files:

    "exports": {
    "./*": "./dist/src/*"
    },

    Single file:

    "exports": {
    ".": "./dist/src/library.js"
    },

    ## tsconfig.json

    "module": "NodeNext",
    "moduleResolution": "NodeNext",

    ## Documentation

    – https://nodejs.org/api/packages.html#package-entry-points
    – https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports

    In conversation Monday, 22-Jan-2024 10:55:47 JST from fosstodon.org permalink

    Attachments

    1. No result found on File_thumbnail lookup.
      Modules: Packages | Node.js v21.6.0 Documentation
    2. No result found on File_thumbnail lookup.
      Documentation - Modules - Reference
      Module syntax and compiler options reference
  2. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Sunday, 21-Jan-2024 06:47:44 JST Axel Rauschmayer Axel Rauschmayer

    Concatenating strings: template literal vs. concatenating parameters:
    b.inlines(`<${tag}${attributes?.toHtml() ?? ''}>`);
    b.inlines('<', tag, attributes?.toHtml() ?? '', '>');

    Both are verbose. I think I slightly prefer the latter version because the additional space between the pieces helps with reading. It reminds me of the /x flag for regular expressions (see first example): https://xregexp.com/#:~:text=XRegExp%20lets%20you%20write%20regexes%20like%20this

    In conversation Sunday, 21-Jan-2024 06:47:44 JST from fosstodon.org permalink

    Attachments

    1. No result found on File_thumbnail lookup.
      JavaScript Regex :: XRegExp
  3. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Friday, 19-Jan-2024 03:29:02 JST Axel Rauschmayer Axel Rauschmayer
    in reply to
    • Sergey Shandar

    @functionalscript BTW, I can see the appeal of going class-less—it’s more reminiscent of functional programming. Alas, JS misses a few features here—especially algebraic data types and matching.

    In conversation Friday, 19-Jan-2024 03:29:02 JST from fosstodon.org permalink
  4. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Friday, 19-Jan-2024 03:29:02 JST Axel Rauschmayer Axel Rauschmayer
    in reply to
    • Sergey Shandar

    @functionalscript Interesting!

    I find myself starting with object types and often (not always) converting them to classes because I prefer them over factory functions for objects when things get more complicated:
    – Methods
    – Explicit runtime type

    In conversation Friday, 19-Jan-2024 03:29:02 JST from fosstodon.org permalink
  5. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Friday, 19-Jan-2024 03:10:43 JST Axel Rauschmayer Axel Rauschmayer

    Class-based cloning in #TypeScript is tricky. Ideas?

    🟢 Approach 1:
    abstract class SuperClass {
    abstract clone(): this;
    }

    Problem: Subclass S can’t invoke its constructor and return the result. TS will complain that `this` could be an instance of a subclass of S; then type is indeed wrong.

    🟢 Approach 2: structuredClone
    Downsides:
    A. Prototypes not preserved (*)
    B. Private properties not copied

    (B) is fatal for nested class instances.

    (*) https://2ality.com/2022/01/structured-clone.html#instances-of-user-defined-classes-become-plain-objects

    In conversation Friday, 19-Jan-2024 03:10:43 JST from fosstodon.org permalink

    Attachments

    1. No result found on File_thumbnail lookup.
      `structuredClone()`: deeply copying objects in JavaScript
      Spreading is a common technique for copying objects in JavaScript: Spreading into an Array literal to copy an Array Spreading into an Object literal to copy a plain object Spreading has one significant downside – it creates shallow copies: The top levels are copied, but property values are shared. structuredClone() is a new function that will soon be supported by most browsers, Node.js and Deno. It creates deep copies of objects. This blog post explains how it works.
  6. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Saturday, 30-Dec-2023 05:36:00 JST Axel Rauschmayer Axel Rauschmayer

    Making sense of “senseless” JavaScript features:

    – 0.1 + 0.2 and the floating point format
    – Type coercion
    – Automatic semicolon insertion
    – Why so many bottom values?
    – Increment (++) and decrement (--)

    https://www.smashingmagazine.com/2023/12/making-sense-of-senseless-javascript-features/

    #JavaScript

    In conversation Saturday, 30-Dec-2023 05:36:00 JST from fosstodon.org permalink

    Attachments

    1. Domain not in remote thumbnail source whitelist: files.smashing.media
      Making Sense Of “Senseless” JavaScript Features — Smashing Magazine
      from https://www.smashingmagazine.com/author/juan-diego-rodriguez/
      JavaScript may be the most popular client-side language in the world, but it’s far from perfect and not without its quirks. Juan Diego Rodriguez examines several “absurd” JavaScript eccentricities and explains how they made it into the language as well as how to avoid them in your own code.
  7. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Saturday, 30-Dec-2023 05:35:59 JST Axel Rauschmayer Axel Rauschmayer
    in reply to

    1/ W.r.t. optional parameters, JavaScript having both `undefined` and `null` becomes useful because we can distinguish between a parameter being `null` and it being omitted. (Probably not enough of an upside to outweigh the downsides elsewhere.)

    In light of this, I’m wondering if we should try to never explicitly use `undefined`—unless we need to skip a positional parameter:

    func(1, undefined, 3)

    Often better: named parameters (see link below).

    https://exploringjs.com/impatient-js/ch_callables.html#parameter-handling

    In conversation Saturday, 30-Dec-2023 05:35:59 JST from fosstodon.org permalink
  8. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Saturday, 30-Dec-2023 05:35:58 JST Axel Rauschmayer Axel Rauschmayer
    in reply to

    2/ Note that we can create our own special “parameter is missing” values via default parameter values (=we don’t really need a built-in `undefined`):

    const MISSING = Symbol('MISSING');
    function f(param = MISSING) {
    return param === MISSING ? 'MISSING' : param;
    }

    Using this function:

    > f()
    'MISSING'
    > f(undefined) // also triggers the default value
    'MISSING'
    > f(null)
    null
    > f('abc')
    'abc'

    In conversation Saturday, 30-Dec-2023 05:35:58 JST from fosstodon.org permalink
  9. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Thursday, 07-Dec-2023 23:21:48 JST Axel Rauschmayer Axel Rauschmayer

    Leopard: Convert your Scratch projects to JavaScript
    https://leopardjs.com/

    In conversation Thursday, 07-Dec-2023 23:21:48 JST from fosstodon.org permalink

    Attachments

    1. Leopard
  10. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Friday, 24-Nov-2023 20:08:07 JST Axel Rauschmayer Axel Rauschmayer
    • Josh Goldberg 💖

    As explained by @JoshuaKGoldberg, TypeScript doesn’t use semantic versioning (semver): “A new major version of TypeScript (e.g. 5.0.0) is released if the minor version would have exceeded 9 (e.g. 4.10.0).”
    https://www.learningtypescript.com/articles/why-typescript-doesnt-follow-strict-semantic-versioning

    It’s interesting that people don’t seem to be aware of that and are hesitant about upgrading to a different major version: https://majors.nullvoxpopuli.com/q?minors=on&packages=typescript

    #TypeScript

    In conversation Friday, 24-Nov-2023 20:08:07 JST from fosstodon.org permalink

    Attachments


    1. No result found on File_thumbnail lookup.
      Downloads by Major
      Reveal problems users are having with upgrading to the next major. Search for a package to see if its ecosystem has an upgrading problem.
  11. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Wednesday, 22-Nov-2023 23:41:29 JST Axel Rauschmayer Axel Rauschmayer

    “Infocom’s ingenious code-porting tools for ‘Zork’ and other games have been found”
    https://arstechnica.com/gaming/2023/11/infocoms-ingenious-code-porting-tools-for-zork-and-other-games-have-been-found/

    Manual by Infocom: "Learning ZIL: everything you always wanted to know about writing interactive fiction but couldn’t find anyone still working here to ask"

    In conversation Wednesday, 22-Nov-2023 23:41:29 JST from fosstodon.org permalink

    Attachments

    1. Domain not in remote thumbnail source whitelist: cdn.arstechnica.net
      manual | Ars Technica
      Serving the Technologist for more than a decade. IT news, reviews, and analysis.
  12. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Wednesday, 08-Nov-2023 09:31:45 JST Axel Rauschmayer Axel Rauschmayer

    Occasionally, I need to collect pieces of text from an HTML page and run code like this in a browser console:

    copy(
    Array.from(document.querySelectorAll('h2'))
    .map(h2 => h2.innerText)
    .join('\n')
    )

    You can also map via the second optional parameter of Array.from(), but I find my version nicer to read (even though it’s less efficient).
    https://exploringjs.com/impatient-js/ch_arrays.html#Array.from

    #JavaScript #HTML

    In conversation Wednesday, 08-Nov-2023 09:31:45 JST from fosstodon.org permalink

    Attachments

    1. No result found on File_thumbnail lookup.
      Arrays (`Array`) • JavaScript for impatient programmers (ES2022 edition)
  13. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Wednesday, 08-Nov-2023 09:31:44 JST Axel Rauschmayer Axel Rauschmayer
    in reply to

    Once JavaScript has iterator helper methods (*), this code becomes:

    copy(
    document.querySelectorAll('h2')
    .values()
    .map(h2 => h2.innerText)
    // Alas, there is no .join()
    // Roughly equivalent:
    .reduce((str, elem) => str+elem+'\n')
    )

    https://2ality.com/2022/12/iterator-helpers.html

    #JavaScript #HTML

    In conversation Wednesday, 08-Nov-2023 09:31:44 JST from fosstodon.org permalink

    Attachments

    1. No result found on File_thumbnail lookup.
      ECMAScript proposal: iterator helpers
      In this blog post, we look at the ECMAScript proposal “Iterator helpers” by Gus Caplan, Michael Ficarra, Adam Vandolder, Jason Orendorff, Kevin Gibbons, and Yulia Startsev. It introduces utility methods for working with iterable data: .map(), .filter(), .take(), etc. The style of the proposed API clashes with the style of the current iteration API. We’ll explore how we can fix that.
  14. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Sunday, 29-Oct-2023 02:20:26 JST Axel Rauschmayer Axel Rauschmayer

    I love how each file stored on Google Drive has a unique ID and is not identified by its pathname. Thus, we can rename any component of a pathname without losing the link with the file. We can even move it somewhere else.

    It reminds me of Lifestreams where a file system is a chronologically ordered stream of files with unique IDs. Instead of folders, there are tags and queries. That makes creating a file simpler because we don’t have to choose a name and a location.
    https://2ality.com/2011/04/information-management-classics.html

    In conversation Sunday, 29-Oct-2023 02:20:26 JST from fosstodon.org permalink

    Attachments

    1. No result found on File_thumbnail lookup.
      http://else.It/
    2. Domain not in remote thumbnail source whitelist: 2ality.com
      Information management classics: Lifestreams (1996)
      Lifestreams [1] were created in 1996 to correct some of the shortcomings of document management when used for personal information management. Even today, document management is still the dominant way of information management, both conceptually and as a user interface metaphor. Some of the shortcomings are:
  15. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Thursday, 29-Jun-2023 02:15:18 JST Axel Rauschmayer Axel Rauschmayer
    in reply to
    • FediTips has moved!

    @feditips “Toot” seems to be on its way out though(?) At least in the Mastodon UI. Personally, I welcome that, I have always called them “posts”.

    In conversation Thursday, 29-Jun-2023 02:15:18 JST from fosstodon.org permalink
  16. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Thursday, 24-Nov-2022 06:06:48 JST Axel Rauschmayer Axel Rauschmayer

    #Github does anyone know what the blue dot means?

    Update: As mentioned in the replies, the blue dot was alerting me to a new feature (code spaces). Once I clicked on the “learn more” link, it went away.

    In conversation Thursday, 24-Nov-2022 06:06:48 JST from fosstodon.org permalink

    Attachments


    1. https://cdn.fosstodon.org/media_attachments/files/109/394/042/769/000/526/original/73c037e48d32a173.jpeg
  17. Embed this notice
    Axel Rauschmayer (rauschma@fosstodon.org)'s status on Sunday, 30-Oct-2022 08:00:19 JST Axel Rauschmayer Axel Rauschmayer
    in reply to
    • FediTips has moved!

    @feditips I prefer exchanging profile URLs because those are easy to check out via a web browser.

    In conversation Sunday, 30-Oct-2022 08:00:19 JST from fosstodon.org permalink
  • After

User actions

    Axel Rauschmayer

    Axel Rauschmayer

    Topics: #JavaScript #TypeScript #fedi22Other interests:– Languages: German, English, French, Spanish, Dutch, Mandarin– Sustainability, degrowth, permaculture, urbanism– Tiny houses– Education– Psychology, getting out of one’s head, heart-centered living– Minimalist spirituality: Advaita, Daoism, Buddhism, Christian mysticism, J. Krishnamurti, …I live in Munich. http://pronoun.is/heNon-tech:– :pixelfed: Photos: @rauschma– 💬 Languages: @langtales

    Tags
    • (None)

    Following 0

      Followers 0

        Groups 0

          Statistics

          User ID
          14578
          Member since
          29 Oct 2022
          Notices
          77
          Daily average
          0

          Feeds

          • Atom
          • Help
          • About
          • FAQ
          • TOS
          • Privacy
          • Source
          • Version
          • Contact

          GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

          Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.