[링크 : https://stackoverflow.com/questions/5467129/sort-javascript-object-by-key/31102605]


'Programming > javascript & HTML' 카테고리의 다른 글

브라우저 닫기, 창 이동시 이벤트  (0) 2018.11.30
javascript 변수 정확도  (0) 2018.11.26
wavesurfer.js 그리고 HE-AACv2  (0) 2018.11.21
requireJS  (0) 2018.11.21
[Violation] 'setInterval' handler took  (0) 2018.11.18
Posted by 구차니

크롬에서는 HE-AACv2를 지원하지 않는건가? edge는 되는데 머야...

Uncaught (in promise) DOMException: Unable to decode audio data


[링크 : https://bugs.chromium.org/p/chromium/issues/detail?id=409402]

[링크 : https://bugs.chromium.org/p/chromium/issues/detail?id=534301]

[링크 : https://github.com/katspaugh/wavesurfer.js/issues/703]

'Programming > javascript & HTML' 카테고리의 다른 글

javascript 변수 정확도  (0) 2018.11.26
js object array sort by key  (0) 2018.11.21
requireJS  (0) 2018.11.21
[Violation] 'setInterval' handler took  (0) 2018.11.18
JSON.stringify() 주의사항(?)  (0) 2018.11.17
Posted by 구차니

node.js 예제를 보다 보면

분명히(?) client side인데 require가 있어서 보는 중..

require.js로 JS들을 조건부 load 할 수 있다고 하는데...

[링크 : https://requirejs.org/docs/commonjs.html]


AMD는 Asynchronous Module Definition (비동기 모듈 정의) 규칙이다.

[링크 : https://blog.pigno.se/post/157992405313]



// EITHER - accessing modules with <script> tags

var WaveSurfer = window.WaveSurfer;

var TimelinePlugin = window.WaveSurfer.timeline;

var MinimapPlugin = window.WaveSurfer.minimap;


// OR - importing as es6 module

import WaveSurfer from 'wavesurfer.js';

import TimelinePlugin from 'wavesurfer.js/dist/plugin/wavesurfer.timeline.min.js';

import MinimapPlugin from 'wavesurfer.js/dist/plugin/wavesurfer.minimap.min.js';


// OR - importing as require.js/commonjs modules

var WaveSurfer = require('wavesurfer.js');

var TimelinePlugin = require('wavesurfer.js/dist/plugin/wavesurfer.timeline.min.js');

var MinimapPlugin = require('wavesurfer.js/dist/plugin/wavesurfer.minimap.min.js');


// ... initialising waveform with plugins

var wavesurfer = WaveSurfer.create({

    container: '#waveform',

    waveColor: 'violet',

    plugins: [

        TimelinePlugin.create({

            container: '#wave-timeline'

        }),

        MinimapPlugin.create()

    ]

}); 


[링크 : https://wavesurfer-js.org/doc/]

'Programming > javascript & HTML' 카테고리의 다른 글

js object array sort by key  (0) 2018.11.21
wavesurfer.js 그리고 HE-AACv2  (0) 2018.11.21
[Violation] 'setInterval' handler took  (0) 2018.11.18
JSON.stringify() 주의사항(?)  (0) 2018.11.17
canvas to input type=file formdata  (0) 2018.11.15
Posted by 구차니

걍 경고인가 문제가 있는건가.. 모르겠네


[링크 : https://forum.vuejs.org/t/how-to-debug-chrome-violation-message-handler-took/36928/2]


+

2018.11.19


"Chrome violations" don't represent Chrome bugs or app errors. They are warnings intended to help you improve your script. Here, Chrome is alerting you there's probably an opportunity to speed up your script.


("Violation" is arguably misleading terminology; what it really means is that the script violates a pre-defined guideline. These messages first appeared in Chrome in early 2017 and should ideally have a "More info" prompt to elaborate on the meaning and give suggested actions to the developer. Hopefully those will be added in the future.) 

[링크 : https://stackoverflow.com/.../javascript-chrome-violation-violation-handler-took-83ms-of-runtime]

'Programming > javascript & HTML' 카테고리의 다른 글

wavesurfer.js 그리고 HE-AACv2  (0) 2018.11.21
requireJS  (0) 2018.11.21
JSON.stringify() 주의사항(?)  (0) 2018.11.17
canvas to input type=file formdata  (0) 2018.11.15
jwt token ajax  (2) 2018.11.08
Posted by 구차니

+ 2018.11.19

걍.. stringify 하고 == 이렇게 비교한게 정상적으로 안되고

원래 배열을 == 로 비교하니 잘되는 희한한 문제..


그리고 코드에서 임시 객체는 삽입해 주었는데 그게 어떻게 내가 잘 못 이해해서

삽입전이거나 그렇게 비교해서 내부 객체를 안한걸로 보인거 같기도 한데

코드 변경해버려서 다시 보기도 귀찮...

---


JSON 객체 내부에 array가 있으면 얘는 별도로 stringify 해주지 않는다.

모지?


+

[링크 : https://medium.com/@cheonmyung0217/구현-json-stringify-를-재귀함수로-구현하기-972f08622562]


+

var a = {"a":"a","b":"b"}

undefined

a

{a: "a", b: "b"}

JSON.stringify(a)

"{"a":"a","b":"b"}"


var b = {"a":"a","b":"b","c":{"c":"c"}}

undefined

JSON.stringify(b)

"{"a":"a","b":"b","c":{"c":"c"}}"


var c = {"a":a,"b":b}

undefined

JSON.stringify(c)

"{"a":{"a":"a","b":"b"},"b":{"a":"a","b":"b","c":{"c":"c"}}}" 


'Programming > javascript & HTML' 카테고리의 다른 글

requireJS  (0) 2018.11.21
[Violation] 'setInterval' handler took  (0) 2018.11.18
canvas to input type=file formdata  (0) 2018.11.15
jwt token ajax  (2) 2018.11.08
js forEach 에서 다음 문장 실행하기  (0) 2018.11.08
Posted by 구차니

'Programming > javascript & HTML' 카테고리의 다른 글

[Violation] 'setInterval' handler took  (0) 2018.11.18
JSON.stringify() 주의사항(?)  (0) 2018.11.17
jwt token ajax  (2) 2018.11.08
js forEach 에서 다음 문장 실행하기  (0) 2018.11.08
js str2ip  (0) 2018.11.07
Posted by 구차니

흐음.. JWT를 써서 header에 박히면

window.localStrorage를 통해서 접근이 가능하다는데...

왜 안될까 ㅠㅠ


[링크 : https://stackoverflow.com/.../how-to-send-a-token-with-an-ajax-request-from-jquery/35870238]

Posted by 구차니

continue 안 먹으니 return으로 해결


[링크 : https://stackoverflow.com/questions/31399411/go-to-next-iteration-in-javascript-foreach-loop]

'Programming > javascript & HTML' 카테고리의 다른 글

canvas to input type=file formdata  (0) 2018.11.15
jwt token ajax  (2) 2018.11.08
js str2ip  (0) 2018.11.07
자바 스크립트 중복 제거된 배열 얻기(집합)  (0) 2018.11.06
canvas 이미지 품질 저하  (0) 2018.11.06
Posted by 구차니

스트링을 파싱해서 할까 하다가 멘탈 붕괴..

다른 사람에게 물어보니 검색하면 되지~ 라는 대답

헐.. 검색해볼걸 생각못한 내 상태를 보니..

뇌 구석구석 시냅스 사이사이 미세먼지가 낀 탓인듯... -_-


아무튼 결론 : 걍 하나 만들면 되지 머...

(어짜피 만들려고 하던거 머...)


function str2ip(str) {
var val = 0;
var dot = str.split(".");
val = (dot[0] << 24) + (dot[1] << 16) + (dot[2] << 8) + dot[3];
return val;
}


[링크 : https://stackoverflow.com/questions/20330865/validate-ip-range-and-subnets]

[링크 : https://stackoverflow.com/questions/8105629/ip-addresses-stored-as-int-results-in-overflow]


+

위의 코드는 정상적으로 계산되지 않는다. -_-

+() 를 해서 값으로 혹은 양수로 인식시켜야 하는 듯?


function str2ip(str) {
var val = 0;
var dot = str.split(".");
val = (+(dot[0]) << 24) + (+(dot[1]) << 16) + (+(dot[2]) << 8) + +(dot[3]);
return val;
}


Posted by 구차니

배열에서 중복된 값을 제거하려니..

ES6 부터는 set(집합)을 이용하면되고

그 이전에는 filter와 indexof를 이용해서 중복을 제거하면 된다.


Use new ES6 feature: [...new Set( [1, 1, 2] )];

function uniqueArray0(array) {

  var result = Array.from(new Set(array));

  return result    

}


Use filter + indexOf

function uniqueArray3(a) {

  function onlyUnique(value, index, self) { 

      return self.indexOf(value) === index;

  }


  // usage

  var unique = a.filter( onlyUnique ); // returns ['a', 1, 2, '1']


  return unique;

}

[링크 : https://stackoverflow.com/questions/1960473/get-all-unique-values-in-a-javascript-array-remove-duplicates]

[링크 : https://codeburst.io/javascript-array-distinct-5edc93501dc4]


Posted by 구차니