Xiaoyi1255 Github Documentation

website·Indexed 29 days ago

https://xiaoyi1255.github.io

Searchable website documentation for Xiaoyi1255 Github from https://xiaoyi1255.github.io.

Tokens
60.7K
Snippets
253
Records
304
Agent score
73%

What's inside Xiaoyi1255 Github Documentation

  1. Overview of Dart List data structure

    A List in Dart is a built-in data structure representing an ordered collection of elements. Key characteristics include:

    • Ordered: Elements can be accessed via their index.
    • Mutable: Elements can be added, removed, or modified.
    • Dynamic Length: The length typically changes as elements are added or removed, except for lists created with List.filled, which have a fixed length and cannot be expanded.
  2. Overview of the Vue effect lifecycle

    The effect serves as the bridge between reactive data and side-effect functions. The lifecycle follows these steps:

    1. Dependency Collection (Track): When a reactive property is read (via a get trap), the current effect is added to the dependency list for that property.
    2. Triggering Updates (Trigger): When a reactive property is modified (via a set trap), the trigger function is called, which identifies and re-executes all associated effect functions.
    3. Creation: Effects are created manually (for library authors), implicitly via watch and watchEffect, or automatically when using reactive objects within a template.
  3. Overview of Set in Dart

    A Set is a collection of unique elements. Duplicate elements are automatically ignored. Unlike a List, elements in a Set do not have a fixed order.
  4. Overview of Server-Sent Events (SSE)

    Server-Sent Events (SSE) is a web technology that allows servers to push data to clients over a single HTTP connection.

    Key Characteristics:

    • Unidirectional: Data flows only from server to client.
    • Lightweight: Simpler to implement than WebSockets.
    • Text-based: Supports text data only (unlike WebSockets which support binary).
    • Automatic Reconnection: Browsers automatically attempt to reconnect after an error.
    • Resource Efficient: More efficient than traditional polling.
  5. Overview of HTTP Caching and Header Priorities

    HTTP caching stores copies of Web resources (CSS, JS, images, pages) in the client (browser) or proxy servers (CDN) to reduce network resource usage, improve page performance, and lower server load.

    Cache Priority Order: Pragma > Cache-Control > Expires (Strong Cache) > Negotiated Cache (Weak Cache).

    Key Header Definitions:

    • Pragma: no-cache is used in request headers; behaves similarly to Cache-Control: no-cache.
    • Last-Modified / If-Modified-Since: Last-Modified (response header) indicates the last modification time; If-Modified-Since (request header) is used for validation.
    • ETag / If-None-Match: ETag (response header) is a unique identifier/hash of the resource; If-None-Match (request header) is used for validation.
    • Cache-Control: The primary header for modern caching (HTTP 1.1). Common directives include:
      • private: Only the browser (private cache) can store the response.
      • public: Both browser and proxy servers (shared cache) can store the response.
      • max-age=seconds: Resource is considered fresh for N seconds after generation.
      • s-maxage: Similar to max-age but specifically for shared caches.
      • no-cache: Response can be stored but must be re-validated with the server before reuse.
      • no-store: No part of the response may be cached; disables both strong and negotiated caching.
      • no-transform: Proxies must not modify the media type.
  6. Understand Service Worker caching capabilities

    Service Workers run as independent threads in the browser background, allowing developers to intercept network requests and control page caching. This enables features like offline access, faster page loads, and push notifications. Unlike standard browser caching (strong/negotiation caching) which is managed by the browser via HTTP headers, Service Worker caching is manually controlled by the developer, providing finer granularity over storage time and update strategies.

    Requirement: Service Workers must be deployed over HTTPS for security.

  7. Use numeric types in Dart

    Dart provides three primary types for representing numbers:

    • int: Represents integer values.
    • double: Represents floating-point numbers.
    • num: A supertype that can represent both integers and floating-point numbers.
  8. Understand Proxy and Reflect in Vue 3 Reactivity

    Vue 3 uses the ES6 Proxy object to intercept basic operations (like property lookup, assignment, and deletion) on objects, replacing the Object.defineProperty approach used in Vue 2. Reflect is used to perform the actual operation on the target object. The primary advantage of Reflect is that it returns a boolean indicating success or failure instead of throwing errors, making the interception logic more robust.
    const obj = { name: 'Vue', age: 3 };
    const proxyObj = new Proxy(obj, {
      get(target, key, receiver) {
        console.log(`getting ${key}`);
        return Reflect.get(target, key, receiver);
      },
      set(target, key, value, receiver) {
        console.log(`setting ${key} to ${value}`);
        return Reflect.set(target, key, value, receiver);
      },
      deleteProperty(target, key) {
        console.log(`deleting ${key}`);
        return Reflect.deleteProperty(target, key);
      },
      ownKeys(target) {
        return Reflect.ownKeys(target);
      },
      has(target, key) {
        return Reflect.has(target, key);
      },
    });
  9. Access common List properties

    Dart Lists provide several properties to quickly retrieve information about the collection's size and elements.
    List<Object> mixedList = [1, 'two', 3.0, 'four', 5];
    
    print(mixedList.length);      // 5: Total number of elements
    print(mixedList.first);         // 1: First element
    print(mixedList[0]);            // 1: First element via index
    print(mixedList.last);          // 5: Last element
    print(mixedList.isEmpty);       // false: True if list is empty
    print(mixedList.isNotEmpty);     // true: True if list contains elements
    print(mixedList.firstOrNull);    // 1: First element, or null if list is empty
  10. Architecture for a WebSocket-based Chat System

    A basic multi-user chat system can be structured as follows:

    Backend Stack:

    • ws: For WebSocket protocol implementation.
    • express: For server framework.
    • http: For handling the underlying HTTP server.
    • Logic: Manage server creation, listen for connections/disconnections, and maintain a mapping between rooms and members.

    Frontend Stack:

    • Vue 3: For reactive UI components.
    • antdv: For UI components (Modals, Buttons).
    • Logic: Handle WebSocket lifecycle (connect, listen, send, receive) and room state (create, join, leave).
  11. Backend architecture for chunked uploads

    The backend (implemented with Express, Busboy, and fs) must provide three primary capabilities:

    1. Chunk Reception: Save each uploaded chunk into a folder named after the file's MD5 hash.
    2. Chunk Merging: Read all chunks in the MD5 folder, sort them by index, and stream them into a single final file.
    3. Verification: Check if the MD5 folder exists and which specific chunk files are present to support breakpoint resumption.
  12. Retrieve File Metadata using Node.js fs

    The fs.statSync method in Node.js allows you to retrieve system information about a file, such as its modification time and size, which is useful for implementing Last-Modified headers.
    const fs = require('fs');
    const stats = fs.statSync(path);
    
    // Useful properties/methods:
    console.log(stats.isFile()); // true if it's a file
    console.log(stats.size); // File size in bytes