Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop
    1. Home
    2. nb
    3. Posts
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 2
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by nb

    • RE: Typescrypt array help.

      මේ වැඩේ හිතුවට වඩා සංකීර්ණයි. කොහොම හරි O(n2) solution එකක් හොයා ගත්තා.

      interface Steps extends Record<string, any> { 
          startDate: String; 
          endDate: String; 
          steps: Number
      }
      
      interface Distance extends Record<string, any> { 
          startDate: String; 
          endDate: String; 
          distance: Number
      }
      
      let steps: Array<Steps> = [
          { startDate: '2020-10-21', endDate: '2020-10-22', steps: 101 }, 
          { startDate: '2020-10-22', endDate: '2020-10-23', steps: 102 },
          { startDate: '2020-10-24', endDate: '2020-10-25', steps: 103 }
      ];
      
      let activity: Array<Distance> = [
          { startDate: '2020-10-21', endDate: '2020-10-22', distance: 101 }, 
          { startDate: '2020-10-22', endDate: '2020-10-23', distance: 102 },
          { startDate: '2020-10-26', endDate: '2020-10-26', distance: 103 }
      ];
      
      function join<L extends Record<string,any>, R extends Record<string,any>>(left: Array<L>,  right: Array<R>,  by: Array<string>) {
          const joined: Array<L&R> = [];
      
          for (let l of left) {
              const fromRight = right.find(r => by.every((curr) => (r[curr] == l[curr]), true))
              if (fromRight === undefined)
                  continue;
              joined.push({ ...fromRight, ...l})
          }
      
          return joined;
      }
      
      console.log(join(steps, activity, ['startDate', 'endDate']))
      /*
      [LOG]: [{
        "startDate": "2020-10-21",
        "endDate": "2020-10-22",
        "distance": 101,
        "steps": 101
      }, {
        "startDate": "2020-10-22",
        "endDate": "2020-10-23",
        "distance": 102,
        "steps": 102
      }] 
      */
      

      Types දාපු හැටි හරිද දන්නෑ. logic එක නං හරි.

      Playground link

      posted in Front-End Development
      nb
      nb
    • RE: Flutter App එකක සිංහල අකුරු ටයිප් කරන්න

      FM fonts standard නොවෙන නිසා flutter එක්ක පාවිච්චි කරන්න පුළුවන් වෙන එකක් නෑ. මොකද එහෙම පෙන්වන්න නම් FM to Unicode converter එකකුත් embed කරන්න වෙයි.

      ලිනක්ස් වල english වලින් ටයිප් කරලා theme font එක FM Malithi දාන්න ඕනේ

      ඇයි එහෙම කරන්න ඕනෙ වෙන්නෙ?

      posted in Flutter
      nb
      nb
    • 1 / 1